OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2009 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 12 matching lines...) Expand all Loading... |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 * | 25 * |
26 */ | 26 */ |
27 | 27 |
28 #include "core/workers/InProcessWorkerMessagingProxy.h" | 28 #include "core/workers/InProcessWorkerMessagingProxy.h" |
29 | 29 |
30 #include <memory> | 30 #include <memory> |
31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
32 #include "core/dom/SecurityContext.h" | 32 #include "core/dom/SecurityContext.h" |
| 33 #include "core/dom/TaskRunnerHelper.h" |
33 #include "core/events/ErrorEvent.h" | 34 #include "core/events/ErrorEvent.h" |
34 #include "core/events/MessageEvent.h" | 35 #include "core/events/MessageEvent.h" |
35 #include "core/frame/LocalFrame.h" | 36 #include "core/frame/LocalFrame.h" |
36 #include "core/frame/csp/ContentSecurityPolicy.h" | 37 #include "core/frame/csp/ContentSecurityPolicy.h" |
37 #include "core/loader/DocumentLoadTiming.h" | 38 #include "core/loader/DocumentLoadTiming.h" |
38 #include "core/loader/DocumentLoader.h" | 39 #include "core/loader/DocumentLoader.h" |
39 #include "core/origin_trials/OriginTrialContext.h" | 40 #include "core/origin_trials/OriginTrialContext.h" |
40 #include "core/workers/InProcessWorkerBase.h" | 41 #include "core/workers/InProcessWorkerBase.h" |
41 #include "core/workers/InProcessWorkerObjectProxy.h" | 42 #include "core/workers/InProcessWorkerObjectProxy.h" |
42 #include "core/workers/WorkerClients.h" | 43 #include "core/workers/WorkerClients.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 142 |
142 if (GetWorkerThread()) { | 143 if (GetWorkerThread()) { |
143 // A message event is an activity and may initiate another activity. | 144 // A message event is an activity and may initiate another activity. |
144 worker_global_scope_has_pending_activity_ = true; | 145 worker_global_scope_has_pending_activity_ = true; |
145 ++unconfirmed_message_count_; | 146 ++unconfirmed_message_count_; |
146 std::unique_ptr<WTF::CrossThreadClosure> task = CrossThreadBind( | 147 std::unique_ptr<WTF::CrossThreadClosure> task = CrossThreadBind( |
147 &InProcessWorkerObjectProxy::ProcessMessageFromWorkerObject, | 148 &InProcessWorkerObjectProxy::ProcessMessageFromWorkerObject, |
148 CrossThreadUnretained(&WorkerObjectProxy()), std::move(message), | 149 CrossThreadUnretained(&WorkerObjectProxy()), std::move(message), |
149 WTF::Passed(std::move(channels)), | 150 WTF::Passed(std::move(channels)), |
150 CrossThreadUnretained(GetWorkerThread())); | 151 CrossThreadUnretained(GetWorkerThread())); |
151 GetWorkerThread()->PostTask(BLINK_FROM_HERE, std::move(task)); | 152 TaskRunnerHelper::Get(TaskType::kPostedMessage, GetWorkerThread()) |
| 153 ->PostTask(BLINK_FROM_HERE, std::move(task)); |
152 } else { | 154 } else { |
153 queued_early_tasks_.push_back( | 155 queued_early_tasks_.push_back( |
154 QueuedTask{std::move(message), std::move(channels)}); | 156 QueuedTask{std::move(message), std::move(channels)}); |
155 } | 157 } |
156 } | 158 } |
157 | 159 |
158 void InProcessWorkerMessagingProxy::DispatchErrorEvent( | 160 void InProcessWorkerMessagingProxy::DispatchErrorEvent( |
159 const String& error_message, | 161 const String& error_message, |
160 std::unique_ptr<SourceLocation> location, | 162 std::unique_ptr<SourceLocation> location, |
161 int exception_id) { | 163 int exception_id) { |
(...skipping 28 matching lines...) Expand all Loading... |
190 | 192 |
191 DCHECK_EQ(0u, unconfirmed_message_count_); | 193 DCHECK_EQ(0u, unconfirmed_message_count_); |
192 unconfirmed_message_count_ = queued_early_tasks_.size(); | 194 unconfirmed_message_count_ = queued_early_tasks_.size(); |
193 for (auto& queued_task : queued_early_tasks_) { | 195 for (auto& queued_task : queued_early_tasks_) { |
194 std::unique_ptr<WTF::CrossThreadClosure> task = CrossThreadBind( | 196 std::unique_ptr<WTF::CrossThreadClosure> task = CrossThreadBind( |
195 &InProcessWorkerObjectProxy::ProcessMessageFromWorkerObject, | 197 &InProcessWorkerObjectProxy::ProcessMessageFromWorkerObject, |
196 CrossThreadUnretained(&WorkerObjectProxy()), | 198 CrossThreadUnretained(&WorkerObjectProxy()), |
197 queued_task.message.Release(), | 199 queued_task.message.Release(), |
198 WTF::Passed(std::move(queued_task.channels)), | 200 WTF::Passed(std::move(queued_task.channels)), |
199 CrossThreadUnretained(GetWorkerThread())); | 201 CrossThreadUnretained(GetWorkerThread())); |
200 GetWorkerThread()->PostTask(BLINK_FROM_HERE, std::move(task)); | 202 TaskRunnerHelper::Get(TaskType::kPostedMessage, GetWorkerThread()) |
| 203 ->PostTask(BLINK_FROM_HERE, std::move(task)); |
201 } | 204 } |
202 queued_early_tasks_.Clear(); | 205 queued_early_tasks_.Clear(); |
203 } | 206 } |
204 | 207 |
205 void InProcessWorkerMessagingProxy::ParentObjectDestroyed() { | 208 void InProcessWorkerMessagingProxy::ParentObjectDestroyed() { |
206 DCHECK(IsParentContextThread()); | 209 DCHECK(IsParentContextThread()); |
207 | 210 |
208 // parentObjectDestroyed() is called in InProcessWorkerBase's destructor. | 211 // parentObjectDestroyed() is called in InProcessWorkerBase's destructor. |
209 // Thus it should be guaranteed that a weak pointer m_workerObject has been | 212 // Thus it should be guaranteed that a weak pointer m_workerObject has been |
210 // cleared before this method gets called. | 213 // cleared before this method gets called. |
(...skipping 23 matching lines...) Expand all Loading... |
234 } | 237 } |
235 | 238 |
236 bool InProcessWorkerMessagingProxy::HasPendingActivity() const { | 239 bool InProcessWorkerMessagingProxy::HasPendingActivity() const { |
237 DCHECK(IsParentContextThread()); | 240 DCHECK(IsParentContextThread()); |
238 if (AskedToTerminate()) | 241 if (AskedToTerminate()) |
239 return false; | 242 return false; |
240 return worker_global_scope_has_pending_activity_; | 243 return worker_global_scope_has_pending_activity_; |
241 } | 244 } |
242 | 245 |
243 } // namespace blink | 246 } // namespace blink |
OLD | NEW |