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

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

Issue 2539443004: Worker: Move ParentFrameTaskRunners from WorkerReportingProxy to ObjectProxy (Closed)
Patch Set: rebase 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 void WebSharedWorkerImpl::reportConsoleMessage(MessageSource, 246 void WebSharedWorkerImpl::reportConsoleMessage(MessageSource,
247 MessageLevel, 247 MessageLevel,
248 const String& message, 248 const String& message,
249 SourceLocation*) { 249 SourceLocation*) {
250 // Not supported in SharedWorker. 250 // Not supported in SharedWorker.
251 } 251 }
252 252
253 void WebSharedWorkerImpl::postMessageToPageInspector(const String& message) { 253 void WebSharedWorkerImpl::postMessageToPageInspector(const String& message) {
254 // The TaskType of Inspector tasks need to be Unthrottled because they need to 254 // The TaskType of Inspector tasks need to be Unthrottled because they need to
255 // run even on a suspended page. 255 // run even on a suspended page.
256 getParentFrameTaskRunners() 256 m_parentFrameTaskRunners->get(TaskType::Unthrottled)
257 ->get(TaskType::Unthrottled)
258 ->postTask( 257 ->postTask(
259 BLINK_FROM_HERE, 258 BLINK_FROM_HERE,
260 crossThreadBind( 259 crossThreadBind(
261 &WebSharedWorkerImpl::postMessageToPageInspectorOnMainThread, 260 &WebSharedWorkerImpl::postMessageToPageInspectorOnMainThread,
262 crossThreadUnretained(this), message)); 261 crossThreadUnretained(this), message));
263 } 262 }
264 263
265 void WebSharedWorkerImpl::postMessageToPageInspectorOnMainThread( 264 void WebSharedWorkerImpl::postMessageToPageInspectorOnMainThread(
266 const String& message) { 265 const String& message) {
267 m_workerInspectorProxy->dispatchMessageFromWorker(message); 266 m_workerInspectorProxy->dispatchMessageFromWorker(message);
268 } 267 }
269 268
270 ParentFrameTaskRunners* WebSharedWorkerImpl::getParentFrameTaskRunners() {
271 return m_parentFrameTaskRunners.get();
272 }
273
274 void WebSharedWorkerImpl::didCloseWorkerGlobalScope() { 269 void WebSharedWorkerImpl::didCloseWorkerGlobalScope() {
275 getParentFrameTaskRunners() 270 m_parentFrameTaskRunners->get(TaskType::UnspecedTimer)
276 ->get(TaskType::UnspecedTimer)
277 ->postTask( 271 ->postTask(
278 BLINK_FROM_HERE, 272 BLINK_FROM_HERE,
279 crossThreadBind( 273 crossThreadBind(
280 &WebSharedWorkerImpl::didCloseWorkerGlobalScopeOnMainThread, 274 &WebSharedWorkerImpl::didCloseWorkerGlobalScopeOnMainThread,
281 crossThreadUnretained(this))); 275 crossThreadUnretained(this)));
282 } 276 }
283 277
284 void WebSharedWorkerImpl::didCloseWorkerGlobalScopeOnMainThread() { 278 void WebSharedWorkerImpl::didCloseWorkerGlobalScopeOnMainThread() {
285 m_client->workerContextClosed(); 279 m_client->workerContextClosed();
286 280
287 terminateWorkerThread(); 281 terminateWorkerThread();
288 } 282 }
289 283
290 void WebSharedWorkerImpl::didTerminateWorkerThread() { 284 void WebSharedWorkerImpl::didTerminateWorkerThread() {
291 getParentFrameTaskRunners() 285 m_parentFrameTaskRunners->get(TaskType::UnspecedTimer)
292 ->get(TaskType::UnspecedTimer)
293 ->postTask(BLINK_FROM_HERE, 286 ->postTask(BLINK_FROM_HERE,
294 crossThreadBind( 287 crossThreadBind(
295 &WebSharedWorkerImpl::didTerminateWorkerThreadOnMainThread, 288 &WebSharedWorkerImpl::didTerminateWorkerThreadOnMainThread,
296 crossThreadUnretained(this))); 289 crossThreadUnretained(this)));
297 } 290 }
298 291
299 void WebSharedWorkerImpl::didTerminateWorkerThreadOnMainThread() { 292 void WebSharedWorkerImpl::didTerminateWorkerThreadOnMainThread() {
300 m_client->workerContextDestroyed(); 293 m_client->workerContextDestroyed();
301 // The lifetime of this proxy is controlled by the worker context. 294 // The lifetime of this proxy is controlled by the worker context.
302 delete this; 295 delete this;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 402
410 // SharedWorker can sometimes run tasks that are initiated by/associated with 403 // SharedWorker can sometimes run tasks that are initiated by/associated with
411 // a document's frame but these documents can be from a different process. So 404 // a document's frame but these documents can be from a different process. So
412 // we intentionally populate the task runners with null document in order to 405 // we intentionally populate the task runners with null document in order to
413 // use the thread's default task runner. Note that |m_document| should not be 406 // use the thread's default task runner. Note that |m_document| should not be
414 // used as it's a dummy document for loading that doesn't represent the frame 407 // used as it's a dummy document for loading that doesn't represent the frame
415 // of any associated document. 408 // of any associated document.
416 m_parentFrameTaskRunners = ParentFrameTaskRunners::create(nullptr); 409 m_parentFrameTaskRunners = ParentFrameTaskRunners::create(nullptr);
417 410
418 m_loaderProxy = WorkerLoaderProxy::create(this); 411 m_loaderProxy = WorkerLoaderProxy::create(this);
419 m_workerThread = SharedWorkerThread::create(m_name, m_loaderProxy, *this); 412 m_workerThread = SharedWorkerThread::create(m_name, m_loaderProxy, *this,
413 m_parentFrameTaskRunners.get());
420 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), 414 InspectorInstrumentation::scriptImported(m_loadingDocument.get(),
421 m_mainScriptLoader->identifier(), 415 m_mainScriptLoader->identifier(),
422 m_mainScriptLoader->script()); 416 m_mainScriptLoader->script());
423 m_mainScriptLoader.clear(); 417 m_mainScriptLoader.clear();
424 418
425 workerThread()->start(std::move(startupData)); 419 workerThread()->start(std::move(startupData));
426 m_workerInspectorProxy->workerThreadCreated( 420 m_workerInspectorProxy->workerThreadCreated(
427 toDocument(m_loadingDocument.get()), workerThread(), m_url); 421 toDocument(m_loadingDocument.get()), workerThread(), m_url);
428 m_client->workerScriptLoaded(); 422 m_client->workerScriptLoaded();
429 } 423 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 if (devtoolsAgent) 462 if (devtoolsAgent)
469 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, 463 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method,
470 message); 464 message);
471 } 465 }
472 466
473 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) { 467 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) {
474 return new WebSharedWorkerImpl(client); 468 return new WebSharedWorkerImpl(client);
475 } 469 }
476 470
477 } // namespace blink 471 } // 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