| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IsolatedWorkerReportingProxy_h |
| 6 #define IsolatedWorkerReportingProxy_h |
| 7 |
| 8 #include "core/workers/WorkerReportingProxy.h" |
| 9 #include "public/platform/modules/serviceworker/service_worker.mojom-blink.h" |
| 10 #include "public/web/modules/serviceworker/WebIsolatedWorkerContextClient.h" |
| 11 #include "wtf/HashMap.h" |
| 12 |
| 13 namespace blink { |
| 14 class WebIsolatedWorkerContextClient; |
| 15 class IsolatedWorkerThread; |
| 16 class WebServiceWorkerContextClient; |
| 17 class WebServiceWorkerResponse; |
| 18 |
| 19 class IsolatedWorkerReportingProxy : public WorkerReportingProxy { |
| 20 public: |
| 21 static std::unique_ptr<IsolatedWorkerReportingProxy> create(std::unique_ptr<
WebIsolatedWorkerContextClient> workerContextClient); |
| 22 ~IsolatedWorkerReportingProxy(); |
| 23 void setVersionID(int64_t versionID); |
| 24 void setThread(IsolatedWorkerThread* thread); |
| 25 |
| 26 void reportException(const String& errorMessage, std::unique_ptr<SourceLocat
ion>, int exceptionId) override; |
| 27 void reportConsoleMessage(MessageSource, MessageLevel, const String& message
, SourceLocation*) override; |
| 28 void postMessageToPageInspector(const String&) override; |
| 29 |
| 30 // Invoked when the worker script is evaluated. |success| is true if the |
| 31 // evaluation completed with no uncaught exception. |
| 32 void didEvaluateWorkerScript(bool success) override; |
| 33 // Invoked when the thread creates a worker script context. |
| 34 void didInitializeWorkerContext() override; |
| 35 |
| 36 // Invoked when the new WorkerGlobalScope is started. |
| 37 void workerGlobalScopeStarted(WorkerOrWorkletGlobalScope* workerGlobalScope)
override; |
| 38 // Invoked when close() is invoked on the worker context. |
| 39 void workerGlobalScopeClosed() override; |
| 40 |
| 41 // Invoked when the thread is stopped and WorkerGlobalScope is being |
| 42 // destructed. (This is be the last method that is called on this |
| 43 // interface) |
| 44 void workerThreadTerminated() override; |
| 45 |
| 46 // Invoked when the thread is about to be stopped and WorkerGlobalScope |
| 47 // is to be destructed. (When this is called it is guaranteed that |
| 48 // WorkerGlobalScope is still alive) |
| 49 void willDestroyWorkerGlobalScope() override; |
| 50 |
| 51 void initializeOnWorkerThread() override; |
| 52 |
| 53 std::unique_ptr<String> takeAlternativeCode(const KURL& url) override; |
| 54 |
| 55 std::unique_ptr<WTF::Vector<char>> takeAlternativeCachedMetadata(const KURL&
url); |
| 56 |
| 57 private: |
| 58 class IsolatedWorkerClientImpl; |
| 59 class IsolatedServiceWorkerContextClient; |
| 60 |
| 61 IsolatedWorkerReportingProxy(std::unique_ptr<WebIsolatedWorkerContextClient>
workerContextClient); |
| 62 void sendWorkerStarted(); |
| 63 void OnFetchEvent(int32_t responseID, int32_t eventFinishID, const String& u
rl, bool is_navigate, const mojom::blink::IsolatedWorkerClient::OnFetchEventCall
back& callback); |
| 64 void respondToFetchEvent(int responseID); |
| 65 void respondToFetchEvent(int responseID, const WebServiceWorkerResponse& res
ponse); |
| 66 |
| 67 std::unique_ptr<WebIsolatedWorkerContextClient> m_workerContextClient; |
| 68 std::unique_ptr<IsolatedWorkerClientImpl> m_isolatedWorkerClient; |
| 69 mojom::blink::IsolatedWorkerHostServicePtr m_isolated_worker_host_service; |
| 70 std::unique_ptr<std::vector<std::unique_ptr<WebIsolatedWorkerContextClient::
WebScriptData>>> m_scriptList; |
| 71 std::unique_ptr<WebServiceWorkerContextClient> m_seriveWorkerContextClient; |
| 72 WTF::HashMap<int32_t, mojom::blink::IsolatedWorkerClient::OnFetchEventCallba
ck> m_onFetchCallbacks; |
| 73 IsolatedWorkerThread* m_thread = nullptr; |
| 74 int64_t m_versionID = 0; |
| 75 WeakPtrFactory<IsolatedWorkerReportingProxy> m_weakFactory; |
| 76 }; |
| 77 |
| 78 } // namespace blink |
| 79 |
| 80 #endif // IsolatedWorkerReportingProxy_h |
| OLD | NEW |