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

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

Issue 857193004: [NOT READY FOR REVIEW YET]workers: Some refactoring to allow creating new kind of worker threads Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 years, 11 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
« no previous file with comments | « Source/core/workers/WorkerGlobalScope.cpp ('k') | Source/core/workers/WorkerThread.cpp » ('j') | 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 21 matching lines...) Expand all
32 #include "core/workers/WorkerGlobalScope.h" 32 #include "core/workers/WorkerGlobalScope.h"
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 v8 {
43 class Isolate;
44 }
45
42 namespace blink { 46 namespace blink {
43 47
44 class WebWaitableEvent; 48 class WebWaitableEvent;
45 class WorkerGlobalScope; 49 class WorkerGlobalScope;
46 class WorkerInspectorController; 50 class WorkerInspectorController;
47 class WorkerLoaderProxy; 51 class WorkerLoaderProxy;
48 class WorkerReportingProxy; 52 class WorkerReportingProxy;
49 class WorkerSharedTimer; 53 class WorkerSharedTimer;
50 class WorkerThreadShutdownFinishTask; 54 class WorkerThreadShutdownFinishTask;
51 class WorkerThreadStartupData; 55 class WorkerThreadStartupData;
52 class WorkerThreadTask; 56 class WorkerThreadTask;
53 57
54 enum WorkerThreadStartMode { 58 enum WorkerThreadStartMode {
55 DontPauseWorkerGlobalScopeOnStart, 59 DontPauseWorkerGlobalScopeOnStart,
56 PauseWorkerGlobalScopeOnStart 60 PauseWorkerGlobalScopeOnStart
57 }; 61 };
58 62
59 class WorkerThread : public RefCounted<WorkerThread> { 63 class WorkerThread : public RefCounted<WorkerThread> {
60 public: 64 public:
61 virtual ~WorkerThread(); 65 virtual ~WorkerThread();
62 66
63 virtual void start(); 67 virtual void start();
64 virtual void stop(); 68 virtual void stop();
65 69
70 virtual v8::Isolate* initializeIsolate();
71 virtual PassOwnPtr<WebThreadSupportingGC> createWebThreadSupportingGC();
72
66 // Can be used to wait for this worker thread to shut down. 73 // Can be used to wait for this worker thread to shut down.
67 // (This is signalled on the main thread, so it's assumed to be waited on th e worker context thread) 74 // (This is signalled on the main thread, so it's assumed to be waited on th e worker context thread)
68 WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get(); } 75 WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get(); }
69 76
70 WebWaitableEvent* terminationEvent() { return m_terminationEvent.get(); } 77 WebWaitableEvent* terminationEvent() { return m_terminationEvent.get(); }
71 void terminateAndWait(); 78 void terminateAndWait();
72 static void terminateAndWaitForAllWorkers(); 79 static void terminateAndWaitForAllWorkers();
73 80
74 bool isCurrentThread() const; 81 bool isCurrentThread() const;
75 WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProxy; } 82 WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProxy; }
(...skipping 10 matching lines...) Expand all
86 void willEnterNestedLoop(); 93 void willEnterNestedLoop();
87 void didLeaveNestedLoop(); 94 void didLeaveNestedLoop();
88 95
89 WorkerGlobalScope* workerGlobalScope() const { return m_workerGlobalScope.ge t(); } 96 WorkerGlobalScope* workerGlobalScope() const { return m_workerGlobalScope.ge t(); }
90 bool terminated(); 97 bool terminated();
91 98
92 // Number of active worker threads. 99 // Number of active worker threads.
93 static unsigned workerThreadCount(); 100 static unsigned workerThreadCount();
94 101
95 PlatformThreadId platformThreadId() const; 102 PlatformThreadId platformThreadId() const;
103 v8::Isolate* isolate() const;
96 104
97 void interruptAndDispatchInspectorCommands(); 105 void interruptAndDispatchInspectorCommands();
98 void setWorkerInspectorController(WorkerInspectorController*); 106 void setWorkerInspectorController(WorkerInspectorController*);
99 107
100 protected: 108 protected:
101 WorkerThread(WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtrWillBeRawP tr<WorkerThreadStartupData>); 109 WorkerThread(WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtrWillBeRawP tr<WorkerThreadStartupData>);
102 110
103 // Factory method for creating a new worker context for the thread. 111 // Factory method for creating a new worker context for the thread.
104 virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScope(Pa ssOwnPtrWillBeRawPtr<WorkerThreadStartupData>) = 0; 112 virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScope(Pa ssOwnPtrWillBeRawPtr<WorkerThreadStartupData>) = 0;
105 113
(...skipping 25 matching lines...) Expand all
131 Mutex m_threadCreationMutex; 139 Mutex m_threadCreationMutex;
132 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; 140 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope;
133 OwnPtrWillBePersistent<WorkerThreadStartupData> m_startupData; 141 OwnPtrWillBePersistent<WorkerThreadStartupData> m_startupData;
134 142
135 // Used to signal thread shutdown. 143 // Used to signal thread shutdown.
136 OwnPtr<WebWaitableEvent> m_shutdownEvent; 144 OwnPtr<WebWaitableEvent> m_shutdownEvent;
137 145
138 // Used to signal thread termination. 146 // Used to signal thread termination.
139 OwnPtr<WebWaitableEvent> m_terminationEvent; 147 OwnPtr<WebWaitableEvent> m_terminationEvent;
140 148
149 v8::Isolate* m_isolate;
150
141 // FIXME: This has to be last because of crbug.com/401397 - the 151 // FIXME: This has to be last because of crbug.com/401397 - the
142 // WorkerThread might get deleted before it had a chance to properly 152 // WorkerThread might get deleted before it had a chance to properly
143 // shut down. By deleting the WebThread first, we can guarantee that 153 // shut down. By deleting the WebThread first, we can guarantee that
144 // no pending tasks on the thread might want to access any of the other 154 // no pending tasks on the thread might want to access any of the other
145 // members during the WorkerThread's destruction. 155 // members during the WorkerThread's destruction.
146 OwnPtr<WebThreadSupportingGC> m_thread; 156 OwnPtr<WebThreadSupportingGC> m_thread;
147 }; 157 };
148 158
149 } // namespace blink 159 } // namespace blink
150 160
151 #endif // WorkerThread_h 161 #endif // WorkerThread_h
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerGlobalScope.cpp ('k') | Source/core/workers/WorkerThread.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698