Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 #include "platform/heap/Handle.h" | 54 #include "platform/heap/Handle.h" |
| 55 #include "platform/network/ContentSecurityPolicyParsers.h" | 55 #include "platform/network/ContentSecurityPolicyParsers.h" |
| 56 #include "platform/network/ResourceResponse.h" | 56 #include "platform/network/ResourceResponse.h" |
| 57 #include "platform/weborigin/KURL.h" | 57 #include "platform/weborigin/KURL.h" |
| 58 #include "platform/weborigin/SecurityOrigin.h" | 58 #include "platform/weborigin/SecurityOrigin.h" |
| 59 #include "public/platform/WebFileError.h" | 59 #include "public/platform/WebFileError.h" |
| 60 #include "public/platform/WebMessagePortChannel.h" | 60 #include "public/platform/WebMessagePortChannel.h" |
| 61 #include "public/platform/WebString.h" | 61 #include "public/platform/WebString.h" |
| 62 #include "public/platform/WebURL.h" | 62 #include "public/platform/WebURL.h" |
| 63 #include "public/platform/WebURLRequest.h" | 63 #include "public/platform/WebURLRequest.h" |
| 64 #include "public/web/WebDevToolsAgent.h" | |
| 64 #include "public/web/WebFrame.h" | 65 #include "public/web/WebFrame.h" |
| 65 #include "public/web/WebSettings.h" | 66 #include "public/web/WebSettings.h" |
| 66 #include "public/web/WebView.h" | 67 #include "public/web/WebView.h" |
| 67 #include "public/web/WebWorkerPermissionClientProxy.h" | 68 #include "public/web/WebWorkerPermissionClientProxy.h" |
| 68 #include "web/DatabaseClientImpl.h" | 69 #include "web/DatabaseClientImpl.h" |
| 69 #include "web/LocalFileSystemClient.h" | 70 #include "web/LocalFileSystemClient.h" |
| 70 #include "web/WebDataSourceImpl.h" | 71 #include "web/WebDataSourceImpl.h" |
| 71 #include "web/WebLocalFrameImpl.h" | 72 #include "web/WebLocalFrameImpl.h" |
| 72 #include "web/WorkerPermissionClient.h" | 73 #include "web/WorkerPermissionClient.h" |
| 73 #include "wtf/Functional.h" | 74 #include "wtf/Functional.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 } | 153 } |
| 153 | 154 |
| 154 WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client) | 155 WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client) |
| 155 : m_webView(0) | 156 : m_webView(0) |
| 156 , m_mainFrame(0) | 157 , m_mainFrame(0) |
| 157 , m_askedToTerminate(false) | 158 , m_askedToTerminate(false) |
| 158 , m_workerInspectorProxy(WorkerInspectorProxy::create()) | 159 , m_workerInspectorProxy(WorkerInspectorProxy::create()) |
| 159 , m_client(WeakReference<WebSharedWorkerClient>::create(client)) | 160 , m_client(WeakReference<WebSharedWorkerClient>::create(client)) |
| 160 , m_clientWeakPtr(WeakPtr<WebSharedWorkerClient>(m_client)) | 161 , m_clientWeakPtr(WeakPtr<WebSharedWorkerClient>(m_client)) |
| 161 , m_pauseWorkerContextOnStart(false) | 162 , m_pauseWorkerContextOnStart(false) |
| 162 , m_attachDevToolsOnStart(false) | 163 , m_isPausedOnStart(false) |
| 163 { | 164 { |
| 164 initializeWebKitStaticValues(); | 165 initializeWebKitStaticValues(); |
| 165 } | 166 } |
| 166 | 167 |
| 167 WebSharedWorkerImpl::~WebSharedWorkerImpl() | 168 WebSharedWorkerImpl::~WebSharedWorkerImpl() |
| 168 { | 169 { |
| 169 ASSERT(m_webView); | 170 ASSERT(m_webView); |
| 170 // Detach the client before closing the view to avoid getting called back. | 171 // Detach the client before closing the view to avoid getting called back. |
| 171 toWebLocalFrameImpl(m_mainFrame)->setClient(0); | 172 toWebLocalFrameImpl(m_mainFrame)->setClient(0); |
| 172 | 173 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 200 ASSERT(!m_webView); | 201 ASSERT(!m_webView); |
| 201 m_webView = WebView::create(0); | 202 m_webView = WebView::create(0); |
| 202 m_webView->settings()->setOfflineWebApplicationCacheEnabled(RuntimeEnabledFe atures::applicationCacheEnabled()); | 203 m_webView->settings()->setOfflineWebApplicationCacheEnabled(RuntimeEnabledFe atures::applicationCacheEnabled()); |
| 203 // FIXME: http://crbug.com/363843. This needs to find a better way to | 204 // FIXME: http://crbug.com/363843. This needs to find a better way to |
| 204 // not create graphics layers. | 205 // not create graphics layers. |
| 205 m_webView->settings()->setAcceleratedCompositingEnabled(false); | 206 m_webView->settings()->setAcceleratedCompositingEnabled(false); |
| 206 // FIXME: Settings information should be passed to the Worker process from B rowser process when the worker | 207 // FIXME: Settings information should be passed to the Worker process from B rowser process when the worker |
| 207 // is created (similar to RenderThread::OnCreateNewView). | 208 // is created (similar to RenderThread::OnCreateNewView). |
| 208 m_mainFrame = WebLocalFrame::create(this); | 209 m_mainFrame = WebLocalFrame::create(this); |
| 209 m_webView->setMainFrame(m_mainFrame); | 210 m_webView->setMainFrame(m_mainFrame); |
| 211 m_webView->setDevToolsAgentClient(this); | |
| 210 | 212 |
| 211 WebLocalFrameImpl* webFrame = toWebLocalFrameImpl(m_webView->mainFrame()); | 213 WebLocalFrameImpl* webFrame = toWebLocalFrameImpl(m_webView->mainFrame()); |
| 212 | 214 |
| 213 // Construct substitute data source for the 'shadow page'. We only need it | 215 // Construct substitute data source for the 'shadow page'. We only need it |
| 214 // to have same origin as the worker so the loading checks work correctly. | 216 // to have same origin as the worker so the loading checks work correctly. |
| 215 CString content(""); | 217 CString content(""); |
| 216 int length = static_cast<int>(content.length()); | 218 int length = static_cast<int>(content.length()); |
| 217 RefPtr<SharedBuffer> buffer(SharedBuffer::create(content.data(), length)); | 219 RefPtr<SharedBuffer> buffer(SharedBuffer::create(content.data(), length)); |
| 218 webFrame->frame()->loader().load(FrameLoadRequest(0, ResourceRequest(url), S ubstituteData(buffer, "text/html", "UTF-8", KURL()))); | 220 webFrame->frame()->loader().load(FrameLoadRequest(0, ResourceRequest(url), S ubstituteData(buffer, "text/html", "UTF-8", KURL()))); |
| 219 } | 221 } |
| 220 | 222 |
| 221 WebApplicationCacheHost* WebSharedWorkerImpl::createApplicationCacheHost(WebLoca lFrame*, WebApplicationCacheHostClient* appcacheHostClient) | 223 WebApplicationCacheHost* WebSharedWorkerImpl::createApplicationCacheHost(WebLoca lFrame*, WebApplicationCacheHostClient* appcacheHostClient) |
| 222 { | 224 { |
| 223 if (client()) | 225 if (client()) |
| 224 return client()->createApplicationCacheHost(appcacheHostClient); | 226 return client()->createApplicationCacheHost(appcacheHostClient); |
| 225 return 0; | 227 return 0; |
| 226 } | 228 } |
| 227 | 229 |
| 228 void WebSharedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) | 230 void WebSharedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) |
| 229 { | 231 { |
| 232 // If we were asked to pause worker context on start and wait for debugger t hen it is the good time to do that. | |
| 233 client()->workerReadyForInspection(); | |
| 234 if (m_pauseWorkerContextOnStart) { | |
| 235 m_isPausedOnStart = true; | |
| 236 return; | |
| 237 } | |
| 238 startScriptLoader(frame); | |
| 239 } | |
| 240 | |
| 241 void WebSharedWorkerImpl::sendMessageToInspectorFrontend(const WebString& messag e) | |
| 242 { | |
| 243 client()->dispatchDevToolsMessage(message); | |
| 244 } | |
| 245 | |
| 246 void WebSharedWorkerImpl::resumeStartup() | |
| 247 { | |
| 248 bool isPausedOnStart = m_isPausedOnStart; | |
| 249 m_isPausedOnStart = false; | |
| 250 if (isPausedOnStart) | |
| 251 startScriptLoader(toWebLocalFrameImpl(m_mainFrame)); | |
| 252 } | |
| 253 | |
| 254 void WebSharedWorkerImpl::saveAgentRuntimeState(const WebString& inspectorState) | |
| 255 { | |
| 256 client()->saveDevToolsAgentState(inspectorState); | |
| 257 } | |
| 258 | |
| 259 void WebSharedWorkerImpl::startScriptLoader(WebLocalFrame* frame) | |
| 260 { | |
| 230 ASSERT(!m_loadingDocument); | 261 ASSERT(!m_loadingDocument); |
| 231 ASSERT(!m_mainScriptLoader); | 262 ASSERT(!m_mainScriptLoader); |
| 232 m_mainScriptLoader = Loader::create(); | 263 m_mainScriptLoader = Loader::create(); |
| 233 m_loadingDocument = toWebLocalFrameImpl(frame)->frame()->document(); | 264 m_loadingDocument = toWebLocalFrameImpl(frame)->frame()->document(); |
| 234 m_mainScriptLoader->load( | 265 m_mainScriptLoader->load( |
| 235 m_loadingDocument.get(), | 266 m_loadingDocument.get(), |
| 236 m_url, | 267 m_url, |
| 237 bind(&WebSharedWorkerImpl::didReceiveScriptLoaderResponse, this), | 268 bind(&WebSharedWorkerImpl::didReceiveScriptLoaderResponse, this), |
| 238 bind(&WebSharedWorkerImpl::onScriptLoaderFinished, this)); | 269 bind(&WebSharedWorkerImpl::onScriptLoaderFinished, this)); |
| 239 } | 270 } |
| 240 | 271 |
| 241 // WorkerReportingProxy -------------------------------------------------------- | 272 // WorkerReportingProxy -------------------------------------------------------- |
| 242 | 273 |
| 243 void WebSharedWorkerImpl::reportException(const String& errorMessage, int lineNu mber, int columnNumber, const String& sourceURL) | 274 void WebSharedWorkerImpl::reportException(const String& errorMessage, int lineNu mber, int columnNumber, const String& sourceURL) |
| 244 { | 275 { |
| 245 // Not suppported in SharedWorker. | 276 // Not suppported in SharedWorker. |
| 246 } | 277 } |
| 247 | 278 |
| 248 void WebSharedWorkerImpl::reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMes sage>) | 279 void WebSharedWorkerImpl::reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMes sage>) |
| 249 { | 280 { |
| 250 // Not supported in SharedWorker. | 281 // Not supported in SharedWorker. |
| 251 } | 282 } |
| 252 | 283 |
| 253 void WebSharedWorkerImpl::postMessageToPageInspector(const String& message) | 284 void WebSharedWorkerImpl::postMessageToPageInspector(const String& message) |
| 254 { | 285 { |
| 255 // Note that we need to keep the closure creation on a separate line so | |
| 256 // that the temporary created by isolatedCopy() will always be destroyed | |
| 257 // before the copy in the closure is used on the main thread. | |
| 258 const Closure& boundFunction = bind(&WebSharedWorkerClient::dispatchDevTools Message, m_clientWeakPtr, message.isolatedCopy()); | |
| 259 callOnMainThread(boundFunction); | |
| 260 toWebLocalFrameImpl(m_mainFrame)->frame()->document()->postInspectorTask(cre ateCrossThreadTask(&WebSharedWorkerImpl::postMessageToPageInspectorOnMainThread, this, message)); | 286 toWebLocalFrameImpl(m_mainFrame)->frame()->document()->postInspectorTask(cre ateCrossThreadTask(&WebSharedWorkerImpl::postMessageToPageInspectorOnMainThread, this, message)); |
| 261 } | 287 } |
| 262 | 288 |
| 263 void WebSharedWorkerImpl::postMessageToPageInspectorOnMainThread(const String& m essage) | 289 void WebSharedWorkerImpl::postMessageToPageInspectorOnMainThread(const String& m essage) |
| 264 { | 290 { |
| 265 WorkerInspectorProxy::PageInspector* pageInspector = m_workerInspectorProxy- >pageInspector(); | 291 WorkerInspectorProxy::PageInspector* pageInspector = m_workerInspectorProxy- >pageInspector(); |
| 266 if (!pageInspector) | 292 if (!pageInspector) |
| 267 return; | 293 return; |
| 268 pageInspector->dispatchMessageFromWorker(message); | 294 pageInspector->dispatchMessageFromWorker(message); |
| 269 | 295 |
| 270 } | 296 } |
| 271 | 297 |
| 272 void WebSharedWorkerImpl::updateInspectorStateCookie(const String& cookie) | 298 void WebSharedWorkerImpl::updateInspectorStateCookie(const String& cookie) |
| 273 { | 299 { |
| 274 // Note that we need to keep the closure creation on a separate line so | |
| 275 // that the temporary created by isolatedCopy() will always be destroyed | |
| 276 // before the copy in the closure is used on the main thread. | |
| 277 const Closure& boundFunction = bind(&WebSharedWorkerClient::saveDevToolsAgen tState, m_clientWeakPtr, cookie.isolatedCopy()); | |
| 278 callOnMainThread(boundFunction); | |
| 279 } | 300 } |
| 280 | 301 |
| 281 void WebSharedWorkerImpl::workerGlobalScopeClosed() | 302 void WebSharedWorkerImpl::workerGlobalScopeClosed() |
| 282 { | 303 { |
| 283 callOnMainThread(bind(&WebSharedWorkerImpl::workerGlobalScopeClosedOnMainThr ead, this)); | 304 callOnMainThread(bind(&WebSharedWorkerImpl::workerGlobalScopeClosedOnMainThr ead, this)); |
| 284 } | 305 } |
| 285 | 306 |
| 286 void WebSharedWorkerImpl::workerGlobalScopeClosedOnMainThread() | 307 void WebSharedWorkerImpl::workerGlobalScopeClosedOnMainThread() |
| 287 { | 308 { |
| 288 if (client()) | 309 if (client()) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 initializeLoader(url); | 367 initializeLoader(url); |
| 347 } | 368 } |
| 348 | 369 |
| 349 void WebSharedWorkerImpl::didReceiveScriptLoaderResponse() | 370 void WebSharedWorkerImpl::didReceiveScriptLoaderResponse() |
| 350 { | 371 { |
| 351 InspectorInstrumentation::didReceiveScriptResponse(m_loadingDocument.get(), m_mainScriptLoader->identifier()); | 372 InspectorInstrumentation::didReceiveScriptResponse(m_loadingDocument.get(), m_mainScriptLoader->identifier()); |
| 352 if (client()) | 373 if (client()) |
| 353 client()->selectAppCacheID(m_mainScriptLoader->appCacheID()); | 374 client()->selectAppCacheID(m_mainScriptLoader->appCacheID()); |
| 354 } | 375 } |
| 355 | 376 |
| 356 static void connectToWorkerContextInspectorTask(ExecutionContext* context, bool) | |
| 357 { | |
| 358 toWorkerGlobalScope(context)->workerInspectorController()->connectFrontend() ; | |
| 359 } | |
| 360 | |
| 361 void WebSharedWorkerImpl::onScriptLoaderFinished() | 377 void WebSharedWorkerImpl::onScriptLoaderFinished() |
| 362 { | 378 { |
| 363 ASSERT(m_loadingDocument); | 379 ASSERT(m_loadingDocument); |
| 364 ASSERT(m_mainScriptLoader); | 380 ASSERT(m_mainScriptLoader); |
| 365 if (m_askedToTerminate) | 381 if (m_askedToTerminate) |
| 366 return; | 382 return; |
| 367 if (m_mainScriptLoader->failed()) { | 383 if (m_mainScriptLoader->failed()) { |
| 368 m_mainScriptLoader->cancel(); | 384 m_mainScriptLoader->cancel(); |
| 369 if (client()) | 385 if (client()) |
| 370 client()->workerScriptLoadFailed(); | 386 client()->workerScriptLoadFailed(); |
| 371 | 387 |
| 372 // The SharedWorker was unable to load the initial script, so | 388 // The SharedWorker was unable to load the initial script, so |
| 373 // shut it down right here. | 389 // shut it down right here. |
| 374 delete this; | 390 delete this; |
| 375 return; | 391 return; |
| 376 } | 392 } |
| 377 WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerG lobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart; | 393 |
| 394 Document* document = toWebLocalFrameImpl(m_mainFrame)->frame()->document(); | |
| 395 WorkerThreadStartMode startMode = DontPauseWorkerGlobalScopeOnStart; | |
| 396 if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(document)) | |
|
horo
2014/09/04 05:44:02
nit: It is better to rename "shouldPauseDedicatedW
| |
| 397 startMode = PauseWorkerGlobalScopeOnStart; | |
| 398 | |
| 378 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); | 399 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); |
| 379 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c reate()); | 400 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c reate()); |
| 380 provideDatabaseClientToWorker(workerClients.get(), DatabaseClientImpl::creat e()); | 401 provideDatabaseClientToWorker(workerClients.get(), DatabaseClientImpl::creat e()); |
| 381 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); | 402 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); |
| 382 providePermissionClientToWorker(workerClients.get(), adoptPtr(client()->crea teWorkerPermissionClientProxy(webSecurityOrigin))); | 403 providePermissionClientToWorker(workerClients.get(), adoptPtr(client()->crea teWorkerPermissionClientProxy(webSecurityOrigin))); |
| 383 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartu pData::create(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->sc ript(), startMode, m_contentSecurityPolicy, static_cast<ContentSecurityPolicyHea derType>(m_policyType), workerClients.release()); | 404 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartu pData::create(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->sc ript(), startMode, m_contentSecurityPolicy, static_cast<ContentSecurityPolicyHea derType>(m_policyType), workerClients.release()); |
| 384 setWorkerThread(SharedWorkerThread::create(m_name, *this, *this, startupData .release())); | 405 setWorkerThread(SharedWorkerThread::create(m_name, *this, *this, startupData .release())); |
| 385 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri ptLoader->identifier(), m_mainScriptLoader->script()); | 406 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri ptLoader->identifier(), m_mainScriptLoader->script()); |
| 386 m_mainScriptLoader.clear(); | 407 m_mainScriptLoader.clear(); |
| 387 | 408 |
| 388 if (m_attachDevToolsOnStart) | |
| 389 workerThread()->postDebuggerTask(createCrossThreadTask(connectToWorkerCo ntextInspectorTask, true)); | |
| 390 | |
| 391 workerThread()->start(); | 409 workerThread()->start(); |
| 392 m_workerInspectorProxy->workerThreadCreated(m_loadingDocument.get(), workerT hread(), m_url); | 410 m_workerInspectorProxy->workerThreadCreated(m_loadingDocument.get(), workerT hread(), m_url); |
| 393 if (client()) { | 411 if (client()) |
| 394 client()->workerScriptLoaded(); | 412 client()->workerScriptLoaded(); |
| 395 client()->workerReadyForInspection(); | |
| 396 } | |
| 397 } | 413 } |
| 398 | 414 |
| 399 void WebSharedWorkerImpl::terminateWorkerContext() | 415 void WebSharedWorkerImpl::terminateWorkerContext() |
| 400 { | 416 { |
| 401 stopWorkerThread(); | 417 stopWorkerThread(); |
| 402 } | 418 } |
| 403 | 419 |
| 404 void WebSharedWorkerImpl::clientDestroyed() | 420 void WebSharedWorkerImpl::clientDestroyed() |
| 405 { | 421 { |
| 406 m_client.clear(); | 422 m_client.clear(); |
| 407 } | 423 } |
| 408 | 424 |
| 409 void WebSharedWorkerImpl::pauseWorkerContextOnStart() | 425 void WebSharedWorkerImpl::pauseWorkerContextOnStart() |
| 410 { | 426 { |
| 411 m_pauseWorkerContextOnStart = true; | 427 m_pauseWorkerContextOnStart = true; |
| 412 } | 428 } |
| 413 | 429 |
| 414 static void resumeWorkerContextTask(ExecutionContext* context, bool) | |
| 415 { | |
| 416 toWorkerGlobalScope(context)->workerInspectorController()->resume(); | |
| 417 } | |
| 418 | |
| 419 void WebSharedWorkerImpl::resumeWorkerContext() | 430 void WebSharedWorkerImpl::resumeWorkerContext() |
| 420 { | 431 { |
| 421 m_pauseWorkerContextOnStart = false; | |
| 422 if (workerThread()) | |
| 423 workerThread()->postDebuggerTask(createCrossThreadTask(resumeWorkerConte xtTask, true)); | |
| 424 } | |
| 425 | |
| 426 void WebSharedWorkerImpl::attachDevTools() | |
| 427 { | |
| 428 if (workerThread()) | |
| 429 workerThread()->postDebuggerTask(createCrossThreadTask(connectToWorkerCo ntextInspectorTask, true)); | |
| 430 else | |
| 431 m_attachDevToolsOnStart = true; | |
| 432 } | 432 } |
| 433 | 433 |
| 434 void WebSharedWorkerImpl::attachDevTools(const WebString& hostId) | 434 void WebSharedWorkerImpl::attachDevTools(const WebString& hostId) |
| 435 { | 435 { |
| 436 attachDevTools(); | 436 WebDevToolsAgent* devtoolsAgent = m_webView->devToolsAgent(); |
| 437 } | 437 if (devtoolsAgent) |
| 438 | 438 devtoolsAgent->attach(hostId); |
| 439 static void reconnectToWorkerContextInspectorTask(ExecutionContext* context, con st String& savedState) | |
| 440 { | |
| 441 WorkerInspectorController* ic = toWorkerGlobalScope(context)->workerInspecto rController(); | |
| 442 ic->restoreInspectorStateFromCookie(savedState); | |
| 443 ic->resume(); | |
| 444 } | |
| 445 | |
| 446 void WebSharedWorkerImpl::reattachDevTools(const WebString& savedState) | |
| 447 { | |
| 448 workerThread()->postDebuggerTask(createCrossThreadTask(reconnectToWorkerCont extInspectorTask, String(savedState))); | |
| 449 } | 439 } |
| 450 | 440 |
| 451 void WebSharedWorkerImpl::reattachDevTools(const WebString& hostId, const WebStr ing& savedState) | 441 void WebSharedWorkerImpl::reattachDevTools(const WebString& hostId, const WebStr ing& savedState) |
| 452 { | 442 { |
| 453 reattachDevTools(savedState); | 443 WebDevToolsAgent* devtoolsAgent = m_webView->devToolsAgent(); |
| 454 } | 444 if (devtoolsAgent) |
| 455 | 445 devtoolsAgent->reattach(hostId, savedState); |
| 456 static void disconnectFromWorkerContextInspectorTask(ExecutionContext* context, bool) | |
| 457 { | |
| 458 toWorkerGlobalScope(context)->workerInspectorController()->disconnectFronten d(); | |
| 459 } | 446 } |
| 460 | 447 |
| 461 void WebSharedWorkerImpl::detachDevTools() | 448 void WebSharedWorkerImpl::detachDevTools() |
| 462 { | 449 { |
| 463 m_attachDevToolsOnStart = false; | 450 WebDevToolsAgent* devtoolsAgent = m_webView->devToolsAgent(); |
| 464 workerThread()->postDebuggerTask(createCrossThreadTask(disconnectFromWorkerC ontextInspectorTask, true)); | 451 if (devtoolsAgent) |
| 465 } | 452 devtoolsAgent->detach(); |
| 466 | |
| 467 static void dispatchOnInspectorBackendTask(ExecutionContext* context, const Stri ng& message) | |
| 468 { | |
| 469 toWorkerGlobalScope(context)->workerInspectorController()->dispatchMessageFr omFrontend(message); | |
| 470 } | 453 } |
| 471 | 454 |
| 472 void WebSharedWorkerImpl::dispatchDevToolsMessage(const WebString& message) | 455 void WebSharedWorkerImpl::dispatchDevToolsMessage(const WebString& message) |
| 473 { | 456 { |
| 474 if (m_askedToTerminate) | 457 if (m_askedToTerminate) |
| 475 return; | 458 return; |
| 476 workerThread()->postDebuggerTask(createCrossThreadTask(dispatchOnInspectorBa ckendTask, String(message))); | 459 WebDevToolsAgent* devtoolsAgent = m_webView->devToolsAgent(); |
| 477 workerThread()->interruptAndDispatchInspectorCommands(); | 460 if (devtoolsAgent) |
| 461 devtoolsAgent->dispatchOnInspectorBackend(message); | |
| 478 } | 462 } |
| 479 | 463 |
| 480 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) | 464 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) |
| 481 { | 465 { |
| 482 return new WebSharedWorkerImpl(client); | 466 return new WebSharedWorkerImpl(client); |
| 483 } | 467 } |
| 484 | 468 |
| 485 } // namespace blink | 469 } // namespace blink |
| OLD | NEW |