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

Side by Side Diff: Source/core/workers/WorkerThread.h

Issue 1175233004: WorkerThread: drop unnecessary interfaces to simplify (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: git cl format Created 5 years, 6 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 | Annotate | Revision Log
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 DontPauseWorkerGlobalScopeOnStart, 54 DontPauseWorkerGlobalScopeOnStart,
55 PauseWorkerGlobalScopeOnStart 55 PauseWorkerGlobalScopeOnStart
56 }; 56 };
57 57
58 // TODO(sadrul): Rename to WorkerScript. 58 // TODO(sadrul): Rename to WorkerScript.
59 class CORE_EXPORT WorkerThread : public RefCounted<WorkerThread> { 59 class CORE_EXPORT WorkerThread : public RefCounted<WorkerThread> {
60 public: 60 public:
61 virtual ~WorkerThread(); 61 virtual ~WorkerThread();
62 62
63 // Called on the main thread. 63 // Called on the main thread.
64 virtual void start(PassOwnPtr<WorkerThreadStartupData>); 64 void start(PassOwnPtr<WorkerThreadStartupData>);
65 virtual void stop(); 65 void terminate();
66 66
67 // Returns the thread this worker runs on. Some implementations can create 67 // Returns the thread this worker runs on. Some implementations can create
68 // a new thread on the first call (e.g. shared, dedicated workers), whereas 68 // a new thread on the first call (e.g. shared, dedicated workers), whereas
69 // some implementations can use an existing thread that is already being 69 // some implementations can use an existing thread that is already being
70 // used by other workers (e.g. compositor workers). 70 // used by other workers (e.g. compositor workers).
71 virtual WebThreadSupportingGC& backingThread() = 0; 71 virtual WebThreadSupportingGC& backingThread() = 0;
72 72
73 virtual void didStartRunLoop();
74 virtual void didStopRunLoop(); 73 virtual void didStopRunLoop();
75 74
76 v8::Isolate* isolate() const { return m_isolate; } 75 v8::Isolate* isolate() const { return m_isolate; }
77 76
78 // Can be used to wait for this worker thread to shut down. 77 // Can be used to wait for this worker thread to shut down.
79 // (This is signalled on the main thread, so it's assumed to be waited on th e worker context thread) 78 // (This is signaled on the main thread, so it's assumed to be waited on
79 // the worker context thread)
80 WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get(); } 80 WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get(); }
81 81
82 WebWaitableEvent* terminationEvent() { return m_terminationEvent.get(); } 82 // Called in shutdown sequence. Internally calls terminate() (or
83 83 // terminateInternal) and wait (by *blocking* the calling thread) until the
84 // Called in shutdown sequence. Internally calls stop() (or stopInternal) 84 // worker(s) is/are shut down.
85 // and wait (by *blocking* the calling thread) until the worker(s) is/are
86 // shut down.
87 void terminateAndWait(); 85 void terminateAndWait();
88 static void terminateAndWaitForAllWorkers(); 86 static void terminateAndWaitForAllWorkers();
89 87
90 bool isCurrentThread(); 88 bool isCurrentThread();
91 WorkerLoaderProxy* workerLoaderProxy() const 89 WorkerLoaderProxy* workerLoaderProxy() const
92 { 90 {
93 RELEASE_ASSERT(m_workerLoaderProxy); 91 RELEASE_ASSERT(m_workerLoaderProxy);
94 return m_workerLoaderProxy.get(); 92 return m_workerLoaderProxy.get();
95 } 93 }
96 94
97 WorkerReportingProxy& workerReportingProxy() const { return m_workerReportin gProxy; } 95 WorkerReportingProxy& workerReportingProxy() const { return m_workerReportin gProxy; }
98 96
99 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>); 97 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>);
100 void appendDebuggerTask(PassOwnPtr<WebThread::Task>); 98 void appendDebuggerTask(PassOwnPtr<WebThread::Task>);
101 99
102 enum WaitMode { WaitForMessage, DontWaitForMessage }; 100 enum WaitMode { WaitForMessage, DontWaitForMessage };
103 MessageQueueWaitResult runDebuggerTask(WaitMode = WaitForMessage); 101 MessageQueueWaitResult runDebuggerTask(WaitMode = WaitForMessage);
104 102
105 // These methods should be called if the holder of the thread is 103 // These methods should be called if the holder of the thread is
106 // going to call runDebuggerTask in a loop. 104 // going to call runDebuggerTask in a loop.
107 void willEnterNestedLoop(); 105 void willEnterNestedLoop();
108 void didLeaveNestedLoop(); 106 void didLeaveNestedLoop();
109 107
110 WorkerGlobalScope* workerGlobalScope() const { return m_workerGlobalScope.ge t(); } 108 WorkerGlobalScope* workerGlobalScope() const { return m_workerGlobalScope.ge t(); }
111 109
112 // Returns true once stop() (or one of the terminate* methods which 110 // Returns true once one of the terminate* methods is called.
113 // internally calls stop) is called.
114 bool terminated(); 111 bool terminated();
115 112
116 // Number of active worker threads. 113 // Number of active worker threads.
117 static unsigned workerThreadCount(); 114 static unsigned workerThreadCount();
118 115
119 PlatformThreadId platformThreadId(); 116 PlatformThreadId platformThreadId();
120 117
121 void interruptAndDispatchInspectorCommands(); 118 void interruptAndDispatchInspectorCommands();
122 void setWorkerInspectorController(WorkerInspectorController*); 119 void setWorkerInspectorController(WorkerInspectorController*);
123 120
(...skipping 10 matching lines...) Expand all
134 virtual void destroyIsolate(); 131 virtual void destroyIsolate();
135 virtual void terminateV8Execution(); 132 virtual void terminateV8Execution();
136 133
137 // This is protected virtual for testing. 134 // This is protected virtual for testing.
138 virtual bool doIdleGc(double deadlineSeconds); 135 virtual bool doIdleGc(double deadlineSeconds);
139 136
140 private: 137 private:
141 friend class WorkerMicrotaskRunner; 138 friend class WorkerMicrotaskRunner;
142 139
143 // Called on the main thread. 140 // Called on the main thread.
144 void stopInternal(); 141 virtual void didStartRunLoop();
kinuko 2015/06/11 08:42:33 nit: It's subjective but I think I'd like to keep
Takashi Toyoshima 2015/06/11 11:25:59 Sounds reasonable. If we could stop calling didSto
142 void terminateInternal();
145 143
146 // Called on the worker thread. 144 // Called on the worker thread.
147 void initialize(PassOwnPtr<WorkerThreadStartupData>); 145 void initialize(PassOwnPtr<WorkerThreadStartupData>);
148 void shutdown(); 146 void shutdown();
149 void performIdleWork(double deadlineSeconds); 147 void performIdleWork(double deadlineSeconds);
150 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTas k>, long long delayMs); 148 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTas k>, long long delayMs);
151 149
152 bool m_started; 150 bool m_started;
153 bool m_terminated; 151 bool m_terminated;
154 bool m_shutdown; 152 bool m_shutdown;
(...skipping 18 matching lines...) Expand all
173 // Used to signal thread shutdown. 171 // Used to signal thread shutdown.
174 OwnPtr<WebWaitableEvent> m_shutdownEvent; 172 OwnPtr<WebWaitableEvent> m_shutdownEvent;
175 173
176 // Used to signal thread termination. 174 // Used to signal thread termination.
177 OwnPtr<WebWaitableEvent> m_terminationEvent; 175 OwnPtr<WebWaitableEvent> m_terminationEvent;
178 }; 176 };
179 177
180 } // namespace blink 178 } // namespace blink
181 179
182 #endif // WorkerThread_h 180 #endif // WorkerThread_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698