Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.cpp

Issue 2811993007: Worker: Remove cross-thread PostTask functions from WorkerLoaderProxy (Closed)
Patch Set: address review comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // exceptions should *always* be reported even if the thread is terminated. 169 // exceptions should *always* be reported even if the thread is terminated.
170 // This is intentionally different than the behavior in MessageWorkerTask, 170 // This is intentionally different than the behavior in MessageWorkerTask,
171 // because terminated workers no longer deliver messages (section 4.6 of the 171 // because terminated workers no longer deliver messages (section 4.6 of the
172 // WebWorker spec), but they do report exceptions. 172 // WebWorker spec), but they do report exceptions.
173 173
174 ErrorEvent* event = 174 ErrorEvent* event =
175 ErrorEvent::Create(error_message, location->Clone(), nullptr); 175 ErrorEvent::Create(error_message, location->Clone(), nullptr);
176 if (worker_object_->DispatchEvent(event) != DispatchEventResult::kNotCanceled) 176 if (worker_object_->DispatchEvent(event) != DispatchEventResult::kNotCanceled)
177 return; 177 return;
178 178
179 PostTaskToWorkerGlobalScope( 179 // The HTML spec requires to queue an error event using the DOM manipulation
180 BLINK_FROM_HERE, 180 // task source.
181 CrossThreadBind(&InProcessWorkerObjectProxy::ProcessUnhandledException, 181 // https://html.spec.whatwg.org/multipage/workers.html#runtime-script-errors-2
182 CrossThreadUnretained(worker_object_proxy_.get()), 182 TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetWorkerThread())
183 exception_id, CrossThreadUnretained(GetWorkerThread()))); 183 ->PostTask(BLINK_FROM_HERE,
184 CrossThreadBind(
185 &InProcessWorkerObjectProxy::ProcessUnhandledException,
186 CrossThreadUnretained(worker_object_proxy_.get()),
187 exception_id, CrossThreadUnretained(GetWorkerThread())));
184 } 188 }
185 189
186 void InProcessWorkerMessagingProxy::WorkerThreadCreated() { 190 void InProcessWorkerMessagingProxy::WorkerThreadCreated() {
187 DCHECK(IsParentContextThread()); 191 DCHECK(IsParentContextThread());
188 ThreadedMessagingProxyBase::WorkerThreadCreated(); 192 ThreadedMessagingProxyBase::WorkerThreadCreated();
189 193
190 // Worker initialization means a pending activity. 194 // Worker initialization means a pending activity.
191 worker_global_scope_has_pending_activity_ = true; 195 worker_global_scope_has_pending_activity_ = true;
192 196
193 DCHECK_EQ(0u, unconfirmed_message_count_); 197 DCHECK_EQ(0u, unconfirmed_message_count_);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 241 }
238 242
239 bool InProcessWorkerMessagingProxy::HasPendingActivity() const { 243 bool InProcessWorkerMessagingProxy::HasPendingActivity() const {
240 DCHECK(IsParentContextThread()); 244 DCHECK(IsParentContextThread());
241 if (AskedToTerminate()) 245 if (AskedToTerminate())
242 return false; 246 return false;
243 return worker_global_scope_has_pending_activity_; 247 return worker_global_scope_has_pending_activity_;
244 } 248 }
245 249
246 } // namespace blink 250 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698