Bug 1384294 - replace GetMainThreadEventTarget with GetNeckoTarget in HttpChannelChild. r?mayhemer draft
authorShih-Chiang Chien <schien@mozilla.com>
Wed, 26 Jul 2017 15:55:18 +0800
changeset 615727 d3712d8bd29c473cd8facd9681be5bb4b84ed3e2
parent 614808 dcfb58fcb6dd8f6474eed6520ba6272dedded393
child 639251 c5eb75d1302bde61772bdc1897bda72da2aa2415
push id70443
push userbmo:schien@mozilla.com
push dateWed, 26 Jul 2017 08:42:14 +0000
reviewersmayhemer
bugs1384294
milestone56.0a1
Bug 1384294 - replace GetMainThreadEventTarget with GetNeckoTarget in HttpChannelChild. r?mayhemer GetMainThreadEventTarget doesn't label runnable with correct doc group or tab group. In HttpChannelChild we should replace it with |GetNeckoTarget| in general. By making mIsTrackingResource atomic, HttpChannelChild::ProcessNotifyTrackingResource can be further changed to do direct function call without dispatching additional runnable on main thread. MozReview-Commit-ID: LVvoiljHElX
netwerk/protocol/http/HttpBaseChannel.h
netwerk/protocol/http/HttpChannelChild.cpp
--- a/netwerk/protocol/http/HttpBaseChannel.h
+++ b/netwerk/protocol/http/HttpBaseChannel.h
@@ -627,17 +627,17 @@ protected:
 
   // Holds the name of the preferred alt-data type.
   nsCString mPreferredCachedAltDataType;
   // Holds the name of the alternative data type the channel returned.
   nsCString mAvailableCachedAltDataType;
   int64_t   mAltDataLength;
 
   bool mForceMainDocumentChannel;
-  bool mIsTrackingResource;
+  Atomic<bool, ReleaseAcquire> mIsTrackingResource;
 
   uint64_t mChannelId;
 
   // If this channel was created as the result of a redirect, then this value
   // will reflect the redirect flags passed to the SetupReplacementChannel()
   // method.
   uint32_t mLastRedirectFlags;
 
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -1764,38 +1764,33 @@ HttpChannelChild::ProcessFlushedForDiver
 
 void
 HttpChannelChild::ProcessNotifyTrackingProtectionDisabled()
 {
   LOG(("HttpChannelChild::ProcessNotifyTrackingProtectionDisabled [this=%p]\n", this));
   MOZ_ASSERT(OnSocketThread());
 
   RefPtr<HttpChannelChild> self = this;
-  nsCOMPtr<nsIEventTarget> mainTarget = GetMainThreadEventTarget();
-  mainTarget->Dispatch(
+  nsCOMPtr<nsIEventTarget> neckoTarget = GetNeckoTarget();
+  neckoTarget->Dispatch(
     NS_NewRunnableFunction(
       "nsChannelClassifier::NotifyTrackingProtectionDisabled",
       [self]() {
         nsChannelClassifier::NotifyTrackingProtectionDisabled(self);
       }),
     NS_DISPATCH_NORMAL);
 }
 
 void
 HttpChannelChild::ProcessNotifyTrackingResource()
 {
   LOG(("HttpChannelChild::ProcessNotifyTrackingResource [this=%p]\n", this));
   MOZ_ASSERT(OnSocketThread());
 
-  nsCOMPtr<nsIEventTarget> mainTarget = GetMainThreadEventTarget();
-  mainTarget->Dispatch(
-    NewRunnableMethod(
-      "HttpChannelChild::SetIsTrackingResource",
-      this, &HttpChannelChild::SetIsTrackingResource),
-    NS_DISPATCH_NORMAL);
+  SetIsTrackingResource();
 }
 
 void
 HttpChannelChild::FlushedForDiversion()
 {
   LOG(("HttpChannelChild::FlushedForDiversion [this=%p]\n", this));
   MOZ_RELEASE_ASSERT(mDivertingToParent);
 
@@ -1810,18 +1805,18 @@ HttpChannelChild::FlushedForDiversion()
 void
 HttpChannelChild::ProcessSetClassifierMatchedInfo(const nsCString& aList,
                                                   const nsCString& aProvider,
                                                   const nsCString& aPrefix)
 {
   LOG(("HttpChannelChild::ProcessSetClassifierMatchedInfo [this=%p]\n", this));
   MOZ_ASSERT(OnSocketThread());
 
-  nsCOMPtr<nsIEventTarget> mainTarget = GetMainThreadEventTarget();
-  mainTarget->Dispatch(
+  nsCOMPtr<nsIEventTarget> neckoTarget = GetNeckoTarget();
+  neckoTarget->Dispatch(
     NewRunnableMethod<const nsCString, const nsCString, const nsCString>
       ("HttpChannelChild::SetMatchedInfo",
        this, &HttpChannelChild::SetMatchedInfo,
        aList, aProvider, aPrefix),
     NS_DISPATCH_NORMAL);
 }
 
 void