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

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

Issue 1140503003: workers: Change how debugger-tasks are posted to the thread. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 years, 7 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 namespace blink { 44 namespace blink {
45 45
46 class WebWaitableEvent; 46 class WebWaitableEvent;
47 class WorkerGlobalScope; 47 class WorkerGlobalScope;
48 class WorkerInspectorController; 48 class WorkerInspectorController;
49 class WorkerMicrotaskRunner; 49 class WorkerMicrotaskRunner;
50 class WorkerReportingProxy; 50 class WorkerReportingProxy;
51 class WorkerSharedTimer; 51 class WorkerSharedTimer;
52 class WorkerThreadStartupData; 52 class WorkerThreadStartupData;
53 class WorkerThreadTask;
54 53
55 enum WorkerThreadStartMode { 54 enum WorkerThreadStartMode {
56 DontPauseWorkerGlobalScopeOnStart, 55 DontPauseWorkerGlobalScopeOnStart,
57 PauseWorkerGlobalScopeOnStart 56 PauseWorkerGlobalScopeOnStart
58 }; 57 };
59 58
60 // TODO(sadrul): Rename to WorkerScript. 59 // TODO(sadrul): Rename to WorkerScript.
61 class CORE_EXPORT WorkerThread : public RefCounted<WorkerThread> { 60 class CORE_EXPORT WorkerThread : public RefCounted<WorkerThread> {
62 public: 61 public:
63 virtual ~WorkerThread(); 62 virtual ~WorkerThread();
(...skipping 23 matching lines...) Expand all
87 bool isCurrentThread(); 86 bool isCurrentThread();
88 WorkerLoaderProxy* workerLoaderProxy() const 87 WorkerLoaderProxy* workerLoaderProxy() const
89 { 88 {
90 RELEASE_ASSERT(m_workerLoaderProxy); 89 RELEASE_ASSERT(m_workerLoaderProxy);
91 return m_workerLoaderProxy.get(); 90 return m_workerLoaderProxy.get();
92 } 91 }
93 92
94 WorkerReportingProxy& workerReportingProxy() const { return m_workerReportin gProxy; } 93 WorkerReportingProxy& workerReportingProxy() const { return m_workerReportin gProxy; }
95 94
96 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>); 95 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>);
97 void postDebuggerTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTa sk>); 96 void appendDebuggerTask(PassOwnPtr<WebThread::Task>);
98 97
99 enum WaitMode { WaitForMessage, DontWaitForMessage }; 98 enum WaitMode { WaitForMessage, DontWaitForMessage };
100 MessageQueueWaitResult runDebuggerTask(WaitMode = WaitForMessage); 99 MessageQueueWaitResult runDebuggerTask(WaitMode = WaitForMessage);
101 100
102 // These methods should be called if the holder of the thread is 101 // These methods should be called if the holder of the thread is
103 // going to call runDebuggerTask in a loop. 102 // going to call runDebuggerTask in a loop.
104 void willEnterNestedLoop(); 103 void willEnterNestedLoop();
105 void didLeaveNestedLoop(); 104 void didLeaveNestedLoop();
106 105
107 WorkerGlobalScope* workerGlobalScope() const { return m_workerGlobalScope.ge t(); } 106 WorkerGlobalScope* workerGlobalScope() const { return m_workerGlobalScope.ge t(); }
(...skipping 26 matching lines...) Expand all
134 private: 133 private:
135 friend class WorkerSharedTimer; 134 friend class WorkerSharedTimer;
136 friend class WorkerMicrotaskRunner; 135 friend class WorkerMicrotaskRunner;
137 136
138 void stopInShutdownSequence(); 137 void stopInShutdownSequence();
139 void stopInternal(); 138 void stopInternal();
140 139
141 void initialize(PassOwnPtr<WorkerThreadStartupData>); 140 void initialize(PassOwnPtr<WorkerThreadStartupData>);
142 void shutdown(); 141 void shutdown();
143 void performIdleWork(double deadlineSeconds); 142 void performIdleWork(double deadlineSeconds);
144 void postDelayedTask(PassOwnPtr<ExecutionContextTask>, long long delayMs);
145 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTas k>, long long delayMs); 143 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTas k>, long long delayMs);
146 144
147 bool m_started; 145 bool m_started;
148 bool m_terminated; 146 bool m_terminated;
149 MessageQueue<WorkerThreadTask> m_debuggerMessageQueue; 147 MessageQueue<WebThread::Task> m_debuggerMessageQueue;
150 OwnPtr<WebThread::TaskObserver> m_microtaskRunner; 148 OwnPtr<WebThread::TaskObserver> m_microtaskRunner;
151 149
152 RefPtr<WorkerLoaderProxy> m_workerLoaderProxy; 150 RefPtr<WorkerLoaderProxy> m_workerLoaderProxy;
153 WorkerReportingProxy& m_workerReportingProxy; 151 WorkerReportingProxy& m_workerReportingProxy;
154 RawPtr<WebScheduler> m_webScheduler; // Not owned. 152 RawPtr<WebScheduler> m_webScheduler; // Not owned.
155 153
156 RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorControlle r; 154 RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorControlle r;
157 Mutex m_workerInspectorControllerMutex; 155 Mutex m_workerInspectorControllerMutex;
158 156
159 // This lock protects |m_workerGlobalScope|, |m_terminated|, |m_isolate| and |m_microtaskRunner|. 157 // This lock protects |m_workerGlobalScope|, |m_terminated|, |m_isolate| and |m_microtaskRunner|.
160 Mutex m_threadStateMutex; 158 Mutex m_threadStateMutex;
161 159
162 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; 160 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope;
163 161
164 v8::Isolate* m_isolate; 162 v8::Isolate* m_isolate;
165 OwnPtr<V8IsolateInterruptor> m_interruptor; 163 OwnPtr<V8IsolateInterruptor> m_interruptor;
166 164
167 // Used to signal thread shutdown. 165 // Used to signal thread shutdown.
168 OwnPtr<WebWaitableEvent> m_shutdownEvent; 166 OwnPtr<WebWaitableEvent> m_shutdownEvent;
169 167
170 // Used to signal thread termination. 168 // Used to signal thread termination.
171 OwnPtr<WebWaitableEvent> m_terminationEvent; 169 OwnPtr<WebWaitableEvent> m_terminationEvent;
172 }; 170 };
173 171
174 } // namespace blink 172 } // namespace blink
175 173
176 #endif // WorkerThread_h 174 #endif // WorkerThread_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698