Skip to content

Commit

Permalink
Backed out 9 changesets (bug 1744025) for causing wpt failures on Che…
Browse files Browse the repository at this point in the history
…ckedUnsafePtr.h CLOSED TREE

Backed out changeset 89dca4fc5940 (bug 1744025)
Backed out changeset 7aa395dcdbe4 (bug 1744025)
Backed out changeset 1580a4ea1a85 (bug 1744025)
Backed out changeset af171636a87f (bug 1744025)
Backed out changeset a5edfa1c9cd6 (bug 1744025)
Backed out changeset 8abd6ba69815 (bug 1744025)
Backed out changeset cfb822df5b3f (bug 1744025)
Backed out changeset 5598943a94fd (bug 1744025)
Backed out changeset 43186fbbf8b4 (bug 1744025)
  • Loading branch information
Norisz Fay committed Dec 15, 2021
1 parent 876b0c8 commit 47e4e6f
Show file tree
Hide file tree
Showing 35 changed files with 94 additions and 81 deletions.
2 changes: 1 addition & 1 deletion dom/base/ChromeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "mozilla/dom/UnionTypes.h"
#include "mozilla/dom/WindowBinding.h" // For IdleRequestCallback/Options
#include "mozilla/dom/WindowGlobalParent.h"
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/ipc/GeckoChildProcessHost.h"
#include "mozilla/net/UrlClassifierFeatureFactory.h"
#include "IOActivityMonitor.h"
Expand Down
1 change: 1 addition & 0 deletions dom/broadcastchannel/BroadcastChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/dom/RefMessageBodyService.h"
#include "mozilla/dom/SharedMessageBody.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/dom/WorkerRef.h"
#include "mozilla/dom/WorkerRunnable.h"
Expand Down
1 change: 1 addition & 0 deletions dom/clients/api/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "mozilla/dom/DOMMozPromiseRequestHolder.h"
#include "mozilla/dom/MessagePortBinding.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerScope.h"
#include "nsIDUtils.h"
#include "nsIGlobalObject.h"
Expand Down
2 changes: 1 addition & 1 deletion dom/clients/api/Clients.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ServiceWorkerDescriptor.h"
#include "mozilla/dom/ServiceWorkerManager.h"
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/SchedulerGroup.h"
#include "mozilla/StaticPrefs_privacy.h"
Expand Down
1 change: 1 addition & 0 deletions dom/clients/manager/ClientSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "mozilla/dom/MessageEvent.h"
#include "mozilla/dom/MessageEventBinding.h"
#include "mozilla/dom/Navigator.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/dom/WorkerRef.h"
#include "mozilla/dom/ServiceWorker.h"
Expand Down
1 change: 1 addition & 0 deletions dom/console/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/StructuredCloneHolder.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerRunnable.h"
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/dom/WorkletGlobalScope.h"
Expand Down
8 changes: 5 additions & 3 deletions dom/fetch/Fetch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "InternalResponse.h"

#include "mozilla/dom/WorkerCommon.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerRef.h"
#include "mozilla/dom/WorkerRunnable.h"
#include "mozilla/dom/WorkerScope.h"
Expand Down Expand Up @@ -1088,15 +1089,16 @@ nsresult ExtractByteStreamFromBody(const fetch::ResponseBodyInit& aBodyInit,
template <class Derived>
FetchBody<Derived>::FetchBody(nsIGlobalObject* aOwner)
: mOwner(aOwner),
mWorkerPrivate(nullptr),
mReadableStreamBody(nullptr),
mReadableStreamReader(nullptr),
mBodyUsed(false) {
MOZ_ASSERT(aOwner);

if (!NS_IsMainThread()) {
WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(wp);
mMainThreadEventTarget = wp->MainThreadEventTarget();
mWorkerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(mWorkerPrivate);
mMainThreadEventTarget = mWorkerPrivate->MainThreadEventTarget();
} else {
mMainThreadEventTarget = aOwner->EventTargetFor(TaskCategory::Other);
}
Expand Down
10 changes: 6 additions & 4 deletions dom/fetch/Fetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/FetchStreamReader.h"
#include "mozilla/dom/RequestBinding.h"
#include "mozilla/dom/workerinternals/RuntimeService.h"

class nsIGlobalObject;
class nsIEventTarget;
Expand Down Expand Up @@ -231,6 +230,9 @@ class FetchBody : public BodyStreamHolder, public AbortFollower {
protected:
nsCOMPtr<nsIGlobalObject> mOwner;

// Always set whenever the FetchBody is created on the worker thread.
WorkerPrivate* mWorkerPrivate;

// This is the ReadableStream exposed to content. It's underlying source is a
// BodyStream object.
JS::Heap<JSObject*> mReadableStreamBody;
Expand All @@ -252,9 +254,9 @@ class FetchBody : public BodyStreamHolder, public AbortFollower {

void LockStream(JSContext* aCx, JS::HandleObject aStream, ErrorResult& aRv);

void AssertIsOnTargetThread() {
MOZ_ASSERT(NS_IsMainThread() == !GetCurrentThreadWorkerPrivate());
}
bool IsOnTargetThread() { return NS_IsMainThread() == !mWorkerPrivate; }

void AssertIsOnTargetThread() { MOZ_ASSERT(IsOnTargetThread()); }

// Only ever set once, always on target thread.
bool mBodyUsed;
Expand Down
1 change: 1 addition & 0 deletions dom/indexedDB/IndexedDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "mozilla/dom/FileBlobImpl.h"
#include "mozilla/dom/StructuredCloneTags.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerScope.h"
#include "MainThreadUtils.h"
#include "jsapi.h"
Expand Down
1 change: 1 addition & 0 deletions dom/indexedDB/IndexedDatabaseManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "mozilla/dom/ErrorEvent.h"
#include "mozilla/dom/ErrorEventBinding.h"
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/quota/ResultExtensions.h"
#include "mozilla/intl/LocaleCanonicalizer.h"
#include "mozilla/ipc/BackgroundChild.h"
Expand Down
1 change: 1 addition & 0 deletions dom/notification/Notification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "mozilla/dom/ServiceWorkerGlobalScopeBinding.h"
#include "mozilla/dom/ServiceWorkerManager.h"
#include "mozilla/dom/ServiceWorkerUtils.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerRunnable.h"
#include "mozilla/dom/WorkerScope.h"
#include "Navigator.h"
Expand Down
4 changes: 2 additions & 2 deletions dom/notification/Notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/dom/NotificationBinding.h"
#include "mozilla/dom/WorkerPrivate.h"

#include "nsIObserver.h"
#include "nsISupports.h"
Expand All @@ -30,6 +29,7 @@ class NotificationRef;
class WorkerNotificationObserver;
class Promise;
class StrongWorkerRef;
class WorkerPrivate;

/*
* Notifications on workers introduce some lifetime issues. The property we
Expand Down Expand Up @@ -207,7 +207,7 @@ class Notification : public DOMEventTargetHelper,

// Initialized on the worker thread, never unset, and always used in
// a read-only capacity. Used on any thread.
CheckedUnsafePtr<WorkerPrivate> mWorkerPrivate;
WorkerPrivate* mWorkerPrivate;

// Main thread only.
WorkerNotificationObserver* mObserver;
Expand Down
1 change: 1 addition & 0 deletions dom/performance/PerformanceObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "mozilla/dom/PerformanceBinding.h"
#include "mozilla/dom/PerformanceEntryBinding.h"
#include "mozilla/dom/PerformanceObserverBinding.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/StaticPrefs_dom.h"
#include "nsIScriptError.h"
Expand Down
2 changes: 1 addition & 1 deletion dom/performance/PerformanceStorageWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "PerformanceTiming.h"
#include "mozilla/dom/WorkerRef.h"
#include "mozilla/dom/WorkerRunnable.h"
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/dom/WorkerPrivate.h"

namespace mozilla::dom {

Expand Down
2 changes: 1 addition & 1 deletion dom/performance/PerformanceWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "PerformanceWorker.h"
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/StaticPrefs_dom.h"

namespace mozilla::dom {
Expand Down
5 changes: 3 additions & 2 deletions dom/performance/PerformanceWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
#define mozilla_dom_PerformanceWorker_h

#include "Performance.h"
#include "mozilla/dom/WorkerPrivate.h"

namespace mozilla {
namespace dom {

class WorkerPrivate;

class PerformanceWorker final : public Performance {
public:
explicit PerformanceWorker(WorkerPrivate* aWorkerPrivate);
Expand Down Expand Up @@ -93,7 +94,7 @@ class PerformanceWorker final : public Performance {
}

private:
CheckedUnsafePtr<WorkerPrivate> mWorkerPrivate;
WorkerPrivate* mWorkerPrivate;
};

} // namespace dom
Expand Down
1 change: 1 addition & 0 deletions dom/push/PushManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "mozilla/dom/PushSubscriptionOptionsBinding.h"
#include "mozilla/dom/PushUtil.h"
#include "mozilla/dom/WorkerRunnable.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerScope.h"

#include "mozilla/dom/Promise.h"
Expand Down
1 change: 1 addition & 0 deletions dom/serviceworkers/ServiceWorkerOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "mozilla/dom/SafeRefPtr.h"
#include "mozilla/dom/ServiceWorkerBinding.h"
#include "mozilla/dom/WorkerCommon.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerRef.h"
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/ipc/IPCStreamUtils.h"
Expand Down
1 change: 1 addition & 0 deletions dom/url/URLWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "mozilla/dom/Blob.h"
#include "mozilla/dom/BlobImpl.h"
#include "mozilla/dom/BlobURLProtocolHandler.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerRunnable.h"
#include "mozilla/dom/WorkerScope.h"

Expand Down
1 change: 1 addition & 0 deletions dom/workers/MessageEventRunnable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "mozilla/TimelineConsumers.h"
#include "mozilla/WorkerTimelineMarker.h"
#include "nsQueryObject.h"
#include "WorkerPrivate.h"
#include "WorkerScope.h"

namespace mozilla {
Expand Down
5 changes: 3 additions & 2 deletions dom/workers/RuntimeService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#include "WorkerDebuggerManager.h"
#include "WorkerError.h"
#include "WorkerLoadInfo.h"
#include "WorkerPrivate.h"
#include "WorkerRunnable.h"
#include "WorkerScope.h"
#include "WorkerThread.h"
Expand Down Expand Up @@ -1184,7 +1185,7 @@ bool RuntimeService::RegisterWorker(WorkerPrivate& aWorkerPrivate) {

// From here on out we must call UnregisterWorker if something fails!
if (parent) {
if (!parent->AddChildWorker(aWorkerPrivate)) {
if (!parent->AddChildWorker(&aWorkerPrivate)) {
UnregisterWorker(aWorkerPrivate);
return false;
}
Expand Down Expand Up @@ -1304,7 +1305,7 @@ void RuntimeService::UnregisterWorker(WorkerPrivate& aWorkerPrivate) {
// same time as us calling into the code here and would race with us.

if (parent) {
parent->RemoveChildWorker(aWorkerPrivate);
parent->RemoveChildWorker(&aWorkerPrivate);
} else if (aWorkerPrivate.IsSharedWorker()) {
AssertIsOnMainThread();

Expand Down
1 change: 1 addition & 0 deletions dom/workers/ScriptLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
#include "mozilla/StaticPrefs_security.h"
#include "mozilla/UniquePtr.h"
#include "Principal.h"
#include "WorkerPrivate.h"
#include "WorkerRunnable.h"
#include "WorkerScope.h"

Expand Down
2 changes: 1 addition & 1 deletion dom/workers/WorkerCSPEventListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "WorkerCSPEventListener.h"
#include "WorkerPrivate.h"
#include "WorkerRef.h"
#include "WorkerRunnable.h"
#include "WorkerScope.h"
#include "mozilla/dom/SecurityPolicyViolationEvent.h"
#include "mozilla/dom/SecurityPolicyViolationEventBinding.h"
#include "mozilla/dom/WorkerRunnable.h"
Expand Down
12 changes: 6 additions & 6 deletions dom/workers/WorkerDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* 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 "WorkerDebugger.h"

#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/MessageEvent.h"
#include "mozilla/dom/MessageEventBinding.h"
Expand All @@ -16,9 +18,9 @@
#include "ScriptLoader.h"
#include "WorkerCommon.h"
#include "WorkerError.h"
#include "WorkerPrivate.h"
#include "WorkerRunnable.h"
#include "WorkerDebugger.h"

#include "WorkerScope.h"
#if defined(XP_WIN)
# include <processthreadsapi.h> // for GetCurrentProcessId()
#else
Expand Down Expand Up @@ -546,10 +548,8 @@ RefPtr<PerformanceInfoPromise> WorkerDebugger::ReportPerformanceInfo() {
}

// We need to keep a ref on workerPrivate, passed to the promise,
// to make sure it's still aloive when collecting the info
// (and CheckedUnsafePtr does not convert directly to RefPtr).
WorkerPrivate* workerPtr = mWorkerPrivate;
RefPtr<WorkerPrivate> workerRef = workerPtr;
// to make sure it's still aloive when collecting the info.
RefPtr<WorkerPrivate> workerRef = mWorkerPrivate;
RefPtr<AbstractThread> mainThread = AbstractThread::MainThread();

return CollectMemoryInfo(top, mainThread)
Expand Down
3 changes: 1 addition & 2 deletions dom/workers/WorkerDebugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#define mozilla_dom_workers_WorkerDebugger_h

#include "mozilla/PerformanceTypes.h"
#include "mozilla/dom/WorkerScope.h"
#include "nsCOMPtr.h"
#include "nsIWorkerDebugger.h"

Expand All @@ -25,7 +24,7 @@ class WorkerDebugger : public nsIWorkerDebugger {
class ReportDebuggerErrorRunnable;
class PostDebuggerMessageRunnable;

CheckedUnsafePtr<WorkerPrivate> mWorkerPrivate;
WorkerPrivate* mWorkerPrivate;
bool mIsInitialized;
nsTArray<nsCOMPtr<nsIWorkerDebuggerListener>> mListeners;

Expand Down
5 changes: 3 additions & 2 deletions dom/workers/WorkerEventTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@

#include "nsISerialEventTarget.h"
#include "mozilla/Mutex.h"
#include "mozilla/dom/WorkerPrivate.h"

namespace mozilla {
namespace dom {

class WorkerPrivate;

class WorkerEventTarget final : public nsISerialEventTarget {
public:
// The WorkerEventTarget supports different dispatch behaviors:
Expand All @@ -29,7 +30,7 @@ class WorkerEventTarget final : public nsISerialEventTarget {

private:
mozilla::Mutex mMutex;
CheckedUnsafePtr<WorkerPrivate> mWorkerPrivate;
WorkerPrivate* mWorkerPrivate;
const Behavior mBehavior;

~WorkerEventTarget() = default;
Expand Down
1 change: 1 addition & 0 deletions dom/workers/WorkerNavigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ErrorList.h"
#include "MainThreadUtils.h"
#include "RuntimeService.h"
#include "WorkerPrivate.h"
#include "WorkerRunnable.h"
#include "WorkerScope.h"
#include "mozilla/dom/LockManager.h"
Expand Down
Loading

0 comments on commit 47e4e6f

Please sign in to comment.