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

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

Issue 642013002: Unindent some class declarations in workers/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « Source/core/workers/WorkerScriptLoaderClient.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 22 matching lines...) Expand all
33 #include "platform/SharedTimer.h" 33 #include "platform/SharedTimer.h"
34 #include "platform/WebThreadSupportingGC.h" 34 #include "platform/WebThreadSupportingGC.h"
35 #include "platform/weborigin/SecurityOrigin.h" 35 #include "platform/weborigin/SecurityOrigin.h"
36 #include "wtf/Forward.h" 36 #include "wtf/Forward.h"
37 #include "wtf/MessageQueue.h" 37 #include "wtf/MessageQueue.h"
38 #include "wtf/OwnPtr.h" 38 #include "wtf/OwnPtr.h"
39 #include "wtf/PassRefPtr.h" 39 #include "wtf/PassRefPtr.h"
40 #include "wtf/RefCounted.h" 40 #include "wtf/RefCounted.h"
41 41
42 namespace blink { 42 namespace blink {
43
44 class KURL;
43 class WebWaitableEvent; 45 class WebWaitableEvent;
44 } 46 class WorkerGlobalScope;
47 class WorkerInspectorController;
48 class WorkerLoaderProxy;
49 class WorkerReportingProxy;
50 class WorkerSharedTimer;
51 class WorkerThreadShutdownFinishTask;
52 class WorkerThreadStartupData;
53 class WorkerThreadTask;
45 54
46 namespace blink { 55 enum WorkerThreadStartMode {
56 DontPauseWorkerGlobalScopeOnStart,
57 PauseWorkerGlobalScopeOnStart
58 };
47 59
48 class KURL; 60 class WorkerThread : public RefCounted<WorkerThread> {
49 class WorkerGlobalScope; 61 public:
50 class WorkerInspectorController; 62 virtual ~WorkerThread();
51 class WorkerLoaderProxy;
52 class WorkerReportingProxy;
53 class WorkerSharedTimer;
54 class WorkerThreadShutdownFinishTask;
55 class WorkerThreadStartupData;
56 class WorkerThreadTask;
57 63
58 enum WorkerThreadStartMode { DontPauseWorkerGlobalScopeOnStart, PauseWorkerG lobalScopeOnStart }; 64 virtual void start();
65 virtual void stop();
59 66
67 // Can be used to wait for this worker thread to shut down.
68 // (This is signalled on the main thread, so it's assumed to be waited on th e worker context thread)
69 WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get(); }
60 70
61 class WorkerThread : public RefCounted<WorkerThread> { 71 WebWaitableEvent* terminationEvent() { return m_terminationEvent.get(); }
62 public: 72 static void terminateAndWaitForAllWorkers();
63 virtual ~WorkerThread();
64 73
65 virtual void start(); 74 bool isCurrentThread() const;
66 virtual void stop(); 75 WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProxy; }
76 WorkerReportingProxy& workerReportingProxy() const { return m_workerReportin gProxy; }
67 77
68 // Can be used to wait for this worker thread to shut down. 78 void postTask(PassOwnPtr<ExecutionContextTask>);
69 // (This is signalled on the main thread, so it's assumed to be waited o n the worker context thread) 79 void postDebuggerTask(PassOwnPtr<ExecutionContextTask>);
70 blink::WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get(); }
71 80
72 blink::WebWaitableEvent* terminationEvent() { return m_terminationEvent. get(); } 81 enum WaitMode { WaitForMessage, DontWaitForMessage };
73 static void terminateAndWaitForAllWorkers(); 82 MessageQueueWaitResult runDebuggerTask(WaitMode = WaitForMessage);
74 83
75 bool isCurrentThread() const; 84 // These methods should be called if the holder of the thread is
76 WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProx y; } 85 // going to call runDebuggerTask in a loop.
77 WorkerReportingProxy& workerReportingProxy() const { return m_workerRepo rtingProxy; } 86 void willEnterNestedLoop();
87 void didLeaveNestedLoop();
78 88
79 void postTask(PassOwnPtr<ExecutionContextTask>); 89 WorkerGlobalScope* workerGlobalScope() const { return m_workerGlobalScope.ge t(); }
80 void postDebuggerTask(PassOwnPtr<ExecutionContextTask>); 90 bool terminated();
81 91
82 enum WaitMode { WaitForMessage, DontWaitForMessage }; 92 // Number of active worker threads.
83 MessageQueueWaitResult runDebuggerTask(WaitMode = WaitForMessage); 93 static unsigned workerThreadCount();
84 94
85 // These methods should be called if the holder of the thread is 95 PlatformThreadId platformThreadId() const;
86 // going to call runDebuggerTask in a loop.
87 void willEnterNestedLoop();
88 void didLeaveNestedLoop();
89 96
90 WorkerGlobalScope* workerGlobalScope() const { return m_workerGlobalScop e.get(); } 97 void interruptAndDispatchInspectorCommands();
91 bool terminated(); 98 void setWorkerInspectorController(WorkerInspectorController*);
92 99
93 // Number of active worker threads. 100 protected:
94 static unsigned workerThreadCount(); 101 WorkerThread(WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtrWillBeRawP tr<WorkerThreadStartupData>);
95 102
96 PlatformThreadId platformThreadId() const; 103 // Factory method for creating a new worker context for the thread.
104 virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScope(Pa ssOwnPtrWillBeRawPtr<WorkerThreadStartupData>) = 0;
97 105
98 void interruptAndDispatchInspectorCommands(); 106 virtual void postInitialize() { }
99 void setWorkerInspectorController(WorkerInspectorController*);
100 107
101 protected: 108 private:
102 WorkerThread(WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtrWillBe RawPtr<WorkerThreadStartupData>); 109 friend class WorkerSharedTimer;
110 friend class WorkerThreadShutdownFinishTask;
103 111
104 // Factory method for creating a new worker context for the thread. 112 void stopInShutdownSequence();
105 virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScop e(PassOwnPtrWillBeRawPtr<WorkerThreadStartupData>) = 0; 113 void stopInternal();
106 114
107 virtual void postInitialize() { } 115 void initialize();
116 void cleanup();
117 void idleHandler();
118 void postDelayedTask(PassOwnPtr<ExecutionContextTask>, long long delayMs);
108 119
109 private: 120 bool m_terminated;
110 friend class WorkerSharedTimer; 121 OwnPtr<WorkerSharedTimer> m_sharedTimer;
111 friend class WorkerThreadShutdownFinishTask; 122 MessageQueue<WorkerThreadTask> m_debuggerMessageQueue;
123 OwnPtr<WebThread::TaskObserver> m_microtaskRunner;
112 124
113 void stopInShutdownSequence(); 125 WorkerLoaderProxy& m_workerLoaderProxy;
114 void stopInternal(); 126 WorkerReportingProxy& m_workerReportingProxy;
115 127
116 void initialize(); 128 RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorControlle r;
117 void cleanup(); 129 Mutex m_workerInspectorControllerMutex;
118 void idleHandler();
119 void postDelayedTask(PassOwnPtr<ExecutionContextTask>, long long delayMs );
120 130
121 bool m_terminated; 131 Mutex m_threadCreationMutex;
122 OwnPtr<WorkerSharedTimer> m_sharedTimer; 132 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope;
123 MessageQueue<WorkerThreadTask> m_debuggerMessageQueue; 133 OwnPtrWillBePersistent<WorkerThreadStartupData> m_startupData;
124 OwnPtr<WebThread::TaskObserver> m_microtaskRunner;
125 134
126 WorkerLoaderProxy& m_workerLoaderProxy; 135 // Used to signal thread shutdown.
127 WorkerReportingProxy& m_workerReportingProxy; 136 OwnPtr<WebWaitableEvent> m_shutdownEvent;
128 137
129 RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorContr oller; 138 // Used to signal thread termination.
130 Mutex m_workerInspectorControllerMutex; 139 OwnPtr<WebWaitableEvent> m_terminationEvent;
131 140
132 Mutex m_threadCreationMutex; 141 // FIXME: This has to be last because of crbug.com/401397 - the
133 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; 142 // WorkerThread might get deleted before it had a chance to properly
134 OwnPtrWillBePersistent<WorkerThreadStartupData> m_startupData; 143 // shut down. By deleting the WebThread first, we can guarantee that
135 144 // no pending tasks on the thread might want to access any of the other
136 // Used to signal thread shutdown. 145 // members during the WorkerThread's destruction.
137 OwnPtr<blink::WebWaitableEvent> m_shutdownEvent; 146 OwnPtr<WebThreadSupportingGC> m_thread;
138 147 };
139 // Used to signal thread termination.
140 OwnPtr<blink::WebWaitableEvent> m_terminationEvent;
141
142 // FIXME: This has to be last because of crbug.com/401397 - the
143 // WorkerThread might get deleted before it had a chance to properly
144 // shut down. By deleting the WebThread first, we can guarantee that
145 // no pending tasks on the thread might want to access any of the other
146 // members during the WorkerThread's destruction.
147 OwnPtr<WebThreadSupportingGC> m_thread;
148 };
149 148
150 } // namespace blink 149 } // namespace blink
151 150
152 #endif // WorkerThread_h 151 #endif // WorkerThread_h
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerScriptLoaderClient.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698