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 29 matching lines...) Expand all Loading... |
40 } | 40 } |
41 | 41 |
42 namespace WebCore { | 42 namespace WebCore { |
43 | 43 |
44 class KURL; | 44 class KURL; |
45 class NotificationClient; | 45 class NotificationClient; |
46 class WorkerGlobalScope; | 46 class WorkerGlobalScope; |
47 class WorkerLoaderProxy; | 47 class WorkerLoaderProxy; |
48 class WorkerReportingProxy; | 48 class WorkerReportingProxy; |
49 class WorkerThreadStartupData; | 49 class WorkerThreadStartupData; |
| 50 class WorkerDebuggerAgent; |
50 | 51 |
51 enum WorkerThreadStartMode { DontPauseWorkerGlobalScopeOnStart, PauseWorkerG
lobalScopeOnStart }; | 52 enum WorkerThreadStartMode { DontPauseWorkerGlobalScopeOnStart, PauseWorkerG
lobalScopeOnStart }; |
52 | 53 |
53 class WorkerThread : public RefCounted<WorkerThread> { | 54 class WorkerThread : public RefCounted<WorkerThread> { |
54 public: | 55 public: |
55 virtual ~WorkerThread(); | 56 virtual ~WorkerThread(); |
56 | 57 |
57 bool start(); | 58 bool start(); |
58 void stop(); | 59 void stop(); |
59 | 60 |
60 // Can be used to wait for this worker thread to shut down. | 61 // Can be used to wait for this worker thread to shut down. |
61 // (This is signalled on the main thread, so it's assumed to be waited o
n the worker context thread) | 62 // (This is signalled on the main thread, so it's assumed to be waited o
n the worker context thread) |
62 blink::WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get();
} | 63 blink::WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get();
} |
63 | 64 |
64 bool isCurrentThread() const; | 65 bool isCurrentThread() const; |
65 WorkerRunLoop& runLoop() { return m_runLoop; } | 66 WorkerRunLoop& runLoop() { return m_runLoop; } |
66 WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProx
y; } | 67 WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProx
y; } |
67 WorkerReportingProxy& workerReportingProxy() const { return m_workerRepo
rtingProxy; } | 68 WorkerReportingProxy& workerReportingProxy() const { return m_workerRepo
rtingProxy; } |
68 | 69 |
69 // Number of active worker threads. | 70 // Number of active worker threads. |
70 static unsigned workerThreadCount(); | 71 static unsigned workerThreadCount(); |
71 | 72 |
72 NotificationClient* getNotificationClient() { return m_notificationClien
t; } | 73 NotificationClient* getNotificationClient() { return m_notificationClien
t; } |
73 void setNotificationClient(NotificationClient* client) { m_notificationC
lient = client; } | 74 void setNotificationClient(NotificationClient* client) { m_notificationC
lient = client; } |
74 | 75 |
| 76 WorkerGlobalScope* workerGlobalScope() { return m_workerGlobalScope.get(
); } |
| 77 |
| 78 void interruptAndDispatchInspectorCommands(); |
| 79 |
75 protected: | 80 protected: |
76 WorkerThread(WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtrWillBe
RawPtr<WorkerThreadStartupData>); | 81 WorkerThread(WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtrWillBe
RawPtr<WorkerThreadStartupData>); |
77 | 82 |
78 // Factory method for creating a new worker context for the thread. | 83 // Factory method for creating a new worker context for the thread. |
79 virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScop
e(PassOwnPtrWillBeRawPtr<WorkerThreadStartupData>) = 0; | 84 virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScop
e(PassOwnPtrWillBeRawPtr<WorkerThreadStartupData>) = 0; |
80 | 85 |
81 // Executes the event loop for the worker thread. Derived classes can ov
erride to perform actions before/after entering the event loop. | 86 // Executes the event loop for the worker thread. Derived classes can ov
erride to perform actions before/after entering the event loop. |
82 virtual void runEventLoop(); | 87 virtual void runEventLoop(); |
83 | 88 |
84 WorkerGlobalScope* workerGlobalScope() { return m_workerGlobalScope.get(
); } | |
85 | |
86 private: | 89 private: |
87 // Static function executed as the core routine on the new thread. Passe
d a pointer to a WorkerThread object. | 90 // Static function executed as the core routine on the new thread. Passe
d a pointer to a WorkerThread object. |
88 static void workerThreadStart(void*); | 91 static void workerThreadStart(void*); |
89 | 92 |
90 void workerThread(); | 93 void workerThread(); |
91 | 94 |
92 ThreadIdentifier m_threadID; | 95 ThreadIdentifier m_threadID; |
93 WorkerRunLoop m_runLoop; | 96 WorkerRunLoop m_runLoop; |
94 WorkerLoaderProxy& m_workerLoaderProxy; | 97 WorkerLoaderProxy& m_workerLoaderProxy; |
95 WorkerReportingProxy& m_workerReportingProxy; | 98 WorkerReportingProxy& m_workerReportingProxy; |
96 | 99 |
97 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; | 100 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; |
98 Mutex m_threadCreationMutex; | 101 Mutex m_threadCreationMutex; |
99 | 102 |
100 OwnPtrWillBePersistent<WorkerThreadStartupData> m_startupData; | 103 OwnPtrWillBePersistent<WorkerThreadStartupData> m_startupData; |
101 | 104 |
102 NotificationClient* m_notificationClient; | 105 NotificationClient* m_notificationClient; |
103 | 106 |
104 // Used to signal thread shutdown. | 107 // Used to signal thread shutdown. |
105 OwnPtr<blink::WebWaitableEvent> m_shutdownEvent; | 108 OwnPtr<blink::WebWaitableEvent> m_shutdownEvent; |
| 109 OwnPtrWillBePersistent<WorkerDebuggerAgent> m_workerDebuggerAgent; |
106 }; | 110 }; |
107 | 111 |
108 } // namespace WebCore | 112 } // namespace WebCore |
109 | 113 |
110 #endif // WorkerThread_h | 114 #endif // WorkerThread_h |
OLD | NEW |