OLD | NEW |
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 bool isCurrentThread() const; | 63 bool isCurrentThread() const; |
64 WorkerRunLoop& runLoop() { return m_runLoop; } | 64 WorkerRunLoop& runLoop() { return m_runLoop; } |
65 WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProx
y; } | 65 WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProx
y; } |
66 WorkerReportingProxy& workerReportingProxy() const { return m_workerRepo
rtingProxy; } | 66 WorkerReportingProxy& workerReportingProxy() const { return m_workerRepo
rtingProxy; } |
67 | 67 |
68 void postTask(PassOwnPtr<ExecutionContextTask>); | 68 void postTask(PassOwnPtr<ExecutionContextTask>); |
69 void postDebuggerTask(PassOwnPtr<ExecutionContextTask>); | 69 void postDebuggerTask(PassOwnPtr<ExecutionContextTask>); |
70 | 70 |
71 MessageQueueWaitResult runDebuggerTask(WorkerRunLoop::WaitMode = WorkerR
unLoop::WaitForMessage); | 71 MessageQueueWaitResult runDebuggerTask(WorkerRunLoop::WaitMode = WorkerR
unLoop::WaitForMessage); |
72 bool terminated() { return m_runLoop.terminated(); } | 72 bool terminated() { return m_runLoop.terminated(); } |
| 73 WorkerGlobalScope* workerGlobalScope() { return m_workerGlobalScope.get(
); } |
73 | 74 |
74 // Number of active worker threads. | 75 // Number of active worker threads. |
75 static unsigned workerThreadCount(); | 76 static unsigned workerThreadCount(); |
76 | 77 |
77 protected: | 78 protected: |
78 WorkerThread(WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtrWillBe
RawPtr<WorkerThreadStartupData>); | 79 WorkerThread(WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtrWillBe
RawPtr<WorkerThreadStartupData>); |
79 | 80 |
80 // Factory method for creating a new worker context for the thread. | 81 // Factory method for creating a new worker context for the thread. |
81 virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScop
e(PassOwnPtrWillBeRawPtr<WorkerThreadStartupData>) = 0; | 82 virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScop
e(PassOwnPtrWillBeRawPtr<WorkerThreadStartupData>) = 0; |
82 | 83 |
83 // Executes the event loop for the worker thread. Derived classes can ov
erride to perform actions before/after entering the event loop. | 84 // Executes the event loop for the worker thread. Derived classes can ov
erride to perform actions before/after entering the event loop. |
84 virtual void runEventLoop(); | 85 virtual void runEventLoop(); |
85 | 86 |
86 WorkerGlobalScope* workerGlobalScope() { return m_workerGlobalScope.get(
); } | |
87 | 87 |
88 private: | 88 private: |
89 // Static function executed as the core routine on the new thread. Passe
d a pointer to a WorkerThread object. | 89 // Static function executed as the core routine on the new thread. Passe
d a pointer to a WorkerThread object. |
90 static void workerThreadStart(void*); | 90 static void workerThreadStart(void*); |
91 | 91 |
92 void workerThread(); | 92 void workerThread(); |
93 | 93 |
94 ThreadIdentifier m_threadID; | 94 ThreadIdentifier m_threadID; |
95 WorkerRunLoop m_runLoop; | 95 WorkerRunLoop m_runLoop; |
96 WorkerLoaderProxy& m_workerLoaderProxy; | 96 WorkerLoaderProxy& m_workerLoaderProxy; |
97 WorkerReportingProxy& m_workerReportingProxy; | 97 WorkerReportingProxy& m_workerReportingProxy; |
98 | 98 |
99 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; | 99 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; |
100 Mutex m_threadCreationMutex; | 100 Mutex m_threadCreationMutex; |
101 | 101 |
102 OwnPtrWillBePersistent<WorkerThreadStartupData> m_startupData; | 102 OwnPtrWillBePersistent<WorkerThreadStartupData> m_startupData; |
103 | 103 |
104 // Used to signal thread shutdown. | 104 // Used to signal thread shutdown. |
105 OwnPtr<blink::WebWaitableEvent> m_shutdownEvent; | 105 OwnPtr<blink::WebWaitableEvent> m_shutdownEvent; |
106 }; | 106 }; |
107 | 107 |
108 } // namespace blink | 108 } // namespace blink |
109 | 109 |
110 #endif // WorkerThread_h | 110 #endif // WorkerThread_h |
OLD | NEW |