Closed
Bug 325177
Opened 19 years ago
Closed 18 years ago
Make the unknowndecoder implement nsIContentSniffer
Categories
(Core :: Networking, defect, P3)
Core
Networking
Tracking
()
RESOLVED
FIXED
mozilla1.9alpha1
People
(Reporter: Biesinger, Assigned: Biesinger)
References
Details
(Keywords: fixed1.8.1)
Attachments
(2 files, 4 obsolete files)
12.60 KB,
patch
|
bzbarsky
:
superreview+
|
Details | Diff | Splinter Review |
11.91 KB,
patch
|
darin.moz
:
approval-branch-1.8.1+
|
Details | Diff | Splinter Review |
...and make basechannel use that interface to get a content type. this will be necessary once basechannel implements stuff like nsIEncodedChannel, because applyDecoding can only be set during onStartRequest, and the stream converter in the middle has its own concept of onStartRequest.
Assignee | ||
Comment 1•19 years ago
|
||
had to change nsIInputStreamPump for this... see comments in the patch as for why.
Attachment #210099 -
Flags: review?(darin)
Assignee | ||
Updated•19 years ago
|
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → mozilla1.9alpha
Assignee | ||
Comment 2•19 years ago
|
||
er, this time, the right file
Attachment #210099 -
Attachment is obsolete: true
Attachment #210101 -
Flags: review?(darin)
Attachment #210099 -
Flags: review?(darin)
Comment 3•19 years ago
|
||
Comment on attachment 210101 [details] [diff] [review] patch Perhaps nsIInputStreamPump::stream should just return nsIAsyncInputStream. The comments on nsIInputStreamPump talk about nsIAsyncInputStream, and that's what mAsyncStream implements, so we might as well reveal that here. Instead of hard-coding 1024, you might want to use the #define from nsNetSegmentUtils.h (NET_DEFAULT_SEGMENT_SIZE).
Attachment #210101 -
Flags: review?(darin) → review+
Assignee | ||
Comment 4•19 years ago
|
||
Attachment #210101 -
Attachment is obsolete: true
Attachment #210284 -
Flags: superreview?(bzbarsky)
Comment 5•19 years ago
|
||
Comment on attachment 210284 [details] [diff] [review] with those changes >Index: netwerk/base/public/nsIContentSniffer.idl > * Content sniffer interface. Components implementing this interface can > * determine a MIME type from a chunk of bytes. Should this mention whether aRequest can be used for the sniffing? >+ * @param aRequest The request where this data came from. May be null. Or would that be better to mention here? In particular, should we talk about whether aData should "take precedence" over aRequest, whatever that means? Or at least document that it's undefined? >Index: netwerk/base/public/nsIInputStreamPump.idl >+ readonly attribute nsIAsyncInputStream stream; This should probably document that callers are not allowed to actually read data from the stream, right? Or otherwise change the state of the stream (e.g. seek, setEOF, etc)? In general, exposing the actual async stream here worries me a little bit; would it be safer to just return a shim object here that would disallow stream state changes on the underlying stream while allowing what you want? Or are we ok with just documenting this well? >Index: netwerk/streamconv/converters/nsUnknownDecoder.cpp >+// nsIStreamListener methods... You mean nsIContentSniffer methods, right? sr=bzbarsky with those nits fixed
Attachment #210284 -
Flags: superreview?(bzbarsky) → superreview+
Comment 6•19 years ago
|
||
Perhaps what we really want is a way to peek at the next chunk of data to be pumped.
Assignee | ||
Comment 7•19 years ago
|
||
mmm... we could make the pump implement nsIInputStream maybe?
Assignee | ||
Comment 8•19 years ago
|
||
(and implement it in a way that doesn't consume the data)
Comment 9•19 years ago
|
||
Hmm... maybe a better answer is to expose a private interface that is used internally by Necko to communicate this detail. We could even have the nsBaseChannel QI the nsIInputStreamPump to "nsInputStreamPump" (e.g., make nsInputStreamPump::QueryInterface return a pointer to nsInputStreamPump when aIID equals NS_INPUTSTREAMPUMP_CID). Then, we could put a friendly method on nsInputStreamPump that reveals the first chunk of data. class nsInputStreamPump : ... { public: ... typedef void (*PeekSegmentFun)(void *closure, const char *buf, PRUint32 bufLen); void PeekStream(PeekSegmentFun callback, void *closure); }; We could move this construct out onto an actual interface, but I'm not sure that that is really worth it since it would be non-scriptable.
Assignee | ||
Comment 10•19 years ago
|
||
hm... should baseChannel then maybe also create the pump using "new nsInputStreamPump" so that it can be sure that that function will be available? (It'd also avoid the qi'ing)
Comment 11•19 years ago
|
||
Yes, that sounds like a fine idea.
Assignee | ||
Comment 12•19 years ago
|
||
Attachment #210284 -
Attachment is obsolete: true
Attachment #211626 -
Flags: review?(darin)
Comment 13•19 years ago
|
||
So how would someone implementing a channel class (in an extension, say) do something similar?
Assignee | ||
Comment 14•19 years ago
|
||
I'd like to fix that by exposing basechannel to extensions and JS.
Comment 15•19 years ago
|
||
Sounds like a plan!
Comment 16•18 years ago
|
||
Comment on attachment 211626 [details] [diff] [review] the new approach >Index: netwerk/base/src/nsBaseChannel.cpp > #include "nsIChannelEventSink.h" > #include "nsIStreamConverterService.h" > >+#include "nsIContentSniffer.h" nit: please kill the newline here. >+static void >+CallTypeSniffers(void *aClosure, const PRUint8 *aData, PRUint32 aCount) >+{ >+ nsIChannel* chan = NS_STATIC_CAST(nsIChannel*, aClosure); >+ >+ nsCOMPtr<nsIContentSniffer> sniffer(do_CreateInstance(NS_GENERIC_CONTENT_SNIFFER)); nit: please break lines at 80 chars. nit: use a consistent style for the "*" ... this code uses "nsIChannel *chan" >+#ifdef DEBUG_chb >+ printf("### Detecting content type %s\n", detected.get()); >+#endif nit: prefer DEBUG_BASECHANNEL instead of user specific debug output. I would even prefer no #ifdef's scatter through the code. Maybe just declare DEBUG_PRINTF as a macro at the top of the file. >Index: netwerk/base/src/nsInputStreamPump.cpp >+CallPeekFunc(nsIInputStream *aInStream, void *aClosure, ... >+} >+ >+ nit: kill extra newline r=darin
Attachment #211626 -
Flags: review?(darin) → review+
Assignee | ||
Comment 17•18 years ago
|
||
I just removed the debug printfs
Attachment #211626 -
Attachment is obsolete: true
Attachment #211754 -
Flags: superreview?(bzbarsky)
Comment 18•18 years ago
|
||
Comment on attachment 211754 [details] [diff] [review] nits fixed >diff --git browser/components/bookmarks/content/bookmarks.js browser/components/bookmarks/content/bookmarks.js Hey, I'm all cool with you using git, but please do have more context and some equiv of the -p diff option, ok? ;) Code itself's ok. sr=bzbarsky
Attachment #211754 -
Flags: superreview?(bzbarsky) → superreview+
Assignee | ||
Comment 19•18 years ago
|
||
Comment on attachment 211754 [details] [diff] [review] nits fixed er, this does use the -p option (which is in fact the default with git) sorry about the context, will fix.
Assignee | ||
Comment 20•18 years ago
|
||
fixed on trunk. leaving open because I want to do a branch version of this, for bug 324985
Assignee | ||
Comment 21•18 years ago
|
||
this caused bug 328038
Assignee | ||
Comment 22•18 years ago
|
||
I'm using nsIContentSniffer_MOZILLA_1_8_BRANCH for the interface name, to make it clear that it's branch-only
Attachment #212777 -
Flags: approval-branch-1.8.1?(darin)
Comment 23•18 years ago
|
||
> I'm using nsIContentSniffer_MOZILLA_1_8_BRANCH for the interface name, to make
> it clear that it's branch-only
I don't understand. The interface is exactly the same on the trunk.
Assignee | ||
Comment 24•18 years ago
|
||
yeah, true. But I can't name it nsIContentSniffer on branch because it exists there already. I don't really want to name it nsIContentSniffer2 because that'd sound like trunk is behind branch.
Assignee | ||
Comment 25•18 years ago
|
||
so yeah, "branch-only" was a bad word to use.
Comment 26•18 years ago
|
||
OK, my apologies for being dense. I forgot that we were changing this interface. We should get consensus on naming convention for situations like this. Can you post a question to a mailing list or at least to a wide enough audience to make sure that everyone is on the same page with this solution?
Assignee | ||
Comment 27•18 years ago
|
||
ok, sent to bonecho + m.d.general
Comment 28•18 years ago
|
||
Comment on attachment 212777 [details] [diff] [review] branch patch a=darin given that there is precidence for the MOZILLA_1_8_BRANCH interface name suffix. If your posting results in any changes to this policy, then we'd want to make a blanket change, and that could include changing this post-facto.
Attachment #212777 -
Flags: approval-branch-1.8.1?(darin) → approval-branch-1.8.1+
Assignee | ||
Comment 29•18 years ago
|
||
fixed on branch.
You need to log in
before you can comment on or make changes to this bug.
Description
•