| 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" | |
| 34 #include "core/events/ErrorEvent.h" | 33 #include "core/events/ErrorEvent.h" |
| 35 #include "core/events/MessageEvent.h" | 34 #include "core/events/MessageEvent.h" |
| 36 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
| 37 #include "core/frame/csp/ContentSecurityPolicy.h" | 36 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 38 #include "core/loader/DocumentLoadTiming.h" | 37 #include "core/loader/DocumentLoadTiming.h" |
| 39 #include "core/loader/DocumentLoader.h" | 38 #include "core/loader/DocumentLoader.h" |
| 40 #include "core/origin_trials/OriginTrialContext.h" | 39 #include "core/origin_trials/OriginTrialContext.h" |
| 41 #include "core/workers/InProcessWorkerBase.h" | 40 #include "core/workers/InProcessWorkerBase.h" |
| 42 #include "core/workers/InProcessWorkerObjectProxy.h" | 41 #include "core/workers/InProcessWorkerObjectProxy.h" |
| 43 #include "core/workers/WorkerClients.h" | 42 #include "core/workers/WorkerClients.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 141 |
| 143 if (GetWorkerThread()) { | 142 if (GetWorkerThread()) { |
| 144 // A message event is an activity and may initiate another activity. | 143 // A message event is an activity and may initiate another activity. |
| 145 worker_global_scope_has_pending_activity_ = true; | 144 worker_global_scope_has_pending_activity_ = true; |
| 146 ++unconfirmed_message_count_; | 145 ++unconfirmed_message_count_; |
| 147 std::unique_ptr<WTF::CrossThreadClosure> task = CrossThreadBind( | 146 std::unique_ptr<WTF::CrossThreadClosure> task = CrossThreadBind( |
| 148 &InProcessWorkerObjectProxy::ProcessMessageFromWorkerObject, | 147 &InProcessWorkerObjectProxy::ProcessMessageFromWorkerObject, |
| 149 CrossThreadUnretained(&WorkerObjectProxy()), std::move(message), | 148 CrossThreadUnretained(&WorkerObjectProxy()), std::move(message), |
| 150 WTF::Passed(std::move(channels)), | 149 WTF::Passed(std::move(channels)), |
| 151 CrossThreadUnretained(GetWorkerThread())); | 150 CrossThreadUnretained(GetWorkerThread())); |
| 152 TaskRunnerHelper::Get(TaskType::kPostedMessage, GetWorkerThread()) | 151 GetWorkerThread()->PostTask(BLINK_FROM_HERE, std::move(task)); |
| 153 ->PostTask(BLINK_FROM_HERE, std::move(task)); | |
| 154 } else { | 152 } else { |
| 155 queued_early_tasks_.push_back( | 153 queued_early_tasks_.push_back( |
| 156 QueuedTask{std::move(message), std::move(channels)}); | 154 QueuedTask{std::move(message), std::move(channels)}); |
| 157 } | 155 } |
| 158 } | 156 } |
| 159 | 157 |
| 160 void InProcessWorkerMessagingProxy::DispatchErrorEvent( | 158 void InProcessWorkerMessagingProxy::DispatchErrorEvent( |
| 161 const String& error_message, | 159 const String& error_message, |
| 162 std::unique_ptr<SourceLocation> location, | 160 std::unique_ptr<SourceLocation> location, |
| 163 int exception_id) { | 161 int exception_id) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 192 | 190 |
| 193 DCHECK_EQ(0u, unconfirmed_message_count_); | 191 DCHECK_EQ(0u, unconfirmed_message_count_); |
| 194 unconfirmed_message_count_ = queued_early_tasks_.size(); | 192 unconfirmed_message_count_ = queued_early_tasks_.size(); |
| 195 for (auto& queued_task : queued_early_tasks_) { | 193 for (auto& queued_task : queued_early_tasks_) { |
| 196 std::unique_ptr<WTF::CrossThreadClosure> task = CrossThreadBind( | 194 std::unique_ptr<WTF::CrossThreadClosure> task = CrossThreadBind( |
| 197 &InProcessWorkerObjectProxy::ProcessMessageFromWorkerObject, | 195 &InProcessWorkerObjectProxy::ProcessMessageFromWorkerObject, |
| 198 CrossThreadUnretained(&WorkerObjectProxy()), | 196 CrossThreadUnretained(&WorkerObjectProxy()), |
| 199 queued_task.message.Release(), | 197 queued_task.message.Release(), |
| 200 WTF::Passed(std::move(queued_task.channels)), | 198 WTF::Passed(std::move(queued_task.channels)), |
| 201 CrossThreadUnretained(GetWorkerThread())); | 199 CrossThreadUnretained(GetWorkerThread())); |
| 202 TaskRunnerHelper::Get(TaskType::kPostedMessage, GetWorkerThread()) | 200 GetWorkerThread()->PostTask(BLINK_FROM_HERE, std::move(task)); |
| 203 ->PostTask(BLINK_FROM_HERE, std::move(task)); | |
| 204 } | 201 } |
| 205 queued_early_tasks_.Clear(); | 202 queued_early_tasks_.Clear(); |
| 206 } | 203 } |
| 207 | 204 |
| 208 void InProcessWorkerMessagingProxy::ParentObjectDestroyed() { | 205 void InProcessWorkerMessagingProxy::ParentObjectDestroyed() { |
| 209 DCHECK(IsParentContextThread()); | 206 DCHECK(IsParentContextThread()); |
| 210 | 207 |
| 211 // parentObjectDestroyed() is called in InProcessWorkerBase's destructor. | 208 // parentObjectDestroyed() is called in InProcessWorkerBase's destructor. |
| 212 // Thus it should be guaranteed that a weak pointer m_workerObject has been | 209 // Thus it should be guaranteed that a weak pointer m_workerObject has been |
| 213 // cleared before this method gets called. | 210 // cleared before this method gets called. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 237 } | 234 } |
| 238 | 235 |
| 239 bool InProcessWorkerMessagingProxy::HasPendingActivity() const { | 236 bool InProcessWorkerMessagingProxy::HasPendingActivity() const { |
| 240 DCHECK(IsParentContextThread()); | 237 DCHECK(IsParentContextThread()); |
| 241 if (AskedToTerminate()) | 238 if (AskedToTerminate()) |
| 242 return false; | 239 return false; |
| 243 return worker_global_scope_has_pending_activity_; | 240 return worker_global_scope_has_pending_activity_; |
| 244 } | 241 } |
| 245 | 242 |
| 246 } // namespace blink | 243 } // namespace blink |
| OLD | NEW |