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 22 matching lines...) Expand all Loading... |
33 #include <wtf/Noncopyable.h> | 33 #include <wtf/Noncopyable.h> |
34 #include <wtf/PassRefPtr.h> | 34 #include <wtf/PassRefPtr.h> |
35 #include <wtf/RefPtr.h> | 35 #include <wtf/RefPtr.h> |
36 #include <wtf/Vector.h> | 36 #include <wtf/Vector.h> |
37 | 37 |
38 namespace WebCore { | 38 namespace WebCore { |
39 | 39 |
40 class ScriptExecutionContext; | 40 class ScriptExecutionContext; |
41 class String; | 41 class String; |
42 class Worker; | 42 class Worker; |
43 class WorkerTask; | |
44 class WorkerThread; | 43 class WorkerThread; |
45 | 44 |
46 class WorkerMessagingProxy : Noncopyable { | 45 class WorkerMessagingProxy : Noncopyable { |
47 public: | 46 public: |
48 WorkerMessagingProxy(PassRefPtr<ScriptExecutionContext>, Worker*); | 47 WorkerMessagingProxy(PassRefPtr<ScriptExecutionContext>, Worker*); |
49 | 48 |
50 void postMessageToWorkerObject(const String& message); | 49 void postMessageToWorkerObject(const String& message); |
51 void postMessageToWorkerContext(const String& message); | 50 void postMessageToWorkerContext(const String& message); |
52 void postTaskToParentContext(PassRefPtr<ScriptExecutionContext::Task>); | 51 |
| 52 void postTaskToWorkerObject(PassRefPtr<ScriptExecutionContext::Task>); |
| 53 void postTaskToWorkerContext(PassRefPtr<ScriptExecutionContext::Task>); |
53 | 54 |
54 void postWorkerException(const String& errorMessage, int lineNumber, con
st String& sourceURL); | 55 void postWorkerException(const String& errorMessage, int lineNumber, con
st String& sourceURL); |
55 | 56 |
56 void workerThreadCreated(PassRefPtr<WorkerThread>); | 57 void workerThreadCreated(PassRefPtr<WorkerThread>); |
57 void workerObjectDestroyed(); | 58 void workerObjectDestroyed(); |
58 void workerContextDestroyed(); | 59 void workerContextDestroyed(); |
59 | 60 |
60 void terminate(); | |
61 | |
62 void confirmWorkerThreadMessage(bool hasPendingActivity); | 61 void confirmWorkerThreadMessage(bool hasPendingActivity); |
63 void reportWorkerThreadActivity(bool hasPendingActivity); | 62 void reportWorkerThreadActivity(bool hasPendingActivity); |
64 bool workerThreadHasPendingActivity() const; | 63 bool workerThreadHasPendingActivity() const; |
65 | 64 |
| 65 // Only use these methods on the worker object thread. |
| 66 void terminate(); |
| 67 bool askedToTerminate() const { return m_askedToTerminate; } |
| 68 |
66 private: | 69 private: |
67 friend class GenericWorkerTaskBase; | |
68 friend class MessageWorkerTask; | 70 friend class MessageWorkerTask; |
69 friend class WorkerContextDestroyedTask; | 71 friend class WorkerContextDestroyedTask; |
70 friend class WorkerExceptionTask; | |
71 friend class WorkerThreadActivityReportTask; | 72 friend class WorkerThreadActivityReportTask; |
72 | 73 |
73 ~WorkerMessagingProxy(); | 74 ~WorkerMessagingProxy(); |
74 | 75 |
75 void workerContextDestroyedInternal(); | 76 void workerContextDestroyedInternal(); |
76 void reportWorkerThreadActivityInternal(bool confirmingMessage, bool has
PendingActivity); | 77 void reportWorkerThreadActivityInternal(bool confirmingMessage, bool has
PendingActivity); |
77 Worker* workerObject() const { return m_workerObject; } | 78 Worker* workerObject() const { return m_workerObject; } |
78 bool askedToTerminate() { return m_askedToTerminate; } | |
79 | 79 |
80 RefPtr<ScriptExecutionContext> m_scriptExecutionContext; | 80 RefPtr<ScriptExecutionContext> m_scriptExecutionContext; |
81 Worker* m_workerObject; | 81 Worker* m_workerObject; |
82 RefPtr<WorkerThread> m_workerThread; | 82 RefPtr<WorkerThread> m_workerThread; |
83 | 83 |
84 unsigned m_unconfirmedMessageCount; // Unconfirmed messages from worker
object to worker thread. | 84 unsigned m_unconfirmedMessageCount; // Unconfirmed messages from worker
object to worker thread. |
85 bool m_workerThreadHadPendingActivity; // The latest confirmation from w
orker thread reported that it was still active. | 85 bool m_workerThreadHadPendingActivity; // The latest confirmation from w
orker thread reported that it was still active. |
86 | 86 |
87 bool m_askedToTerminate; | 87 bool m_askedToTerminate; |
88 | 88 |
89 Vector<RefPtr<WorkerTask> > m_queuedEarlyTasks; // Tasks are queued here
until there's a thread object created. | 89 Vector<RefPtr<ScriptExecutionContext::Task> > m_queuedEarlyTasks; // Tas
ks are queued here until there's a thread object created. |
90 }; | 90 }; |
91 | 91 |
92 } // namespace WebCore | 92 } // namespace WebCore |
93 | 93 |
94 #endif // ENABLE(WORKERS) | 94 #endif // ENABLE(WORKERS) |
95 | 95 |
96 #endif // WorkerMessagingProxy_h | 96 #endif // WorkerMessagingProxy_h |
97 | 97 |
98 | 98 |
OLD | NEW |