author | Kershaw Chang <kechang@mozilla.com> |
Mon, 24 Jul 2017 23:50:00 +0200 | |
changeset 419557 | 1c61346d6f447a7dcc405aeea12ed7941c398764 |
parent 419556 | c926529797f2aa274403e0b4d1e42a2dbd330a9e |
child 419558 | 30c0fb1d099700f028316ee30ce7285134dcd99c |
push id | 7566 |
push user | mtabara@mozilla.com |
push date | Wed, 02 Aug 2017 08:25:16 +0000 |
treeherder | mozilla-beta@86913f512c3c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mayhemer |
bugs | 1377544 |
milestone | 56.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -10540,27 +10540,27 @@ nsContentUtils::HtmlObjectContentTypeFor // ShouldPlay will handle checking for disabled plugins return nsIObjectLoadingContent::TYPE_PLUGIN; } } return nsIObjectLoadingContent::TYPE_NULL; } -/* static */ already_AddRefed<nsIEventTarget> +/* static */ already_AddRefed<nsISerialEventTarget> nsContentUtils::GetEventTargetByLoadInfo(nsILoadInfo* aLoadInfo, TaskCategory aCategory) { if (NS_WARN_IF(!aLoadInfo)) { return nullptr; } nsCOMPtr<nsIDOMDocument> domDoc; aLoadInfo->GetLoadingDocument(getter_AddRefs(domDoc)); nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc); - nsCOMPtr<nsIEventTarget> target; + nsCOMPtr<nsISerialEventTarget> target; if (doc) { if (DocGroup* group = doc->GetDocGroup()) { target = group->EventTargetFor(aCategory); } } else { // There's no document yet, but this might be a top-level load where we can // find a TabGroup. uint64_t outerWindowId;
--- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -3023,17 +3023,17 @@ public: * nullptr in which case the docshell's plugin permissions * will not be checked. */ static uint32_t HtmlObjectContentTypeForMIMEType(const nsCString& aMIMEType, bool aNoFakePlugin, nsIContent* aContent); - static already_AddRefed<nsIEventTarget> + static already_AddRefed<nsISerialEventTarget> GetEventTargetByLoadInfo(nsILoadInfo* aLoadInfo, mozilla::TaskCategory aCategory); /** * Detect whether a string is a local-url. * https://drafts.csswg.org/css-values/#local-urls */ static bool IsLocalRefURL(const nsString& aString);
--- a/netwerk/protocol/res/ExtensionProtocolHandler.cpp +++ b/netwerk/protocol/res/ExtensionProtocolHandler.cpp @@ -1,29 +1,29 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "ExtensionProtocolHandler.h" -#include "mozilla/AbstractThread.h" #include "mozilla/ClearOnShutdown.h" #include "mozilla/ExtensionPolicyService.h" #include "mozilla/FileUtils.h" #include "mozilla/ipc/IPCStreamUtils.h" #include "mozilla/ipc/URIParams.h" #include "mozilla/ipc/URIUtils.h" #include "mozilla/net/NeckoChild.h" #include "mozilla/RefPtr.h" #include "FileDescriptor.h" #include "FileDescriptorFile.h" #include "LoadInfo.h" +#include "nsContentUtils.h" #include "nsServiceManagerUtils.h" #include "nsIFile.h" #include "nsIFileChannel.h" #include "nsIFileStreams.h" #include "nsIFileURL.h" #include "nsIJARChannel.h" #include "nsIMIMEService.h" #include "nsIURL.h" @@ -104,16 +104,18 @@ class ExtensionStreamGetter : public Ref // in an unpacked extension. ExtensionStreamGetter(nsIURI* aURI, nsILoadInfo* aLoadInfo) : mURI(aURI) , mLoadInfo(aLoadInfo) , mIsJarChannel(false) { MOZ_ASSERT(aURI); MOZ_ASSERT(aLoadInfo); + + SetupEventTarget(); } // To use when getting an FD for a packed extension JAR file // in order to load a resource. ExtensionStreamGetter(nsIURI* aURI, nsILoadInfo* aLoadInfo, already_AddRefed<nsIJARChannel>&& aJarChannel, nsIFile* aJarFile) : mURI(aURI) @@ -121,20 +123,31 @@ class ExtensionStreamGetter : public Ref , mJarChannel(Move(aJarChannel)) , mJarFile(aJarFile) , mIsJarChannel(true) { MOZ_ASSERT(aURI); MOZ_ASSERT(aLoadInfo); MOZ_ASSERT(mJarChannel); MOZ_ASSERT(aJarFile); + + SetupEventTarget(); } ~ExtensionStreamGetter() {} + void SetupEventTarget() + { + mMainThreadEventTarget = + nsContentUtils::GetEventTargetByLoadInfo(mLoadInfo, TaskCategory::Other); + if (!mMainThreadEventTarget) { + mMainThreadEventTarget = GetMainThreadSerialEventTarget(); + } + } + // Get an input stream or file descriptor from the parent asynchronously. Result<Ok, nsresult> GetAsync(nsIStreamListener* aListener, nsIChannel* aChannel); // Handle an input stream being returned from the parent void OnStream(nsIInputStream* aStream); // Handle file descriptor being returned from the parent @@ -144,16 +157,17 @@ class ExtensionStreamGetter : public Ref private: nsCOMPtr<nsIURI> mURI; nsCOMPtr<nsILoadInfo> mLoadInfo; nsCOMPtr<nsIJARChannel> mJarChannel; nsCOMPtr<nsIFile> mJarFile; nsCOMPtr<nsIStreamListener> mListener; nsCOMPtr<nsIChannel> mChannel; + nsCOMPtr<nsISerialEventTarget> mMainThreadEventTarget; bool mIsJarChannel; }; class ExtensionJARFileOpener : public nsISupports { public: ExtensionJARFileOpener(nsIFile* aFile, NeckoParent::GetExtensionFDResolver& aResolve) : @@ -220,47 +234,48 @@ NS_IMPL_ISUPPORTS(ExtensionJARFileOpener #define DEFAULT_THREAD_TIMEOUT_MS 30000 // Request an FD or input stream from the parent. Result<Ok, nsresult> ExtensionStreamGetter::GetAsync(nsIStreamListener* aListener, nsIChannel* aChannel) { MOZ_ASSERT(IsNeckoChild()); + MOZ_ASSERT(mMainThreadEventTarget); mListener = aListener; mChannel = aChannel; // Serialize the URI to send to parent mozilla::ipc::URIParams uri; SerializeURI(mURI, uri); // Serialize the LoadInfo to send to parent OptionalLoadInfoArgs loadInfo; NS_TRY(mozilla::ipc::LoadInfoToLoadInfoArgs(mLoadInfo, &loadInfo)); RefPtr<ExtensionStreamGetter> self = this; if (mIsJarChannel) { // Request an FD for this moz-extension URI gNeckoChild->SendGetExtensionFD(uri, loadInfo)->Then( - AbstractThread::MainThread(), + mMainThreadEventTarget, __func__, [self] (const FileDescriptor& fd) { self->OnFD(fd); }, [self] (const mozilla::ipc::PromiseRejectReason) { self->OnFD(FileDescriptor()); } ); return Ok(); } // Request an input stream for this moz-extension URI gNeckoChild->SendGetExtensionStream(uri, loadInfo)->Then( - AbstractThread::MainThread(), + mMainThreadEventTarget, __func__, [self] (const OptionalIPCStream& stream) { nsCOMPtr<nsIInputStream> inputStream; if (stream.type() == OptionalIPCStream::OptionalIPCStream::TIPCStream) { inputStream = ipc::DeserializeIPCStream(stream); } self->OnStream(inputStream); }, @@ -272,33 +287,35 @@ ExtensionStreamGetter::GetAsync(nsIStrea } // Handle an input stream sent from the parent. void ExtensionStreamGetter::OnStream(nsIInputStream* aStream) { MOZ_ASSERT(IsNeckoChild()); MOZ_ASSERT(mListener); + MOZ_ASSERT(mMainThreadEventTarget); // We must keep an owning reference to the listener // until we pass it on to AsyncRead. nsCOMPtr<nsIStreamListener> listener = mListener.forget(); MOZ_ASSERT(mChannel); if (!aStream) { // The parent didn't send us back a stream. listener->OnStartRequest(mChannel, nullptr); listener->OnStopRequest(mChannel, nullptr, NS_ERROR_FILE_ACCESS_DENIED); mChannel->Cancel(NS_BINDING_ABORTED); return; } nsCOMPtr<nsIInputStreamPump> pump; - nsresult rv = NS_NewInputStreamPump(getter_AddRefs(pump), aStream); + nsresult rv = NS_NewInputStreamPump(getter_AddRefs(pump), aStream, -1, -1, 0, + 0, false, mMainThreadEventTarget); if (NS_FAILED(rv)) { mChannel->Cancel(NS_BINDING_ABORTED); return; } rv = pump->AsyncRead(listener, nullptr); if (NS_FAILED(rv)) { mChannel->Cancel(NS_BINDING_ABORTED);