Index: third_party/WebKit/Source/core/workers/ThreadedWorkletMessagingProxy.h |
diff --git a/third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.h b/third_party/WebKit/Source/core/workers/ThreadedWorkletMessagingProxy.h |
similarity index 21% |
copy from third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.h |
copy to third_party/WebKit/Source/core/workers/ThreadedWorkletMessagingProxy.h |
index 130f134f54e28f2836483d801ae2e177a25efbfd..48ec692a7f50d2cc1da6f148e4944f8106c0dcd2 100644 |
--- a/third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.h |
+++ b/third_party/WebKit/Source/core/workers/ThreadedWorkletMessagingProxy.h |
@@ -1,139 +1,76 @@ |
-/* |
- * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
- * |
- * Redistribution and use in source and binary forms, with or without |
- * modification, are permitted provided that the following conditions |
- * are met: |
- * 1. Redistributions of source code must retain the above copyright |
- * notice, this list of conditions and the following disclaimer. |
- * 2. Redistributions in binary form must reproduce the above copyright |
- * notice, this list of conditions and the following disclaimer in the |
- * documentation and/or other materials provided with the distribution. |
- * |
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- * |
- */ |
- |
-#ifndef InProcessWorkerMessagingProxy_h |
-#define InProcessWorkerMessagingProxy_h |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef ThreadedWorkletMessagingProxy_h |
+#define ThreadedWorkletMessagingProxy_h |
#include "core/CoreExport.h" |
-#include "core/dom/ExecutionContext.h" |
-#include "core/workers/InProcessWorkerGlobalScopeProxy.h" |
+#include "core/inspector/ConsoleTypes.h" |
#include "core/workers/WorkerLoaderProxy.h" |
-#include "platform/heap/Handle.h" |
-#include "wtf/Forward.h" |
-#include "wtf/Noncopyable.h" |
-#include "wtf/PassRefPtr.h" |
-#include "wtf/RefPtr.h" |
-#include "wtf/Vector.h" |
-#include <memory> |
+#include "core/workers/WorkletGlobalScopeProxy.h" |
+#include <v8.h> |
namespace blink { |
-class ExecutionContext; |
-class InProcessWorkerBase; |
-class InProcessWorkerObjectProxy; |
-class ParentFrameTaskRunners; |
-class WorkerClients; |
+class LocalFrame; |
+class ThreadedWorkletObjectProxy; |
class WorkerInspectorProxy; |
class WorkerThread; |
-// TODO(nhiroki): "MessagingProxy" is not well-defined term among worker |
-// components. Probably we should rename this to something more suitable. |
-// (http://crbug.com/603785) |
-class CORE_EXPORT InProcessWorkerMessagingProxy |
- : public InProcessWorkerGlobalScopeProxy |
+class CORE_EXPORT ThreadedWorkletMessagingProxy |
+ : public WorkletGlobalScopeProxy |
, private WorkerLoaderProxyProvider { |
- WTF_MAKE_NONCOPYABLE(InProcessWorkerMessagingProxy); |
-public: |
- // Implementations of InProcessWorkerGlobalScopeProxy. |
- // (Only use these methods in the parent context thread.) |
- void startWorkerGlobalScope(const KURL& scriptURL, const String& userAgent, const String& sourceCode) override; |
- void terminateWorkerGlobalScope() override; |
- void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue>, std::unique_ptr<MessagePortChannelArray>) override; |
- bool hasPendingActivity() const final; |
- void workerObjectDestroyed() override; |
+ WTF_MAKE_NONCOPYABLE(ThreadedWorkletMessagingProxy); |
- // These methods come from worker context thread via |
- // InProcessWorkerObjectProxy and are called on the parent context thread. |
- void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, std::unique_ptr<MessagePortChannelArray>); |
- void dispatchErrorEvent(const String& errorMessage, std::unique_ptr<SourceLocation>, int exceptionId); |
- void reportConsoleMessage(MessageSource, MessageLevel, const String& message, std::unique_ptr<SourceLocation>); |
- void postMessageToPageInspector(const String&); |
+public: |
+ ~ThreadedWorkletMessagingProxy() override; |
- // 'virtual' for testing. |
- virtual void confirmMessageFromWorkerObject(); |
- virtual void pendingActivityFinished(); |
- virtual void workerThreadTerminated(); |
+ void initialize(); |
+ ExecutionContext* getExecutionContext() const { return m_executionContext; } |
- void workerThreadCreated(); |
+ virtual std::unique_ptr<WorkerThread> createWorkerThread() = 0; |
- ExecutionContext* getExecutionContext() const { return m_executionContext.get(); } |
+ void workletObjectDestroyed(); |
- ParentFrameTaskRunners* getParentFrameTaskRunners() { return m_parentFrameTaskRunners.get(); } |
+ // WorkletGlobalScopeProxy |
+ void evaluateScript(const ScriptSourceCode&) final; |
+ void terminateWorkletGlobalScope() final; |
- // Number of live messaging proxies, used by leak detection. |
- static int proxyCount(); |
+ // These methods come from worker context thread via |
+ // ThreadedWorkletMessagingProxy and are called on the main thread. |
+ void reportConsoleMessage(MessageSource, MessageLevel, const String& message, std::unique_ptr<SourceLocation>); |
+ void postMessageToPageInspector(const String&); |
+ void reportPendingActivity(bool hasPendingActivity); |
+ void workerThreadTerminated(); |
+ void workerThreadCreated(); |
protected: |
- InProcessWorkerMessagingProxy(InProcessWorkerBase*, WorkerClients*); |
- ~InProcessWorkerMessagingProxy() override; |
- |
- virtual std::unique_ptr<WorkerThread> createWorkerThread(double originTime) = 0; |
+ explicit ThreadedWorkletMessagingProxy(LocalFrame*); |
PassRefPtr<WorkerLoaderProxy> loaderProxy() { return m_loaderProxy; } |
- InProcessWorkerObjectProxy& workerObjectProxy() { return *m_workerObjectProxy.get(); } |
+ ThreadedWorkletObjectProxy& workerObjectProxy(); |
private: |
- friend class InProcessWorkerMessagingProxyForTest; |
- InProcessWorkerMessagingProxy(ExecutionContext*, InProcessWorkerBase*, WorkerClients*); |
- |
- void workerObjectDestroyedInternal(); |
- |
// WorkerLoaderProxyProvider |
// These methods are called on different threads to schedule loading |
// requests and to send callbacks back to WorkerGlobalScope. |
- void postTaskToLoader(const WebTraceLocation&, std::unique_ptr<ExecutionContextTask>) override; |
- void postTaskToWorkerGlobalScope(const WebTraceLocation&, std::unique_ptr<ExecutionContextTask>) override; |
+ void postTaskToLoader(const WebTraceLocation&, std::unique_ptr<ExecutionContextTask>) final; |
+ void postTaskToWorkerGlobalScope(const WebTraceLocation&, std::unique_ptr<ExecutionContextTask>) final; |
- // Returns true if this is called on the parent context thread. |
- bool isParentContextThread() const; |
+ void workerObjectDestroyedInternal(); |
Persistent<ExecutionContext> m_executionContext; |
- std::unique_ptr<InProcessWorkerObjectProxy> m_workerObjectProxy; |
- WeakPersistent<InProcessWorkerBase> m_workerObject; |
- bool m_mayBeDestroyed; |
+ std::unique_ptr<ThreadedWorkletObjectProxy> m_workletObjectProxy; |
std::unique_ptr<WorkerThread> m_workerThread; |
- |
- // Unconfirmed messages from the parent context thread to the worker thread. |
- unsigned m_unconfirmedMessageCount; |
- |
- bool m_workerGlobalScopeMayHavePendingActivity; |
- bool m_askedToTerminate; |
- |
- // Tasks are queued here until there's a thread object created. |
- Vector<std::unique_ptr<ExecutionContextTask>> m_queuedEarlyTasks; |
- |
+ RefPtr<WorkerLoaderProxy> m_loaderProxy; |
Persistent<WorkerInspectorProxy> m_workerInspectorProxy; |
- Persistent<WorkerClients> m_workerClients; |
- |
- Persistent<ParentFrameTaskRunners> m_parentFrameTaskRunners; |
- |
- RefPtr<WorkerLoaderProxy> m_loaderProxy; |
+ bool m_workerThreadHadPendingActivity; |
+ bool m_askedToTerminate; |
+ bool m_mayBeDestroyed; |
}; |
} // namespace blink |
-#endif // InProcessWorkerMessagingProxy_h |
+#endif // ThreadedWorkletMessagingProxy_h |