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

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

Issue 2642113002: Worker: Reduce use of ExecutionContextTask in core/workers (Closed)
Patch Set: fix build failures Created 3 years, 11 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/WebSharedWorkerImpl.h ('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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 wrapCrossThreadWeakPersistent(m_loadingDocument.get()))); 315 wrapCrossThreadWeakPersistent(m_loadingDocument.get())));
316 } 316 }
317 317
318 void WebSharedWorkerImpl::postTaskToWorkerGlobalScope( 318 void WebSharedWorkerImpl::postTaskToWorkerGlobalScope(
319 const WebTraceLocation& location, 319 const WebTraceLocation& location,
320 std::unique_ptr<WTF::CrossThreadClosure> task) { 320 std::unique_ptr<WTF::CrossThreadClosure> task) {
321 m_workerThread->postTask(location, std::move(task)); 321 m_workerThread->postTask(location, std::move(task));
322 } 322 }
323 323
324 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) { 324 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) {
325 DCHECK(isMainThread());
325 workerThread()->postTask( 326 workerThread()->postTask(
326 BLINK_FROM_HERE, 327 BLINK_FROM_HERE,
327 createCrossThreadTask( 328 crossThreadBind(&WebSharedWorkerImpl::connectTask,
328 &connectTask, 329 WTF::crossThreadUnretained(this),
329 WTF::passed(WebMessagePortChannelUniquePtr(webChannel)))); 330 WTF::passed(WebMessagePortChannelUniquePtr(webChannel))));
330 } 331 }
331 332
332 void WebSharedWorkerImpl::connectTask(WebMessagePortChannelUniquePtr channel, 333 void WebSharedWorkerImpl::connectTask(WebMessagePortChannelUniquePtr channel) {
333 ExecutionContext* context) {
334 // Wrap the passed-in channel in a MessagePort, and send it off via a connect 334 // Wrap the passed-in channel in a MessagePort, and send it off via a connect
335 // event. 335 // event.
336 MessagePort* port = MessagePort::create(*context); 336 DCHECK(m_workerThread->isCurrentThread());
337 WorkerGlobalScope* workerGlobalScope =
338 toWorkerGlobalScope(m_workerThread->globalScope());
339 MessagePort* port = MessagePort::create(*workerGlobalScope);
337 port->entangle(std::move(channel)); 340 port->entangle(std::move(channel));
338 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
339 SECURITY_DCHECK(workerGlobalScope->isSharedWorkerGlobalScope()); 341 SECURITY_DCHECK(workerGlobalScope->isSharedWorkerGlobalScope());
340 workerGlobalScope->dispatchEvent(createConnectEvent(port)); 342 workerGlobalScope->dispatchEvent(createConnectEvent(port));
341 } 343 }
342 344
343 void WebSharedWorkerImpl::startWorkerContext( 345 void WebSharedWorkerImpl::startWorkerContext(
344 const WebURL& url, 346 const WebURL& url,
345 const WebString& name, 347 const WebString& name,
346 const WebString& contentSecurityPolicy, 348 const WebString& contentSecurityPolicy,
347 WebContentSecurityPolicyType policyType, 349 WebContentSecurityPolicyType policyType,
348 WebAddressSpace creationAddressSpace) { 350 WebAddressSpace creationAddressSpace) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 if (devtoolsAgent) 468 if (devtoolsAgent)
467 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, 469 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method,
468 message); 470 message);
469 } 471 }
470 472
471 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) { 473 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) {
472 return new WebSharedWorkerImpl(client); 474 return new WebSharedWorkerImpl(client);
473 } 475 }
474 476
475 } // namespace blink 477 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebSharedWorkerImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698