Closed Bug 287750 Opened 20 years ago Closed 20 years ago

provide methods to test if streams are buffered

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.8beta2

People

(Reporter: darin.moz, Assigned: darin.moz)

Details

(Keywords: arch)

Attachments

(1 file)

provide methods to test if streams are buffered i.e., test if readSegments (or writeSegments) can be called.
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.8beta2
Attached patch v1 patchSplinter Review
Attachment #178634 - Flags: superreview?(bzbarsky)
Attachment #178634 - Flags: review?(cbiesinger)
Comment on attachment 178634 [details] [diff] [review] v1 patch interesting... nsStreamUtils.h + The test for this is to + * simply call readSegments, without actually consuming any data from the + * stream, to verify that it functions. should this be documented? For example, might a future version of nsIInputStream offer a function for direct testing of buffereredness, which this function might use instead? nsStreamUtils.cpp +static NS_METHOD +TestInputStream(nsIInputStream *inStr, does this need to use PR_CALLBACK? (or PR_STATIC_CALLBACK)
Attachment #178634 - Flags: review?(cbiesinger) → review+
> nsStreamUtils.h > + The test for this is to > + * simply call readSegments, without actually consuming any data from the > + * stream, to verify that it functions. > > should this be documented? For example, might a future version of > nsIInputStream offer a function for direct testing of buffereredness, which > this function might use instead? well... because of the interaction with non-blocking streams, i was concerned that consumers should understand how this check is being made. given that nsIInputStream is frozen, and given that there are ways for extensions to inject their own nsIInputStream implementations, I'm not sure how we'd ever be able to expand to test for buffered'ness directly. that said, it is probably sufficient to simply document the potentially odd behavior for non-blocking streams. > does this need to use PR_CALLBACK? (or PR_STATIC_CALLBACK) no, absolutely not. that would crash on windows.
>I'm not sure how we'd ever be able to expand to test for buffered'ness directly. well, we'll need nsIInputStream2 for 64-bit available(). so, we might want to add such a function there there.
> well, we'll need nsIInputStream2 for 64-bit available(). so, we might want to > add such a function there there. why do you need 64-bit available? available is meant to indicate how much data is available to be read from the stream right now. that can be less than the total size of the stream. it is a hack that we use available to get the entire length of the stream in other contexts.
well, ok. but we assume that in many places. consider nsIUploadChannel: 78 * @param aContentLength 79 * A value of -1 indicates that the length of the stream should be 80 * determined by calling the stream's |available| method. that makes no sense unless available indicates the total length of the data. now, this is probably a bug in the interface. but it is frozen. hm... /netwerk/protocol/file/src/nsFileChannel.cpp, line 118 -- mStream->Available((PRUint32 *) &mContentLength); that one should probably just stat the file (nsIFile.fileSize) I guess we can fix all the places that assume that...
> that makes no sense unless available indicates the total length of the data. > now, this is probably a bug in the interface. but it is frozen. right, that's a limitation of the nsIUploadChannel interface. if someone chooses to pass -1 for the content length, then they must know that available is going to be okay. it's just there for convenience.
Comment on attachment 178634 [details] [diff] [review] v1 patch sr=bzbarsky
Attachment #178634 - Flags: superreview?(bzbarsky) → superreview+
Actually, I decided to leave the comment about the implementation since I think it's important for callers to understand the side-effects of calling this function. I.e., that it is really going to call ReadSegments.
fixed i also added lines to dlldeps.cpp so that these would be exported on win32 ;-)
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: