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

Side by Side Diff: Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp

Issue 17648006: Rename WorkerContext to WorkerGlobalScope (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 6 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 | Annotate | Revision Log
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "core/dom/MessageEvent.h" 48 #include "core/dom/MessageEvent.h"
49 #include "core/dom/MessagePortChannel.h" 49 #include "core/dom/MessagePortChannel.h"
50 #include "core/dom/ScriptExecutionContext.h" 50 #include "core/dom/ScriptExecutionContext.h"
51 #include "core/dom/default/chromium/PlatformMessagePortChannelChromium.h" 51 #include "core/dom/default/chromium/PlatformMessagePortChannelChromium.h"
52 #include "core/inspector/WorkerDebuggerAgent.h" 52 #include "core/inspector/WorkerDebuggerAgent.h"
53 #include "core/inspector/WorkerInspectorController.h" 53 #include "core/inspector/WorkerInspectorController.h"
54 #include "core/loader/FrameLoadRequest.h" 54 #include "core/loader/FrameLoadRequest.h"
55 #include "core/loader/FrameLoader.h" 55 #include "core/loader/FrameLoader.h"
56 #include "core/page/Page.h" 56 #include "core/page/Page.h"
57 #include "core/page/PageGroup.h" 57 #include "core/page/PageGroup.h"
58 #include "core/workers/SharedWorkerContext.h" 58 #include "core/workers/SharedWorkerGlobalScope.h"
59 #include "core/workers/SharedWorkerThread.h" 59 #include "core/workers/SharedWorkerThread.h"
60 #include "core/workers/WorkerContext.h" 60 #include "core/workers/WorkerGlobalScope.h"
61 #include "core/workers/WorkerLoaderProxy.h" 61 #include "core/workers/WorkerLoaderProxy.h"
62 #include "core/workers/WorkerThread.h" 62 #include "core/workers/WorkerThread.h"
63 #include "modules/webdatabase/DatabaseTask.h" 63 #include "modules/webdatabase/DatabaseTask.h"
64 #include "weborigin/KURL.h" 64 #include "weborigin/KURL.h"
65 #include "weborigin/SecurityOrigin.h" 65 #include "weborigin/SecurityOrigin.h"
66 66
67 using namespace WebCore; 67 using namespace WebCore;
68 68
69 namespace WebKit { 69 namespace WebKit {
70 70
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 271
272 void WebSharedWorkerImpl::reportPendingActivityTask(ScriptExecutionContext* cont ext, 272 void WebSharedWorkerImpl::reportPendingActivityTask(ScriptExecutionContext* cont ext,
273 WebSharedWorkerImpl* thisPtr , 273 WebSharedWorkerImpl* thisPtr ,
274 bool hasPendingActivity) 274 bool hasPendingActivity)
275 { 275 {
276 if (!thisPtr->client()) 276 if (!thisPtr->client())
277 return; 277 return;
278 thisPtr->client()->reportPendingActivity(hasPendingActivity); 278 thisPtr->client()->reportPendingActivity(hasPendingActivity);
279 } 279 }
280 280
281 void WebSharedWorkerImpl::workerContextClosed() 281 void WebSharedWorkerImpl::workerGlobalScopeClosed()
282 { 282 {
283 WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&workerContextClo sedTask, 283 WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&workerGlobalScop eClosedTask,
284 AllowCrossThreadAccess(this))); 284 AllowCrossThreadAccess(this)));
285 } 285 }
286 286
287 void WebSharedWorkerImpl::workerContextClosedTask(ScriptExecutionContext* contex t, 287 void WebSharedWorkerImpl::workerGlobalScopeClosedTask(ScriptExecutionContext* co ntext,
288 WebSharedWorkerImpl* thisPtr) 288 WebSharedWorkerImpl* thisPtr)
289 { 289 {
290 if (thisPtr->client()) 290 if (thisPtr->client())
291 thisPtr->client()->workerContextClosed(); 291 thisPtr->client()->workerContextClosed();
292 292
293 thisPtr->stopWorkerThread(); 293 thisPtr->stopWorkerThread();
294 } 294 }
295 295
296 void WebSharedWorkerImpl::workerContextDestroyed() 296 void WebSharedWorkerImpl::workerGlobalScopeDestroyed()
297 { 297 {
298 WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&workerContextDes troyedTask, 298 WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&workerGlobalScop eDestroyedTask,
299 AllowCrossThreadA ccess(this))); 299 AllowCrossThreadA ccess(this)));
300 } 300 }
301 301
302 void WebSharedWorkerImpl::workerContextDestroyedTask(ScriptExecutionContext* con text, 302 void WebSharedWorkerImpl::workerGlobalScopeDestroyedTask(ScriptExecutionContext* context,
303 WebSharedWorkerImpl* thisPt r) 303 WebSharedWorkerImpl* thisPt r)
304 { 304 {
305 if (thisPtr->client()) 305 if (thisPtr->client())
306 thisPtr->client()->workerContextDestroyed(); 306 thisPtr->client()->workerContextDestroyed();
307 // The lifetime of this proxy is controlled by the worker context. 307 // The lifetime of this proxy is controlled by the worker context.
308 delete thisPtr; 308 delete thisPtr;
309 } 309 }
310 310
311 // WorkerLoaderProxy ----------------------------------------------------------- 311 // WorkerLoaderProxy -----------------------------------------------------------
312 312
313 void WebSharedWorkerImpl::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Ta sk> task) 313 void WebSharedWorkerImpl::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Ta sk> task)
314 { 314 {
315 ASSERT(m_loadingDocument->isDocument()); 315 ASSERT(m_loadingDocument->isDocument());
316 m_loadingDocument->postTask(task); 316 m_loadingDocument->postTask(task);
317 } 317 }
318 318
319 bool WebSharedWorkerImpl::postTaskForModeToWorkerContext( 319 bool WebSharedWorkerImpl::postTaskForModeToWorkerGlobalScope(
320 PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode) 320 PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode)
321 { 321 {
322 m_workerThread->runLoop().postTaskForMode(task, mode); 322 m_workerThread->runLoop().postTaskForMode(task, mode);
323 return true; 323 return true;
324 } 324 }
325 325
326 WebWorkerBase* WebSharedWorkerImpl::toWebWorkerBase() 326 WebWorkerBase* WebSharedWorkerImpl::toWebWorkerBase()
327 { 327 {
328 return this; 328 return this;
329 } 329 }
(...skipping 19 matching lines...) Expand all
349 createCallbackTask(&connectTask, channel.release())); 349 createCallbackTask(&connectTask, channel.release()));
350 if (listener) 350 if (listener)
351 listener->connected(); 351 listener->connected();
352 } 352 }
353 353
354 void WebSharedWorkerImpl::connectTask(ScriptExecutionContext* context, PassOwnPt r<MessagePortChannel> channel) 354 void WebSharedWorkerImpl::connectTask(ScriptExecutionContext* context, PassOwnPt r<MessagePortChannel> channel)
355 { 355 {
356 // Wrap the passed-in channel in a MessagePort, and send it off via a connec t event. 356 // Wrap the passed-in channel in a MessagePort, and send it off via a connec t event.
357 RefPtr<MessagePort> port = MessagePort::create(*context); 357 RefPtr<MessagePort> port = MessagePort::create(*context);
358 port->entangle(channel); 358 port->entangle(channel);
359 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerContext()); 359 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerGlobalScope());
360 WorkerContext* workerContext = static_cast<WorkerContext*>(context); 360 WorkerGlobalScope* workerGlobalScope = static_cast<WorkerGlobalScope*>(conte xt);
361 ASSERT_WITH_SECURITY_IMPLICATION(workerContext->isSharedWorkerContext()); 361 ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope->isSharedWorkerGlobalScop e());
362 workerContext->dispatchEvent(createConnectEvent(port)); 362 workerGlobalScope->dispatchEvent(createConnectEvent(port));
363 } 363 }
364 364
365 void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString& name, const WebString& userAgent, const WebString& sourceCode, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType policyType, long long) 365 void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString& name, const WebString& userAgent, const WebString& sourceCode, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType policyType, long long)
366 { 366 {
367 initializeLoader(url); 367 initializeLoader(url);
368 WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerC ontextOnStart : DontPauseWorkerContextOnStart; 368 WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerG lobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart;
369 setWorkerThread(SharedWorkerThread::create(name, url, userAgent, 369 setWorkerThread(SharedWorkerThread::create(name, url, userAgent,
370 sourceCode, *this, *this, startMo de, contentSecurityPolicy, 370 sourceCode, *this, *this, startMo de, contentSecurityPolicy,
371 static_cast<WebCore::ContentSecur ityPolicy::HeaderType>(policyType))); 371 static_cast<WebCore::ContentSecur ityPolicy::HeaderType>(policyType)));
372 372
373 workerThread()->start(); 373 workerThread()->start();
374 } 374 }
375 375
376 void WebSharedWorkerImpl::terminateWorkerContext() 376 void WebSharedWorkerImpl::terminateWorkerContext()
377 { 377 {
378 stopWorkerThread(); 378 stopWorkerThread();
379 } 379 }
380 380
381 void WebSharedWorkerImpl::clientDestroyed() 381 void WebSharedWorkerImpl::clientDestroyed()
382 { 382 {
383 m_client = 0; 383 m_client = 0;
384 } 384 }
385 385
386 void WebSharedWorkerImpl::pauseWorkerContextOnStart() 386 void WebSharedWorkerImpl::pauseWorkerContextOnStart()
387 { 387 {
388 m_pauseWorkerContextOnStart = true; 388 m_pauseWorkerContextOnStart = true;
389 } 389 }
390 390
391 static void resumeWorkerContextTask(ScriptExecutionContext* context, bool) 391 static void resumeWorkerContextTask(ScriptExecutionContext* context, bool)
392 { 392 {
393 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerContext()); 393 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerGlobalScope());
394 static_cast<WorkerContext*>(context)->workerInspectorController()->resume(); 394 static_cast<WorkerGlobalScope*>(context)->workerInspectorController()->resum e();
395 } 395 }
396 396
397 void WebSharedWorkerImpl::resumeWorkerContext() 397 void WebSharedWorkerImpl::resumeWorkerContext()
398 { 398 {
399 m_pauseWorkerContextOnStart = false; 399 m_pauseWorkerContextOnStart = false;
400 if (workerThread()) 400 if (workerThread())
401 workerThread()->runLoop().postTaskForMode(createCallbackTask(resumeWorke rContextTask, true), WorkerDebuggerAgent::debuggerTaskMode); 401 workerThread()->runLoop().postTaskForMode(createCallbackTask(resumeWorke rContextTask, true), WorkerDebuggerAgent::debuggerTaskMode);
402 } 402 }
403 403
404 static void connectToWorkerContextInspectorTask(ScriptExecutionContext* context, bool) 404 static void connectToWorkerContextInspectorTask(ScriptExecutionContext* context, bool)
405 { 405 {
406 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerContext()); 406 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerGlobalScope());
407 static_cast<WorkerContext*>(context)->workerInspectorController()->connectFr ontend(); 407 static_cast<WorkerGlobalScope*>(context)->workerInspectorController()->conne ctFrontend();
408 } 408 }
409 409
410 void WebSharedWorkerImpl::attachDevTools() 410 void WebSharedWorkerImpl::attachDevTools()
411 { 411 {
412 workerThread()->runLoop().postTaskForMode(createCallbackTask(connectToWorker ContextInspectorTask, true), WorkerDebuggerAgent::debuggerTaskMode); 412 workerThread()->runLoop().postTaskForMode(createCallbackTask(connectToWorker ContextInspectorTask, true), WorkerDebuggerAgent::debuggerTaskMode);
413 } 413 }
414 414
415 static void reconnectToWorkerContextInspectorTask(ScriptExecutionContext* contex t, const String& savedState) 415 static void reconnectToWorkerContextInspectorTask(ScriptExecutionContext* contex t, const String& savedState)
416 { 416 {
417 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerContext()); 417 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerGlobalScope());
418 WorkerInspectorController* ic = static_cast<WorkerContext*>(context)->worker InspectorController(); 418 WorkerInspectorController* ic = static_cast<WorkerGlobalScope*>(context)->wo rkerInspectorController();
419 ic->restoreInspectorStateFromCookie(savedState); 419 ic->restoreInspectorStateFromCookie(savedState);
420 ic->resume(); 420 ic->resume();
421 } 421 }
422 422
423 void WebSharedWorkerImpl::reattachDevTools(const WebString& savedState) 423 void WebSharedWorkerImpl::reattachDevTools(const WebString& savedState)
424 { 424 {
425 workerThread()->runLoop().postTaskForMode(createCallbackTask(reconnectToWork erContextInspectorTask, String(savedState)), WorkerDebuggerAgent::debuggerTaskMo de); 425 workerThread()->runLoop().postTaskForMode(createCallbackTask(reconnectToWork erContextInspectorTask, String(savedState)), WorkerDebuggerAgent::debuggerTaskMo de);
426 } 426 }
427 427
428 static void disconnectFromWorkerContextInspectorTask(ScriptExecutionContext* con text, bool) 428 static void disconnectFromWorkerContextInspectorTask(ScriptExecutionContext* con text, bool)
429 { 429 {
430 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerContext()); 430 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerGlobalScope());
431 static_cast<WorkerContext*>(context)->workerInspectorController()->disconnec tFrontend(); 431 static_cast<WorkerGlobalScope*>(context)->workerInspectorController()->disco nnectFrontend();
432 } 432 }
433 433
434 void WebSharedWorkerImpl::detachDevTools() 434 void WebSharedWorkerImpl::detachDevTools()
435 { 435 {
436 workerThread()->runLoop().postTaskForMode(createCallbackTask(disconnectFromW orkerContextInspectorTask, true), WorkerDebuggerAgent::debuggerTaskMode); 436 workerThread()->runLoop().postTaskForMode(createCallbackTask(disconnectFromW orkerContextInspectorTask, true), WorkerDebuggerAgent::debuggerTaskMode);
437 } 437 }
438 438
439 static void dispatchOnInspectorBackendTask(ScriptExecutionContext* context, cons t String& message) 439 static void dispatchOnInspectorBackendTask(ScriptExecutionContext* context, cons t String& message)
440 { 440 {
441 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerContext()); 441 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerGlobalScope());
442 static_cast<WorkerContext*>(context)->workerInspectorController()->dispatchM essageFromFrontend(message); 442 static_cast<WorkerGlobalScope*>(context)->workerInspectorController()->dispa tchMessageFromFrontend(message);
443 } 443 }
444 444
445 void WebSharedWorkerImpl::dispatchDevToolsMessage(const WebString& message) 445 void WebSharedWorkerImpl::dispatchDevToolsMessage(const WebString& message)
446 { 446 {
447 workerThread()->runLoop().postTaskForMode(createCallbackTask(dispatchOnInspe ctorBackendTask, String(message)), WorkerDebuggerAgent::debuggerTaskMode); 447 workerThread()->runLoop().postTaskForMode(createCallbackTask(dispatchOnInspe ctorBackendTask, String(message)), WorkerDebuggerAgent::debuggerTaskMode);
448 WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(workerThread()); 448 WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(workerThread());
449 } 449 }
450 450
451 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) 451 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client)
452 { 452 {
453 return new WebSharedWorkerImpl(client); 453 return new WebSharedWorkerImpl(client);
454 } 454 }
455 455
456 } // namespace WebKit 456 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/WebSharedWorkerImpl.h ('k') | Source/WebKit/chromium/src/WebWorkerBase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698