This also fixes the bug that prevented throttled http/2 streams from
ever re-starting by calling TransactionHasDataToRecv.
MozReview-Commit-ID: 5dFotZGhQk9
--HG--
extra : rebase_source : 2ba35bef4e17d90fc2abe52958bb6459b052b7e7
STS header checking was happening before http-on-examine-response which prevents
an observer from adding the STS headers to enforce STS. This moves the header
processing to after the notification occurs. In a webextension,
WebRequest.onHeadersReceived can now be used to inject STS and have that
recognized by HttpChannel.
MozReview-Commit-ID: KYZCSTBnZL7
--HG--
extra : rebase_source : 7a36fab9361e1da0223a4e63fe770228ea99538f
The SyntheticDiversionListener needs to handle the case where the IPC
connection is gone. This patch avoids calling Send* methods which will
crash the content process if the actor has already been destroyed.
Additionally, OnDataAvailable will return an error in such a case so
that the caller can properly handle the error rather than continuing to
attempt to send data to a listener that doesn't care. This latter
change is an artifact of a previous hack attempt to fix a related
diversion issue that is probably not required for this stack, but makes
sense as a fix, so I've left it in.
--HG--
extra : rebase_source : 824d4ab64e92ebb04d8d1ecd4df6d03a2cb37d2f
The diversion mechanism never expected to be dealing with data sourced
from the content process, but that's exactly what happens with
ServiceWorker-intercepted channels with the current child-intercept
situation (which is being fixed).
In order to allow timely cancellation of diverted intercepted
channels, there needs to be a way to relay to the HttpChannelChild
that it needs to be canceled so that the synthesized pump can be
canceled and diversion can be marked as complete. This patch adds
such a mechanism to ADivertableParentChannel and PHttpChannel for the
exclusive use of InterceptedHttpChannel and then uses it.
--HG--
extra : rebase_source : 59d3aa5e541d2a404c6320ae9fce03e7c9cd8b81
Diversion for intercepted channels with a synthesized response is a
special case. It is not appropriate to send DivertComplete when
mEventQ has been drained, because we are not dealing with the usual
mEventQ-enqueued OnDataAvailable payloads that had been received over
the network and sent down to the child. In this case, all the data
originates in the child and does not go through mEventQ. As such,
the correct place to send DivertComplete is at OnStopComplete for the
synthesized response.
--HG--
extra : rebase_source : 2209c25ad6f2b5655728d8dc07ef7f8b64df6ea6
The aim of this patch is to send trailers to child process via SendOnStopRequest.
--HG--
extra : rebase_source : 1a5e16e140ef20cfe2e723c3800d7feeebd9a5af
This patch includes:
1. Save http trailers in the header array in chunk decoder.
2. Take trailers from chunk decoder in OnStopRequest().
3. Add serverTiming attribute in nsITimedChannel.
4. Parse server timing header when GetServerTiming() is called.
--HG--
extra : rebase_source : 77c92b8a31d3d7eebb33aea266888f944af33327
1. Add a helper function Tokenize() which is able to handle quoted-string and quoted-pair.
2. Modify ParsedHeaderValueListList
- Use Tokenize() to split string by ','.
3. Modify ParsedHeaderValueList
- Use Tokenize() to split string by ';'.
- Function ParseNameAndValue() is for getting name and value from the string containing '='.
4. Handle backslash escapes for quoted string.
5. Reuse ParsedHeaderValueListList to parse server-timing header.
--HG--
extra : rebase_source : 7802a1ae9a6410c4ea992b1197018c5a3f994fa0
1. Create a new telemetry scalar SW_ALTERNATIVE_BODY_USED_COUNT to count the
number of the alternative body used in service worker synthesized channels.
2. To report values of fetching related time of InterceptChannel according to
the detail subresource type. Now subresource/script, subresource/other,
subresource/image and subresource/stylesheet are provided, and keep using
subresource for other types.
If UnknowDecoder is involved and the received content is short we will know whether we need to divert to parent only after OnStartRequest of the listener chain is called. Therefore do not do cleanup if we detect diversion.
Setting the InternalResponse's mCacheInfoChannel while needed, to avoid
keeping unnecessary nsICacheInfoChannel alive.
--HG--
extra : histedit_source : 39f9339b69db52b0278495d5247bc99ffd1d8f79
This also changes URIUtils.cpp:DeserializeURI() to use the mutator to instantiate new URIs, instead of using their default constructor.
MozReview-Commit-ID: JQOvIquuQAP
--HG--
extra : rebase_source : e146624c5ae423f7f69a738aaaafaa55dd0940d9
Currently if you write an async IPDL method which has a return value, we expose
a SendXXX method which returns a MozPromise. This MozPromise can then be
->Then-ed to run code when it is resolved or rejected.
Unfortunately, using this API loses ordering guarantees which IPDL provides.
MozPromise::Then takes an event target, which the resolve runnable is dispatched
to. This means that the resolve callback's code doesn't have any ordering
guarantees relative to the processing of other IPC messages coming over the same
protocol.
This adds a new overload to SendXXX with two additional arguments, a lambda
callback which is called if the call succeeds, and a lambda callback which is
called if the call fails. These will be called in order with other IPC messages
sent over the same protocol.
MozReview-Commit-ID: FZHJJaSDoZy
Previously, if a pushed stream was ended with a padding-only DATA frame
with the FIN bit set, and that stream didn't have a Content-Length,
there would be no way of knowing that the stream was finished. Now we
force-mark the push as complete if we hit a padding-only DATA frame with
the FIN bit set.
MozReview-Commit-ID: 7tk8x2FNgSj
--HG--
extra : rebase_source : b95f635b4bb0b4743cf81e888a455365ef561c22
Ever since bug 1340021 we were supposed to be collecting *_IS_SSL probes on
release, but the code in nsHttpChannel prevented it from happening.
MozReview-Commit-ID: IdU4Gppos6E
--HG--
extra : rebase_source : d8260883287eea1b6a651f1f89dcca9d06fd6cce
This makes the code nicer. In particular, it removes many getter_Copies()
calls. The patch also converts a lot of nsCStrings to nsAutoCString, which will
avoid heap allocation in the common case.
The patch also renames PREF_CopyCharPref() as PREF_GetCStringPref(), because
it's actually getting a string, not a char, and that matches the existing
GetCString() and GetDefaultCString() methods. Correspondingly, it also renames
PREF_SetCharPref() as PREF_SetCStringPref().
The |aPrefName| arguments in nsIPrefBranch.idl remain as |string| because they
almost always involve passing in C string literals, and passing "foo" is much
nicer than passing NS_LITERAL_CSTRING("foo").
It's worth noting that early versions of this patch used |AUTF8String| instead
of |ACString|. But it turns out that libpref stores prefs internally as Latin1.
And |ACString| is compatible with Latin1 but |AUTF8String| isn't, because
non-ASCII Latin1 strings are not valid UTF-8!
MozReview-Commit-ID: D3f7a1Vl1oE
--HG--
extra : rebase_source : e6e4b15d6d210cfd93686f96400281f02bd1d06b
This makes the code nicer. In particular, it removes many getter_Copies()
calls. The patch also converts a lot of nsCStrings to nsAutoCString, which will
avoid heap allocation in the common case.
The patch also renames PREF_CopyCharPref() as PREF_GetCStringPref(), because
it's actually getting a string, not a char, and that matches the existing
GetCString() and GetDefaultCString() methods. Correspondingly, it also renames
PREF_SetCharPref() as PREF_SetCStringPref().
The |aPrefName| arguments in nsIPrefBranch.idl remain as |string| because they
almost always involve passing in C string literals, and passing "foo" is much
nicer than passing NS_LITERAL_CSTRING("foo").
It's worth noting that early versions of this patch used |AUTF8String| instead
of |ACString|. But it turns out that libpref stores prefs internally as Latin1.
And |ACString| is compatible with Latin1 but |AUTF8String| isn't, because
non-ASCII Latin1 strings are not valid UTF-8!
--HG--
extra : rebase_source : 725ccf57943283a60ef8c9d654afe4515b4089f8
After data delivery for a request has been retargeted, there's no reliable way
to get the appropriate event target to re-dispatch data events after
asynchronous processing.
While it's technically possible to retrieve the current thread from
OnDataAvailable callbacks and re-use that for later dispatch, that approach
has some issues:
1) It's not currently possible to reliably map the current thread to the
thread pool that owns it. That means that if data delivery is being targetted
to a thread pool, attempts to redispatch events to the previous delivery
thread might lead to long delays when one thread in a pool is blocked.
2) If a filter wishes to dispatch data events to the wrapped listeners before
it's recieved any data (as extensions StreamFilters sometimes do), there's no
way to determine the proper event target without waiting for initial data to
be received.
Simply returning the correct event target from the request solves both of
these problems.
MozReview-Commit-ID: CJxq7O4399R
--HG--
extra : rebase_source : db2f659ecad16daafdbcc108d7b1a51ea1af31f9
nsHttpHandler is designed only for `getService` but we do not protect against `createInstance`.
The singleton of nsHttpHandler will be replaced by new instance created via `createInstance`.
gHttpHandler will hold a dangling pointer after the new instance is destroyed.
MozReview-Commit-ID: DQV6pmb5BUK
--HG--
extra : rebase_source : a6ab90038853e057c632efb5206cc26dcd71b897
When a WyciwygChannel is canceled, but WyciwygChannelParent::RecvCancel happens
after WyciwygChannelParent::SendOnStartRequest, it would send statusCode=NS_OK
to WyciwygChannelChild::OnStartRequest. So we should not apply the statusCode
if mCanceled, just like how HttpChannelChild handles it.
MozReview-Commit-ID: 5H3PUrlArIA
--HG--
extra : rebase_source : 9e8b034d293dc50d126327dc6452e95335e35ae6
When for some reason the target of a resource: substitution doesn't end
with a / (which can happen when e.g. building a FileURI with a path
that doesn't exist), relative path resolution of the resource URLs end
up rooted under the parent of the non-existing directory.
e.g
resource://foo/bar is substituted with /path/for/bar if
resource://foo/ is registered for file:///path/for/foo (instead of
file:///path/for/foo/)
--HG--
extra : rebase_source : b59dae0337a707a96adfc1c89c27235a856ec58e
When for some reason the target of a resource: substitution doesn't end
with a / (which can happen when e.g. building a FileURI with a path
that doesn't exist), relative path resolution of the resource URLs end
up rooted under the parent of the non-existing directory.
e.g
resource://foo/bar is substituted with /path/for/bar if
resource://foo/ is registered for file:///path/for/foo (instead of
file:///path/for/foo/)
--HG--
extra : rebase_source : 9907f7c54f43851ba1a956a5d278d301013204d2
When for some reason the target of a resource: substitution doesn't end
with a / (which can happen when e.g. building a FileURI with a path
that doesn't exist), relative path resolution of the resource URLs end
up rooted under the parent of the non-existing directory.
e.g
resource://foo/bar is substituted with /path/for/bar if
resource://foo/ is registered for file:///path/for/foo (instead of
file:///path/for/foo/)
--HG--
extra : rebase_source : 50a329318a2424bc5679a2e026e755271214224a
For netwerk/cache2/CacheFileInputStream.cpp:148 and netwerk/protocol/http/nsHttpHeaderArray.cpp:358,
missing "()" in the if statement.
For netwerk/base/rust-url-capi/test/test.cpp:29, netwerk/streamconv/converters/nsHTTPCompressConv.cpp:297,
and netwerk/streamconv/converters/nsHTTPCompressConv.cpp:300, null pointer will be returned but the
original memory buffer will not be freed if |realloc| fails. We should remember the original memory
buffer and free it if error is detected.
MozReview-Commit-ID: 2ggXsL73jYV
--HG--
extra : rebase_source : e47e41f2b37f717207bd13990efead22a14db1c0
In order to optionally report the full hash back to Google, we need to keep it
around in the callback. While a prefix is not the same as a full hash (multiple
full hashes can map to the same prefix), in this case, the callback will only be
called when the full hash matches.
MozReview-Commit-ID: F4WSLZpYrXB
--HG--
extra : rebase_source : da3b16b00729d0aa6ff1765a135b751fcf44c012
Add calls to OnStartRequest() and OnStopRequest() to properly handle async
read failures for remote JAR's and remote unpacked extension resources.
MozReview-Commit-ID: Dcg0LDht9B9
--HG--
extra : rebase_source : fef29e1601c1a53d3b7ff3a9d96450b3ab8fe003
OnStartRequest callback chain is interrupted by add-on during the "http-on-modify-request" observer event.
Therefore, nsInputStreamPump think OnStartRequest is finished. After resuming http channel, nsHttpChannel
asynchronously continue the OnStartRequest procedure and synchronously resume the nsInputStreamPump. Before
nsDocumentOpenInfo invoke the next OnStartRequest on the listener chain, sync XHR in web content is executed
on the call stack. This will spin main thread event queue and will eventually callback OnDataAvailable/OnStopRequest
on the same call stack.
nsHttpChannel should not resume the nsInputStreamPump before |mCallOnResume| is complete, to ensure that
no input stream event can interrupt the resumed call stack before it finished.
MozReview-Commit-ID: 6Q9EtMhcff9
--HG--
extra : rebase_source : 5685bacd9fbc95207a2a1349a8db66d53e3cc524
The NS_LITERAL_STRING macro creates a temporary nsLiteralString to encapsulate the char16_t string literal and its length, but AssignLiteral() can determine the char16_t string literal's length at compile-time without nsLiteralString.
MozReview-Commit-ID: H9I6vNDMdIr
--HG--
extra : rebase_source : cf537a1f65af003c6c4f8919b925b0f305c1dd4d
extra : source : 13b89ce4e6a66c840f82a335c71f5a12938aba22
The NS_LITERAL_CSTRING macro creates a temporary nsLiteralCString to encapsulate the string literal and its length, but AssignLiteral() can determine the string literal's length at compile-time without nsLiteralCString.
MozReview-Commit-ID: B5Y8KyExPQ8
--HG--
extra : rebase_source : e27b266c145daa5acd887e998c6d5b408101e1db
extra : source : 33f49977a33cbdb1c7127871b940eefccc018f65
The NS_LITERAL_CSTRING macro creates a temporary nsLiteralCString to encapsulate the string literal and its length, but AssignLiteral() can determine the string literal's length at compile-time without nsLiteralCString.
MozReview-Commit-ID: DbTW5Bhd9E1
--HG--
extra : rebase_source : b27f666e5ca832d814fb6846208474e1ec66e5f4
extra : source : 9ff4e11402a9a43ed90298a9c354b0164cf9414f
The NS_LITERAL_CSTRING macro creates a temporary nsLiteralCString to encapsulate the string literal and its length, but AssignLiteral() can determine the string literal's length at compile-time without nsLiteralCString.
MozReview-Commit-ID: F750v6NN81s
--HG--
extra : rebase_source : 714dd78df0f4c33e23e5b117615bd8fd561674c5
extra : source : 742bda9e6b1ddaf34d09894204ad18ce798b79b7
This is a preexisting issue that makes nsMultiplexInputStream multiple-inherit
from nsIInputStream: once via nsIMultipartInputStream and once via
nsIAsyncInputStream. This causes problems once we end up with more multiplex
streams that are async streams, because then some assingments to
nsCOMPtr<nsIInputStream> start asserting. This patch just removes the footgun
by getting rid of the multiple inheritance.
This is a preexisting issue that makes nsMultiplexInputStream multiple-inherit
from nsIInputStream: once via nsIMultipartInputStream and once via
nsIAsyncInputStream. This causes problems once we end up with more multiplex
streams that are async streams, because then some assingments to
nsCOMPtr<nsIInputStream> start asserting. This patch just removes the footgun
by getting rid of the multiple inheritance.
Race only when we're going to read from the disk cache storage. Also skip racing if we're going to write to the offline cache, because we need the cache entry which would be ignored if network wins the race.
Fix circular dependency created when encountering a path to a nonexistent JAR
inner file.
Change cache JAR loads to not use ExtensionStreamGetter, instead call the JAR
channel's AsyncOpen2 method directly in the SimpleChannel callback.
Remove the code to handle cached JAR loads from ExtensionStreamGetter.
MozReview-Commit-ID: Kmry02eLYU1
--HG--
extra : rebase_source : 2d750b393b77e23f6ec4e20c322214611f5daea7
When a tail request is canceled, neither mCachePump nor mTransactionPump was created. That means we have to call AsyncAbort to make sure that OnStopRequest() will be called and the request will be removed from the load group.
For some reason, triggering network directly from MaybeRaceCacheWithNetwork() causes performance regression of tp6_facebook tests. This patch changes it so that an event is posted instead.
The patch also adds network.http.rcwn.min_wait_before_racing_ms preference which can be used by users to avoid immediate racing.
These methods return an addrefed raw pointer, which makes them easy to use in
ways that cause leaks. If they're to continue returning an addrefed pointer,
they should explicitly return an already_AddRefed.
This also switches to StaticRefPtr with ClearOnShutdown for the cached
pointers for the sake of sanity.
MozReview-Commit-ID: D0lDpU8Hqug
--HG--
extra : rebase_source : 7b199070805fc0472eaf8409932517700ed23d49
Fix ExtensionProtocolHandler::GetAsync() to handle failures returned
from AsyncOpen2() for cached JAR resources.
Don't call SetupEventTarget() in the cached JAR ExtensionStreamGetter
constructor because the event target is not needed and calling
SetupEventTarget() triggers a debug mode warning from
nsContentUtils::GetEventTargetByLoadInfo().
MozReview-Commit-ID: KjDsPNQWlwU
--HG--
extra : rebase_source : d44e8a1cdf358f364156a3dc2ac6a428b57d5e32
Also adds a mozilla/ResultExtensions.h header to define the appropriate
conversion functions for nsresult and PRResult. This is in a separate header
since those types are not available in Spidermonkey, and this is the pattern
other *Extensions.h headers follow.
Also removes equivalent NS_TRY macros and WrapNSResult inlines that served the
same purpose in existing code, and are no longer necessary.
MozReview-Commit-ID: A85PCAeyWhx
--HG--
extra : rebase_source : a5988ff770888f901dd0798e7717bcf6254460cd
This allows MOZ_TRY and MOZ_TRY_VAR to be transparently used in XPCOM methods
when compatible Result types are used.
Also removes a compatibility macro in SimpleChannel.cpp, and an identical
specialization in AddonManagerStartup, which are no longer necessary after
this change.
MozReview-Commit-ID: 94iNrPDJEnN
--HG--
extra : rebase_source : 24ad4a54cbd170eb04ded21794530e56b1dfbd82
We should not be declaring forward declarations for nsString classes directly,
instead we should use nsStringFwd.h. This will make changing the underlying
types easier.
--HG--
extra : rebase_source : b2c7554e8632f078167ff2f609392e63a136c299
This patch is mainly to add a probe to measure sw launch time. To do this, this
patch records the sw launch time when the sw is just spwaned and it's ready to
handle the incoming fetch event.
MozReview-Commit-ID: 3w5MNyhQNnd
--HG--
extra : rebase_source : 3228213d0ea6be1d23b9c49382f1f8d3c2f358f1
These are all easy cases where an nsXPIDLCString local variable is set via
getter_Copies() and then is null checked. The patch uses IsVoid() to replace
the null checks (and get() and EqualsLiteral() calls to replace any implicit
conversions).
--HG--
extra : rebase_source : 484ad42a7816b34b86afbe072e04ba131c1619c6
Most of these fields are not using any nsXPIDLCString-specific features.
The exceptions are mUserAgentOverride and mDefaultSocketType, which require a
little more care.
--HG--
extra : rebase_source : 50d2178b7bf10f6076fe27f2e65a4b63f1153590
The existing functions work with C strings but almost all the call sites use
Mozilla strings.
The replacement function has the following properties.
- It works with Mozilla strings, which makes it much simpler and also improves
the call sites.
- It appends to the destination string because that's what a lot of the call
sites need. For those that don't, we can just append to an empty string.
- It is declared outside the |extern "C"| section because there is no need for
it to be in that section.
Note: there is no 16-bit variant of nsAppendEscapedHTML(). This is because
there are only two places that need 16-bit variants, both rarely executed,
and so converting to and from 8-bit is good enough.
The patch also adds some testing of the new function, renaming
TestEscapeURL.cpp as TestEscape.cpp in the process, because that file is now
testing other kinds of escaping.
--HG--
rename : xpcom/tests/gtest/TestEscapeURL.cpp => xpcom/tests/gtest/TestEscape.cpp
extra : rebase_source : 51145ae2c9b0b4573c7ea0c342dcb246f9f14fb9
This patch removes the ability to select which protocols you want
included in necko, a wholly untested configuration that is broken in
practice. We have no need of this kind of configurability in necko.
In addition, this removes the final vestiges of rtsp support, which was
originally removed in bug 1295885 but still had some stuff hanging
around behind some ifdefs (that were never true).
MozReview-Commit-ID: KOEaDmit2IL
--HG--
extra : rebase_source : f6c2fdb972aaba46e922cda801252dc953550b94
netwerk/protocol/gio/nsGIOProtocolHandler.cpp:89:10: warning: 'return' will never be executed [-Wunreachable-code-return]
This `return NS_ERROR_FAILURE` statement at the end of this function is unreachable because all of the preceding switch statement's cases return.
MozReview-Commit-ID: 3qDu2IqTPrW
--HG--
extra : rebase_source : bcd8a07eee82b60fc071787ccb7df7d9f45d0679
These are all easy cases where an nsXPIDLCString local variable is set via
getter_Copies() and then is only used in ways that nsCStrings can also be used
(i.e. no null checks or implicit conversions to |char*|).
In every case the patch trivially replaces the nsXPIDLCString with an
nsCString. (Also, there are a couple of unused nsXPIDLCString variables that
the patch simply removes.)
This flags is added in the http channel interface by which developers can control the TLS
connections from JavaScript code (e.g. Add-ons). Basically, all the changes accounted for
plumbing this TLS flags from JavaScript level to C++ code responsible for calling NSS
module. We also added a unit test to make sure that separate connections are created if we
use different tlsFlags. Basically we used a concrete set of flag values that covers the
edge cases and check the hashkey generated in the connection info.
--HG--
rename : netwerk/test/unit/test_separate_connections.js => netwerk/test/unit/test_tls_flags_separate_connections.js
For Linux dev builds, change the developer build unpacked security check
exception to not depend on knowing the repo dir because MOZ_DEVELOPER_REPO
isn't reliably set whenever the firefox binary is run. Instead, make sure the
extension root directory is within NS_GRE_DIR. Use both checks on Mac.
MozReview-Commit-ID: IsbbNS58yf8
--HG--
extra : rebase_source : 64d1008a0513938edc111d12cb9fb28d2048ac82
These are all easy cases where an nsXPIDLCString local variable is set via
getter_Copies() and then is used in ways that rely on the implicit conversion
to |char*|. The patch uses get() and EqualsLiteral() calls to replace the
implicit conversions.
After bug 1338493 landed, HttpChannelChild might be released on STS thread.
Redirected channel, intercept stream listener and context might not always be able to
release off-main-thread. Therefore, we need to proxy release these members on main thread.
MozReview-Commit-ID: 6mcja7WY1fK
--HG--
extra : rebase_source : 55999dfa63b81347e426d90a59e211fabddba6d1
This removes about 2/3 of the occurrences of nsXPIDLString in the tree. The
places where nsXPIDLStrings are null-checked are replaced with |rv| checks.
The patch also removes a couple of unused declarations from
nsIStringBundle.idl.
Note that nsStringBundle::GetStringFromNameHelper() was merged into
GetStringFromName(), because they both would have had the same signature.
--HG--
extra : rebase_source : ac40bc31c2a4997f2db0bd5069cc008757a2df6d
As our threattype-listname conversion design, "goog-harmful-proto" is allocated
for this new threat type. This threat type is mainly for mobile.
MozReview-Commit-ID: G9GbgmHHHfp
--HG--
extra : rebase_source : 0681fcd9322b94451a86eafe57bf1ccc4b89db30
extra : intermediate-source : 28b0502d9add81beeae58a2c33f9fd5839d4d544
extra : source : 646f02f15131aa98ad37015b0a641304a3271796
When racing cache with network, conditional or byte range header could be added in OnCacheEntryCheck. We need to remove these headers when sending the network request, otherwise we would send a conditional request while not having the entry.