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

Side by Side Diff: third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp

Issue 2831843002: Revert of Worker: Introduce per-global-scope task scheduler (Closed)
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "web/WebSharedWorkerImpl.h" 31 #include "web/WebSharedWorkerImpl.h"
32 32
33 #include <memory> 33 #include <memory>
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/dom/TaskRunnerHelper.h"
36 #include "core/events/MessageEvent.h" 35 #include "core/events/MessageEvent.h"
37 #include "core/inspector/ConsoleMessage.h" 36 #include "core/inspector/ConsoleMessage.h"
38 #include "core/loader/FrameLoadRequest.h" 37 #include "core/loader/FrameLoadRequest.h"
39 #include "core/loader/FrameLoader.h" 38 #include "core/loader/FrameLoader.h"
40 #include "core/loader/ThreadableLoadingContext.h" 39 #include "core/loader/ThreadableLoadingContext.h"
41 #include "core/probe/CoreProbes.h" 40 #include "core/probe/CoreProbes.h"
42 #include "core/workers/ParentFrameTaskRunners.h" 41 #include "core/workers/ParentFrameTaskRunners.h"
43 #include "core/workers/SharedWorkerGlobalScope.h" 42 #include "core/workers/SharedWorkerGlobalScope.h"
44 #include "core/workers/SharedWorkerThread.h" 43 #include "core/workers/SharedWorkerThread.h"
45 #include "core/workers/WorkerClients.h" 44 #include "core/workers/WorkerClients.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 std::unique_ptr<WTF::CrossThreadClosure> task) { 247 std::unique_ptr<WTF::CrossThreadClosure> task) {
249 DCHECK(worker_thread_->IsCurrentThread()); 248 DCHECK(worker_thread_->IsCurrentThread());
250 parent_frame_task_runners_->Get(TaskType::kNetworking) 249 parent_frame_task_runners_->Get(TaskType::kNetworking)
251 ->PostTask(FROM_HERE, std::move(task)); 250 ->PostTask(FROM_HERE, std::move(task));
252 } 251 }
253 252
254 void WebSharedWorkerImpl::PostTaskToWorkerGlobalScope( 253 void WebSharedWorkerImpl::PostTaskToWorkerGlobalScope(
255 const WebTraceLocation& location, 254 const WebTraceLocation& location,
256 std::unique_ptr<WTF::CrossThreadClosure> task) { 255 std::unique_ptr<WTF::CrossThreadClosure> task) {
257 DCHECK(IsMainThread()); 256 DCHECK(IsMainThread());
258 TaskRunnerHelper::Get(TaskType::kNetworking, GetWorkerThread()) 257 worker_thread_->PostTask(location, std::move(task));
259 ->PostTask(location, std::move(task));
260 } 258 }
261 259
262 ThreadableLoadingContext* WebSharedWorkerImpl::GetThreadableLoadingContext() { 260 ThreadableLoadingContext* WebSharedWorkerImpl::GetThreadableLoadingContext() {
263 if (!loading_context_) { 261 if (!loading_context_) {
264 loading_context_ = 262 loading_context_ =
265 ThreadableLoadingContext::Create(*ToDocument(loading_document_.Get())); 263 ThreadableLoadingContext::Create(*ToDocument(loading_document_.Get()));
266 } 264 }
267 return loading_context_; 265 return loading_context_;
268 } 266 }
269 267
270 void WebSharedWorkerImpl::Connect( 268 void WebSharedWorkerImpl::Connect(
271 std::unique_ptr<WebMessagePortChannel> web_channel) { 269 std::unique_ptr<WebMessagePortChannel> web_channel) {
272 DCHECK(IsMainThread()); 270 DCHECK(IsMainThread());
273 TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetWorkerThread()) 271 GetWorkerThread()->PostTask(
274 ->PostTask( 272 BLINK_FROM_HERE,
275 BLINK_FROM_HERE, 273 CrossThreadBind(&WebSharedWorkerImpl::ConnectTaskOnWorkerThread,
276 CrossThreadBind(&WebSharedWorkerImpl::ConnectTaskOnWorkerThread, 274 WTF::CrossThreadUnretained(this),
277 WTF::CrossThreadUnretained(this), 275 WTF::Passed(std::move(web_channel))));
278 WTF::Passed(std::move(web_channel))));
279 } 276 }
280 277
281 void WebSharedWorkerImpl::ConnectTaskOnWorkerThread( 278 void WebSharedWorkerImpl::ConnectTaskOnWorkerThread(
282 std::unique_ptr<WebMessagePortChannel> channel) { 279 std::unique_ptr<WebMessagePortChannel> channel) {
283 // Wrap the passed-in channel in a MessagePort, and send it off via a connect 280 // Wrap the passed-in channel in a MessagePort, and send it off via a connect
284 // event. 281 // event.
285 DCHECK(worker_thread_->IsCurrentThread()); 282 DCHECK(worker_thread_->IsCurrentThread());
286 WorkerGlobalScope* worker_global_scope = 283 WorkerGlobalScope* worker_global_scope =
287 ToWorkerGlobalScope(worker_thread_->GlobalScope()); 284 ToWorkerGlobalScope(worker_thread_->GlobalScope());
288 MessagePort* port = MessagePort::Create(*worker_global_scope); 285 MessagePort* port = MessagePort::Create(*worker_global_scope);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 if (devtools_agent) 421 if (devtools_agent)
425 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method, 422 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method,
426 message); 423 message);
427 } 424 }
428 425
429 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) { 426 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) {
430 return new WebSharedWorkerImpl(client); 427 return new WebSharedWorkerImpl(client);
431 } 428 }
432 429
433 } // namespace blink 430 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698