OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 } | 322 } |
323 | 323 |
324 void WebEmbeddedWorkerImpl::DidFinishDocumentLoad(WebLocalFrame* frame) { | 324 void WebEmbeddedWorkerImpl::DidFinishDocumentLoad(WebLocalFrame* frame) { |
325 DCHECK_EQ(frame, main_frame_); | 325 DCHECK_EQ(frame, main_frame_); |
326 DCHECK(!main_script_loader_); | 326 DCHECK(!main_script_loader_); |
327 DCHECK(main_frame_); | 327 DCHECK(main_frame_); |
328 DCHECK(worker_context_client_); | 328 DCHECK(worker_context_client_); |
329 DCHECK(loading_shadow_page_); | 329 DCHECK(loading_shadow_page_); |
330 DCHECK(!asked_to_terminate_); | 330 DCHECK(!asked_to_terminate_); |
331 loading_shadow_page_ = false; | 331 loading_shadow_page_ = false; |
332 frame->DataSource()->SetServiceWorkerNetworkProvider(WTF::WrapUnique( | 332 frame->DataSource()->SetServiceWorkerNetworkProvider( |
333 worker_context_client_->CreateServiceWorkerNetworkProvider())); | 333 worker_context_client_->CreateServiceWorkerNetworkProvider()); |
334 main_script_loader_ = WorkerScriptLoader::Create(); | 334 main_script_loader_ = WorkerScriptLoader::Create(); |
335 main_script_loader_->SetRequestContext( | 335 main_script_loader_->SetRequestContext( |
336 WebURLRequest::kRequestContextServiceWorker); | 336 WebURLRequest::kRequestContextServiceWorker); |
337 main_script_loader_->LoadAsynchronously( | 337 main_script_loader_->LoadAsynchronously( |
338 *main_frame_->GetFrame()->GetDocument(), worker_start_data_.script_url, | 338 *main_frame_->GetFrame()->GetDocument(), worker_start_data_.script_url, |
339 kDenyCrossOriginRequests, worker_start_data_.address_space, nullptr, | 339 kDenyCrossOriginRequests, worker_start_data_.address_space, nullptr, |
340 Bind(&WebEmbeddedWorkerImpl::OnScriptLoaderFinished, | 340 Bind(&WebEmbeddedWorkerImpl::OnScriptLoaderFinished, |
341 WTF::Unretained(this))); | 341 WTF::Unretained(this))); |
342 // Do nothing here since onScriptLoaderFinished() might have been already | 342 // Do nothing here since onScriptLoaderFinished() might have been already |
343 // invoked and |this| might have been deleted at this point. | 343 // invoked and |this| might have been deleted at this point. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 | 412 |
413 WorkerClients* worker_clients = WorkerClients::Create(); | 413 WorkerClients* worker_clients = WorkerClients::Create(); |
414 ProvideContentSettingsClientToWorker(worker_clients, | 414 ProvideContentSettingsClientToWorker(worker_clients, |
415 std::move(content_settings_client_)); | 415 std::move(content_settings_client_)); |
416 ProvideIndexedDBClientToWorker(worker_clients, | 416 ProvideIndexedDBClientToWorker(worker_clients, |
417 IndexedDBClientImpl::Create(*worker_clients)); | 417 IndexedDBClientImpl::Create(*worker_clients)); |
418 ProvideServiceWorkerGlobalScopeClientToWorker( | 418 ProvideServiceWorkerGlobalScopeClientToWorker( |
419 worker_clients, | 419 worker_clients, |
420 ServiceWorkerGlobalScopeClientImpl::Create(*worker_context_client_)); | 420 ServiceWorkerGlobalScopeClientImpl::Create(*worker_context_client_)); |
421 ProvideServiceWorkerContainerClientToWorker( | 421 ProvideServiceWorkerContainerClientToWorker( |
422 worker_clients, | 422 worker_clients, worker_context_client_->CreateServiceWorkerProvider()); |
423 WTF::WrapUnique(worker_context_client_->CreateServiceWorkerProvider())); | |
424 | 423 |
425 if (RuntimeEnabledFeatures::offMainThreadFetchEnabled()) { | 424 if (RuntimeEnabledFeatures::offMainThreadFetchEnabled()) { |
426 std::unique_ptr<WebWorkerFetchContext> web_worker_fetch_context = | 425 std::unique_ptr<WebWorkerFetchContext> web_worker_fetch_context = |
427 | |
428 worker_context_client_->CreateServiceWorkerFetchContext(); | 426 worker_context_client_->CreateServiceWorkerFetchContext(); |
429 DCHECK(web_worker_fetch_context); | 427 DCHECK(web_worker_fetch_context); |
430 // TODO(horo): Set more information about the context (ex: DataSaverEnabled) | 428 // TODO(horo): Set more information about the context (ex: DataSaverEnabled) |
431 // to |web_worker_fetch_context|. | 429 // to |web_worker_fetch_context|. |
432 ProvideWorkerFetchContextToWorker(worker_clients, | 430 ProvideWorkerFetchContextToWorker(worker_clients, |
433 std::move(web_worker_fetch_context)); | 431 std::move(web_worker_fetch_context)); |
434 } | 432 } |
435 | 433 |
436 // We need to set the CSP to both the shadow page's document and the | 434 // We need to set the CSP to both the shadow page's document and the |
437 // ServiceWorkerGlobalScope. | 435 // ServiceWorkerGlobalScope. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 // populate the task runners with null document not to confuse the frame | 474 // populate the task runners with null document not to confuse the frame |
477 // scheduler (which will end up using the thread's default task runner). | 475 // scheduler (which will end up using the thread's default task runner). |
478 worker_thread_->Start(std::move(startup_data), | 476 worker_thread_->Start(std::move(startup_data), |
479 ParentFrameTaskRunners::Create(nullptr)); | 477 ParentFrameTaskRunners::Create(nullptr)); |
480 | 478 |
481 worker_inspector_proxy_->WorkerThreadCreated(document, worker_thread_.get(), | 479 worker_inspector_proxy_->WorkerThreadCreated(document, worker_thread_.get(), |
482 script_url); | 480 script_url); |
483 } | 481 } |
484 | 482 |
485 } // namespace blink | 483 } // namespace blink |
OLD | NEW |