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

Side by Side Diff: third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.h

Issue 1897193002: Worker: Rename worker components to clarify what they work for (part 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 13 matching lines...) Expand all
24 * 24 *
25 */ 25 */
26 26
27 #ifndef InProcessWorkerMessagingProxy_h 27 #ifndef InProcessWorkerMessagingProxy_h
28 #define InProcessWorkerMessagingProxy_h 28 #define InProcessWorkerMessagingProxy_h
29 29
30 #include "core/CoreExport.h" 30 #include "core/CoreExport.h"
31 #include "core/dom/ExecutionContext.h" 31 #include "core/dom/ExecutionContext.h"
32 #include "core/workers/InProcessWorkerGlobalScopeProxy.h" 32 #include "core/workers/InProcessWorkerGlobalScopeProxy.h"
33 #include "core/workers/WorkerLoaderProxy.h" 33 #include "core/workers/WorkerLoaderProxy.h"
34 #include "platform/heap/Handle.h"
34 #include "wtf/Forward.h" 35 #include "wtf/Forward.h"
35 #include "wtf/Noncopyable.h" 36 #include "wtf/Noncopyable.h"
36 #include "wtf/PassOwnPtr.h" 37 #include "wtf/PassOwnPtr.h"
37 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
38 #include "wtf/RefPtr.h" 39 #include "wtf/RefPtr.h"
39 #include "wtf/Vector.h" 40 #include "wtf/Vector.h"
40 41
41 namespace blink { 42 namespace blink {
42 43
43 class WorkerObjectProxy; 44 class InProcessWorkerObjectProxy;
44 class WorkerThread; 45 class WorkerThread;
45 class ExecutionContext; 46 class ExecutionContext;
46 class InProcessWorkerBase; 47 class InProcessWorkerBase;
47 class WorkerClients; 48 class WorkerClients;
48 class WorkerInspectorProxy; 49 class WorkerInspectorProxy;
49 50
50 // TODO(nhiroki): "MessagingProxy" is not well-defined term among worker 51 // TODO(nhiroki): "MessagingProxy" is not well-defined term among worker
51 // components. Probably we should rename this to something more suitable. 52 // components. Probably we should rename this to something more suitable.
52 // (http://crbug.com/603785) 53 // (http://crbug.com/603785)
53 class CORE_EXPORT InProcessWorkerMessagingProxy 54 class CORE_EXPORT InProcessWorkerMessagingProxy
54 : public InProcessWorkerGlobalScopeProxy 55 : public InProcessWorkerGlobalScopeProxy
55 , private WorkerLoaderProxyProvider { 56 , private WorkerLoaderProxyProvider {
56 WTF_MAKE_NONCOPYABLE(InProcessWorkerMessagingProxy); 57 WTF_MAKE_NONCOPYABLE(InProcessWorkerMessagingProxy);
57 public: 58 public:
58 // Implementations of InProcessWorkerGlobalScopeProxy. 59 // Implementations of InProcessWorkerGlobalScopeProxy.
59 // (Only use these methods in the worker object thread.) 60 // (Only use these methods in the worker object thread.)
60 void startWorkerGlobalScope(const KURL& scriptURL, const String& userAgent, const String& sourceCode) override; 61 void startWorkerGlobalScope(const KURL& scriptURL, const String& userAgent, const String& sourceCode) override;
61 void terminateWorkerGlobalScope() override; 62 void terminateWorkerGlobalScope() override;
62 void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue>, PassO wnPtr<MessagePortChannelArray>) override; 63 void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue>, PassO wnPtr<MessagePortChannelArray>) override;
63 bool hasPendingActivity() const final; 64 bool hasPendingActivity() const final;
64 void workerObjectDestroyed() override; 65 void workerObjectDestroyed() override;
65 66
66 // These methods come from worker context thread via WorkerObjectProxy 67 // These methods come from worker context thread via
67 // and are called on the worker object thread (e.g. main thread). 68 // InProcessWorkerObjectProxy and are called on the worker object thread
69 // (e.g. main thread).
68 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr <MessagePortChannelArray>); 70 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr <MessagePortChannelArray>);
69 void reportException(const String& errorMessage, int lineNumber, int columnN umber, const String& sourceURL, int exceptionId); 71 void reportException(const String& errorMessage, int lineNumber, int columnN umber, const String& sourceURL, int exceptionId);
70 void reportConsoleMessage(MessageSource, MessageLevel, const String& message , int lineNumber, const String& sourceURL); 72 void reportConsoleMessage(MessageSource, MessageLevel, const String& message , int lineNumber, const String& sourceURL);
71 void postMessageToPageInspector(const String&); 73 void postMessageToPageInspector(const String&);
72 void postWorkerConsoleAgentEnabled(); 74 void postWorkerConsoleAgentEnabled();
73 void confirmMessageFromWorkerObject(bool hasPendingActivity); 75 void confirmMessageFromWorkerObject(bool hasPendingActivity);
74 void reportPendingActivity(bool hasPendingActivity); 76 void reportPendingActivity(bool hasPendingActivity);
75 void workerGlobalScopeClosed(); 77 void workerGlobalScopeClosed();
76 void workerThreadTerminated(); 78 void workerThreadTerminated();
77 void workerThreadCreated(); 79 void workerThreadCreated();
78 80
79 ExecutionContext* getExecutionContext() const { return m_executionContext.ge t(); } 81 ExecutionContext* getExecutionContext() const { return m_executionContext.ge t(); }
80 82
81 protected: 83 protected:
82 InProcessWorkerMessagingProxy(InProcessWorkerBase*, WorkerClients*); 84 InProcessWorkerMessagingProxy(InProcessWorkerBase*, WorkerClients*);
83 ~InProcessWorkerMessagingProxy() override; 85 ~InProcessWorkerMessagingProxy() override;
84 86
85 virtual PassOwnPtr<WorkerThread> createWorkerThread(double originTime) = 0; 87 virtual PassOwnPtr<WorkerThread> createWorkerThread(double originTime) = 0;
86 88
87 PassRefPtr<WorkerLoaderProxy> loaderProxy() { return m_loaderProxy; } 89 PassRefPtr<WorkerLoaderProxy> loaderProxy() { return m_loaderProxy; }
88 WorkerObjectProxy& workerObjectProxy() { return *m_workerObjectProxy.get(); } 90 InProcessWorkerObjectProxy& workerObjectProxy() { return *m_workerObjectProx y.get(); }
89 91
90 private: 92 private:
91 void workerObjectDestroyedInternal(); 93 void workerObjectDestroyedInternal();
92 void terminateInternally(); 94 void terminateInternally();
93 95
94 // WorkerLoaderProxyProvider 96 // WorkerLoaderProxyProvider
95 // These methods are called on different threads to schedule loading 97 // These methods are called on different threads to schedule loading
96 // requests and to send callbacks back to WorkerGlobalScope. 98 // requests and to send callbacks back to WorkerGlobalScope.
97 void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) override; 99 void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) override;
98 bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) override; 100 bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) override;
99 101
100 Persistent<ExecutionContext> m_executionContext; 102 Persistent<ExecutionContext> m_executionContext;
101 OwnPtr<WorkerObjectProxy> m_workerObjectProxy; 103 OwnPtr<InProcessWorkerObjectProxy> m_workerObjectProxy;
102 WeakPersistent<InProcessWorkerBase> m_workerObject; 104 WeakPersistent<InProcessWorkerBase> m_workerObject;
103 bool m_mayBeDestroyed; 105 bool m_mayBeDestroyed;
104 OwnPtr<WorkerThread> m_workerThread; 106 OwnPtr<WorkerThread> m_workerThread;
105 107
106 unsigned m_unconfirmedMessageCount; // Unconfirmed messages from worker obje ct to worker thread. 108 unsigned m_unconfirmedMessageCount; // Unconfirmed messages from worker obje ct to worker thread.
107 bool m_workerThreadHadPendingActivity; // The latest confirmation from worke r thread reported that it was still active. 109 bool m_workerThreadHadPendingActivity; // The latest confirmation from worke r thread reported that it was still active.
108 110
109 bool m_askedToTerminate; 111 bool m_askedToTerminate;
110 112
111 Vector<OwnPtr<ExecutionContextTask>> m_queuedEarlyTasks; // Tasks are queued here until there's a thread object created. 113 Vector<OwnPtr<ExecutionContextTask>> m_queuedEarlyTasks; // Tasks are queued here until there's a thread object created.
112 Persistent<WorkerInspectorProxy> m_workerInspectorProxy; 114 Persistent<WorkerInspectorProxy> m_workerInspectorProxy;
113 115
114 Persistent<WorkerClients> m_workerClients; 116 Persistent<WorkerClients> m_workerClients;
115 117
116 RefPtr<WorkerLoaderProxy> m_loaderProxy; 118 RefPtr<WorkerLoaderProxy> m_loaderProxy;
117 }; 119 };
118 120
119 } // namespace blink 121 } // namespace blink
120 122
121 #endif // InProcessWorkerMessagingProxy_h 123 #endif // InProcessWorkerMessagingProxy_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698