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

Unified Diff: third_party/WebKit/Source/modules/serviceworkers/IsolatedWorkerReportingProxy.h

Issue 2118243002: [proof-of-concept] SW thread independent of the main thread Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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/modules/serviceworkers/IsolatedWorkerReportingProxy.h
diff --git a/third_party/WebKit/Source/modules/serviceworkers/IsolatedWorkerReportingProxy.h b/third_party/WebKit/Source/modules/serviceworkers/IsolatedWorkerReportingProxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..f81bc1913822a6a0f7b3f9de30e7732335a5d9c9
--- /dev/null
+++ b/third_party/WebKit/Source/modules/serviceworkers/IsolatedWorkerReportingProxy.h
@@ -0,0 +1,80 @@
+// 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 IsolatedWorkerReportingProxy_h
+#define IsolatedWorkerReportingProxy_h
+
+#include "core/workers/WorkerReportingProxy.h"
+#include "public/platform/modules/serviceworker/service_worker.mojom-blink.h"
+#include "public/web/modules/serviceworker/WebIsolatedWorkerContextClient.h"
+#include "wtf/HashMap.h"
+
+namespace blink {
+class WebIsolatedWorkerContextClient;
+class IsolatedWorkerThread;
+class WebServiceWorkerContextClient;
+class WebServiceWorkerResponse;
+
+class IsolatedWorkerReportingProxy : public WorkerReportingProxy {
+public:
+ static std::unique_ptr<IsolatedWorkerReportingProxy> create(std::unique_ptr<WebIsolatedWorkerContextClient> workerContextClient);
+ ~IsolatedWorkerReportingProxy();
+ void setVersionID(int64_t versionID);
+ void setThread(IsolatedWorkerThread* thread);
+
+ void reportException(const String& errorMessage, std::unique_ptr<SourceLocation>, int exceptionId) override;
+ void reportConsoleMessage(MessageSource, MessageLevel, const String& message, SourceLocation*) override;
+ void postMessageToPageInspector(const String&) override;
+
+ // Invoked when the worker script is evaluated. |success| is true if the
+ // evaluation completed with no uncaught exception.
+ void didEvaluateWorkerScript(bool success) override;
+ // Invoked when the thread creates a worker script context.
+ void didInitializeWorkerContext() override;
+
+ // Invoked when the new WorkerGlobalScope is started.
+ void workerGlobalScopeStarted(WorkerOrWorkletGlobalScope* workerGlobalScope) override;
+ // Invoked when close() is invoked on the worker context.
+ void workerGlobalScopeClosed() override;
+
+ // Invoked when the thread is stopped and WorkerGlobalScope is being
+ // destructed. (This is be the last method that is called on this
+ // interface)
+ void workerThreadTerminated() override;
+
+ // Invoked when the thread is about to be stopped and WorkerGlobalScope
+ // is to be destructed. (When this is called it is guaranteed that
+ // WorkerGlobalScope is still alive)
+ void willDestroyWorkerGlobalScope() override;
+
+ void initializeOnWorkerThread() override;
+
+ std::unique_ptr<String> takeAlternativeCode(const KURL& url) override;
+
+ std::unique_ptr<WTF::Vector<char>> takeAlternativeCachedMetadata(const KURL& url);
+
+private:
+ class IsolatedWorkerClientImpl;
+ class IsolatedServiceWorkerContextClient;
+
+ IsolatedWorkerReportingProxy(std::unique_ptr<WebIsolatedWorkerContextClient> workerContextClient);
+ void sendWorkerStarted();
+ void OnFetchEvent(int32_t responseID, int32_t eventFinishID, const String& url, bool is_navigate, const mojom::blink::IsolatedWorkerClient::OnFetchEventCallback& callback);
+ void respondToFetchEvent(int responseID);
+ void respondToFetchEvent(int responseID, const WebServiceWorkerResponse& response);
+
+ std::unique_ptr<WebIsolatedWorkerContextClient> m_workerContextClient;
+ std::unique_ptr<IsolatedWorkerClientImpl> m_isolatedWorkerClient;
+ mojom::blink::IsolatedWorkerHostServicePtr m_isolated_worker_host_service;
+ std::unique_ptr<std::vector<std::unique_ptr<WebIsolatedWorkerContextClient::WebScriptData>>> m_scriptList;
+ std::unique_ptr<WebServiceWorkerContextClient> m_seriveWorkerContextClient;
+ WTF::HashMap<int32_t, mojom::blink::IsolatedWorkerClient::OnFetchEventCallback> m_onFetchCallbacks;
+ IsolatedWorkerThread* m_thread = nullptr;
+ int64_t m_versionID = 0;
+ WeakPtrFactory<IsolatedWorkerReportingProxy> m_weakFactory;
+};
+
+} // namespace blink
+
+#endif // IsolatedWorkerReportingProxy_h

Powered by Google App Engine
This is Rietveld 408576698