Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Unified Diff: third_party/WebKit/Source/core/workers/WorkerLoaderProxy.h

Issue 2709193002: WorkerLoaderProxy: stop accessing cross-thread execution context (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/workers/WorkerLoaderProxy.h
diff --git a/third_party/WebKit/Source/core/workers/WorkerLoaderProxy.h b/third_party/WebKit/Source/core/workers/WorkerLoaderProxy.h
index 770719fe2b78f6f1ea953bd73d5768a7a0f5ffa8..c2235f0231870ca8c6f6b719ee802ed97f45d0d3 100644
--- a/third_party/WebKit/Source/core/workers/WorkerLoaderProxy.h
+++ b/third_party/WebKit/Source/core/workers/WorkerLoaderProxy.h
@@ -32,13 +32,17 @@
#define WorkerLoaderProxy_h
#include "core/CoreExport.h"
-#include "core/dom/ExecutionContext.h"
#include "public/platform/WebTraceLocation.h"
#include "wtf/Forward.h"
+#include "wtf/Functional.h"
+#include "wtf/PassRefPtr.h"
#include "wtf/ThreadSafeRefCounted.h"
+#include "wtf/ThreadingPrimitives.h"
namespace blink {
+class ExecutionContext;
+
// The WorkerLoaderProxy is a proxy to the loader context. Normally, the
// document on the main thread provides loading services for the subordinate
// workers. WorkerLoaderProxy provides 2-way communications to the Document
@@ -64,13 +68,17 @@ class CORE_EXPORT WorkerLoaderProxyProvider {
// Posts a task to the thread which runs the loading code (normally, the main
// thread). This must be called from a worker thread.
virtual void postTaskToLoader(const WebTraceLocation&,
- std::unique_ptr<ExecutionContextTask>) = 0;
+ std::unique_ptr<WTF::CrossThreadClosure>) = 0;
// Posts callbacks from loading code to the WorkerGlobalScope. This must be
// called from the main thread.
virtual void postTaskToWorkerGlobalScope(
const WebTraceLocation&,
std::unique_ptr<WTF::CrossThreadClosure>) = 0;
+
+ // It is guaranteed that this gets accessed only on the thread where
+ // the ExecutionContext is bound.
+ virtual ExecutionContext* getLoaderExecutionContext() = 0;
};
class CORE_EXPORT WorkerLoaderProxy final
@@ -85,12 +93,17 @@ class CORE_EXPORT WorkerLoaderProxy final
// This must be called from a worker thread.
void postTaskToLoader(const WebTraceLocation&,
- std::unique_ptr<ExecutionContextTask>);
+ std::unique_ptr<WTF::CrossThreadClosure>);
// This must be called from the main thread.
void postTaskToWorkerGlobalScope(const WebTraceLocation&,
std::unique_ptr<WTF::CrossThreadClosure>);
+ // This may return nullptr.
+ // This must be called from the main thread (== the thread of the
+ // loader execution context).
+ ExecutionContext* getLoaderExecutionContext();
+
// Notification from the provider that it can no longer be accessed. An
// implementation of WorkerLoaderProxyProvider is required to call
// detachProvider() when finalizing. This must be called from the main thread.
@@ -99,7 +112,7 @@ class CORE_EXPORT WorkerLoaderProxy final
private:
explicit WorkerLoaderProxy(WorkerLoaderProxyProvider*);
- Mutex m_lock;
+ WTF::Mutex m_lock;
WorkerLoaderProxyProvider* m_loaderProxyProvider;
};

Powered by Google App Engine
This is Rietveld 408576698