OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/service_worker/service_worker_version.h" | 5 #include "content/browser/service_worker/service_worker_version.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <map> | 10 #include <map> |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
840 ServiceWorkerMetrics::EventType event_type) | 840 ServiceWorkerMetrics::EventType event_type) |
841 : error_callback(callback), | 841 : error_callback(callback), |
842 start_time(time), | 842 start_time(time), |
843 start_time_ticks(time_ticks), | 843 start_time_ticks(time_ticks), |
844 event_type(event_type) {} | 844 event_type(event_type) {} |
845 | 845 |
846 ServiceWorkerVersion::PendingRequest::~PendingRequest() {} | 846 ServiceWorkerVersion::PendingRequest::~PendingRequest() {} |
847 | 847 |
848 void ServiceWorkerVersion::OnThreadStarted() { | 848 void ServiceWorkerVersion::OnThreadStarted() { |
849 DCHECK_EQ(EmbeddedWorkerStatus::STARTING, running_status()); | 849 DCHECK_EQ(EmbeddedWorkerStatus::STARTING, running_status()); |
850 DCHECK(provider_host_); | |
851 provider_host_->SetReadyToSendMessagesToWorker( | |
852 embedded_worker()->thread_id()); | |
850 // Activate ping/pong now that JavaScript execution will start. | 853 // Activate ping/pong now that JavaScript execution will start. |
851 ping_controller_->Activate(); | 854 ping_controller_->Activate(); |
852 } | 855 } |
853 | 856 |
854 void ServiceWorkerVersion::OnStarting() { | 857 void ServiceWorkerVersion::OnStarting() { |
855 for (auto& observer : listeners_) | 858 for (auto& observer : listeners_) |
856 observer.OnRunningStateChanged(this); | 859 observer.OnRunningStateChanged(this); |
857 } | 860 } |
858 | 861 |
862 void ServiceWorkerVersion::OnStartWorkerMessageSent() { | |
863 DCHECK(pending_provider_host_); | |
864 context()->AddProviderHost(std::move(pending_provider_host_)); | |
kinuko
2017/06/14 08:37:40
I have a feeling that SetHostedVersion should be c
shimazu
2017/06/16 04:18:44
That's good point...
I tried to fix it by
- movi
| |
865 } | |
866 | |
859 void ServiceWorkerVersion::OnStarted() { | 867 void ServiceWorkerVersion::OnStarted() { |
860 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, running_status()); | 868 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, running_status()); |
861 RestartTick(&idle_time_); | 869 RestartTick(&idle_time_); |
862 | 870 |
863 // Fire all start callbacks. | 871 // Fire all start callbacks. |
864 scoped_refptr<ServiceWorkerVersion> protect(this); | 872 scoped_refptr<ServiceWorkerVersion> protect(this); |
865 FinishStartWorker(SERVICE_WORKER_OK); | 873 FinishStartWorker(SERVICE_WORKER_OK); |
866 for (auto& observer : listeners_) | 874 for (auto& observer : listeners_) |
867 observer.OnRunningStateChanged(this); | 875 observer.OnRunningStateChanged(this); |
868 } | 876 } |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1459 DCHECK_EQ(EmbeddedWorkerStatus::STOPPED, running_status()); | 1467 DCHECK_EQ(EmbeddedWorkerStatus::STOPPED, running_status()); |
1460 | 1468 |
1461 if (!ServiceWorkerMetrics::ShouldExcludeSiteFromHistogram(site_for_uma_)) { | 1469 if (!ServiceWorkerMetrics::ShouldExcludeSiteFromHistogram(site_for_uma_)) { |
1462 DCHECK(!event_recorder_); | 1470 DCHECK(!event_recorder_); |
1463 event_recorder_ = | 1471 event_recorder_ = |
1464 base::MakeUnique<ServiceWorkerMetrics::ScopedEventRecorder>(); | 1472 base::MakeUnique<ServiceWorkerMetrics::ScopedEventRecorder>(); |
1465 } | 1473 } |
1466 | 1474 |
1467 StartTimeoutTimer(); | 1475 StartTimeoutTimer(); |
1468 | 1476 |
1477 DCHECK(!pending_provider_host_); | |
1478 pending_provider_host_ = | |
1479 ServiceWorkerProviderHost::PreCreateForWorkerContext(this, context()); | |
1480 provider_host_ = pending_provider_host_->AsWeakPtr(); | |
1481 | |
1469 auto params = base::MakeUnique<EmbeddedWorkerStartParams>(); | 1482 auto params = base::MakeUnique<EmbeddedWorkerStartParams>(); |
1470 params->service_worker_version_id = version_id_; | 1483 params->service_worker_version_id = version_id_; |
1471 params->scope = scope_; | 1484 params->scope = scope_; |
1472 params->script_url = script_url_; | 1485 params->script_url = script_url_; |
1473 params->is_installed = IsInstalled(status_); | 1486 params->is_installed = IsInstalled(status_); |
1474 params->pause_after_download = pause_after_download_; | 1487 params->pause_after_download = pause_after_download_; |
1475 | 1488 |
1476 embedded_worker_->Start( | 1489 embedded_worker_->Start( |
1477 std::move(params), mojo::MakeRequest(&event_dispatcher_), | 1490 std::move(params), pending_provider_host_->AsWeakPtr(), |
1491 mojo::MakeRequest(&event_dispatcher_), | |
1478 base::Bind(&ServiceWorkerVersion::OnStartSentAndScriptEvaluated, | 1492 base::Bind(&ServiceWorkerVersion::OnStartSentAndScriptEvaluated, |
1479 weak_factory_.GetWeakPtr())); | 1493 weak_factory_.GetWeakPtr())); |
1480 event_dispatcher_.set_connection_error_handler(base::Bind( | 1494 event_dispatcher_.set_connection_error_handler(base::Bind( |
1481 &OnEventDispatcherConnectionError, embedded_worker_->AsWeakPtr())); | 1495 &OnEventDispatcherConnectionError, embedded_worker_->AsWeakPtr())); |
1482 } | 1496 } |
1483 | 1497 |
1484 void ServiceWorkerVersion::StartTimeoutTimer() { | 1498 void ServiceWorkerVersion::StartTimeoutTimer() { |
1485 DCHECK(!timeout_timer_.IsRunning()); | 1499 DCHECK(!timeout_timer_.IsRunning()); |
1486 | 1500 |
1487 if (embedded_worker_->devtools_attached()) { | 1501 if (embedded_worker_->devtools_attached()) { |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1859 | 1873 |
1860 void ServiceWorkerVersion::CleanUpExternalRequest( | 1874 void ServiceWorkerVersion::CleanUpExternalRequest( |
1861 const std::string& request_uuid, | 1875 const std::string& request_uuid, |
1862 ServiceWorkerStatusCode status) { | 1876 ServiceWorkerStatusCode status) { |
1863 if (status == SERVICE_WORKER_OK) | 1877 if (status == SERVICE_WORKER_OK) |
1864 return; | 1878 return; |
1865 external_request_uuid_to_request_id_.erase(request_uuid); | 1879 external_request_uuid_to_request_id_.erase(request_uuid); |
1866 } | 1880 } |
1867 | 1881 |
1868 } // namespace content | 1882 } // namespace content |
OLD | NEW |