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