Closed Bug 632227 Opened 14 years ago Closed 14 years ago

NetUtil should have a helper method to read an input stream asynchronously

Categories

(Core :: Networking, defect)

x86
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla5

People

(Reporter: sdwilsh, Assigned: sdwilsh)

References

Details

(Keywords: dev-doc-complete)

Attachments

(1 file, 2 obsolete files)

It turns out to be really hard to read an input stream asynchronously (at least from JS). I'd like to make that easier with a new method on NetUtil. I considered modifying asyncFetch (and could still), but I feel like asyncRead makes more sense. Input welcome.
On second thought, the code is nearly identical for this new case. asyncFetch is probably the right place for this.
Attached patch v1.0 (obsolete) — Splinter Review
This was surprisingly painless.
Attachment #510439 - Flags: review?(bzbarsky)
Attached patch v1.1 (obsolete) — Splinter Review
Managed to miss two spots in the java-doc comment that talks about the source. Fixed now.
Attachment #510439 - Attachment is obsolete: true
Attachment #510440 - Flags: review?(bzbarsky)
Attachment #510439 - Flags: review?(bzbarsky)
I guess biesi might be a good person for sr?
Whiteboard: [needs review bz]
Blocks: 632238
Attachment #510440 - Flags: review?(bzbarsky) → review+
Attachment #510440 - Flags: superreview?(cbiesinger)
Whiteboard: [needs review bz] → [needs sr biesi]
Is it guaranteed that pump stays alive?
(In reply to comment #6) > Is it guaranteed that pump stays alive? Hmm, AFAICT, nothing. I think we have the same problem with the existing implementation and |channel|. bz - am I missing something here?
The pump is kept alive through the read process, yes. Basically, either the pump is waiting on the stream (and then the stream is keeping it alive) or it's inside OnInputStreamReady and there's a ref to it on the stack. Similar with channels; between AsyncOpen returning and OnStopRequest being called the channel is kept alive by the necko machinery.
Attachment #510440 - Flags: superreview?(cbiesinger) → superreview+
Attached patch v1.1 for checkinSplinter Review
Attachment #510440 - Attachment is obsolete: true
(In reply to comment #8) > The pump is kept alive through the read process, yes. Basically, either the > pump is waiting on the stream (and then the stream is keeping it alive) or it's > inside OnInputStreamReady and there's a ref to it on the stack. > > Similar with channels; between AsyncOpen returning and OnStopRequest being > called the channel is kept alive by the necko machinery. Thanks for the clarification!
Flags: in-testsuite?
Keywords: checkin-needed
Whiteboard: [needs sr biesi] → [can land]
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Flags: in-testsuite? → in-testsuite+
Resolution: --- → FIXED
Whiteboard: [can land]
Target Milestone: --- → mozilla2.2
Updated documentation: https://developer.mozilla.org/en/JavaScript_code_modules/NetUtil.jsm Also mentioned on Firefox 5 for developers.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: