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
--- 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