| 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/embedded_worker_instance.h" | 5 #include "content/browser/service_worker/embedded_worker_instance.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/threading/non_thread_safe.h" | |
| 14 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 15 #include "content/browser/bad_message.h" | 14 #include "content/browser/bad_message.h" |
| 16 #include "content/browser/devtools/service_worker_devtools_manager.h" | 15 #include "content/browser/devtools/service_worker_devtools_manager.h" |
| 17 #include "content/browser/service_worker/embedded_worker_registry.h" | 16 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 18 #include "content/browser/service_worker/embedded_worker_status.h" | 17 #include "content/browser/service_worker/embedded_worker_status.h" |
| 19 #include "content/browser/service_worker/service_worker_context_core.h" | 18 #include "content/browser/service_worker/service_worker_context_core.h" |
| 20 #include "content/common/content_switches_internal.h" | 19 #include "content/common/content_switches_internal.h" |
| 21 #include "content/common/service_worker/embedded_worker_messages.h" | 20 #include "content/common/service_worker/embedded_worker_messages.h" |
| 22 #include "content/common/service_worker/embedded_worker_settings.h" | 21 #include "content/common/service_worker/embedded_worker_settings.h" |
| 23 #include "content/common/service_worker/embedded_worker_start_params.h" | 22 #include "content/common/service_worker/embedded_worker_start_params.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 72 |
| 74 void SetupOnUI( | 73 void SetupOnUI( |
| 75 int process_id, | 74 int process_id, |
| 76 const ServiceWorkerContextCore* service_worker_context, | 75 const ServiceWorkerContextCore* service_worker_context, |
| 77 const base::WeakPtr<ServiceWorkerContextCore>& service_worker_context_weak, | 76 const base::WeakPtr<ServiceWorkerContextCore>& service_worker_context_weak, |
| 78 int64_t service_worker_version_id, | 77 int64_t service_worker_version_id, |
| 79 const GURL& url, | 78 const GURL& url, |
| 80 const GURL& scope, | 79 const GURL& scope, |
| 81 bool is_installed, | 80 bool is_installed, |
| 82 mojom::EmbeddedWorkerInstanceClientRequest request, | 81 mojom::EmbeddedWorkerInstanceClientRequest request, |
| 83 const base::Callback<void(int worker_devtools_agent_route_id, | 82 const base::Callback< |
| 84 bool wait_for_debugger)>& callback) { | 83 void(std::unique_ptr<EmbeddedWorkerInstance::DevToolsProxy>, |
| 84 bool wait_for_debugger)>& callback) { |
| 85 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 85 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 86 std::unique_ptr<EmbeddedWorkerInstance::DevToolsProxy> devtools_proxy; |
| 86 int worker_devtools_agent_route_id = MSG_ROUTING_NONE; | 87 int worker_devtools_agent_route_id = MSG_ROUTING_NONE; |
| 87 bool wait_for_debugger = false; | 88 bool wait_for_debugger = false; |
| 88 if (RenderProcessHost* rph = RenderProcessHost::FromID(process_id)) { | 89 if (RenderProcessHost* rph = RenderProcessHost::FromID(process_id)) { |
| 89 // |rph| may be NULL in unit tests. | 90 // |rph| may be NULL in unit tests. |
| 90 worker_devtools_agent_route_id = rph->GetNextRoutingID(); | 91 worker_devtools_agent_route_id = rph->GetNextRoutingID(); |
| 91 wait_for_debugger = | 92 wait_for_debugger = |
| 92 ServiceWorkerDevToolsManager::GetInstance()->WorkerCreated( | 93 ServiceWorkerDevToolsManager::GetInstance()->WorkerCreated( |
| 93 process_id, worker_devtools_agent_route_id, | 94 process_id, worker_devtools_agent_route_id, |
| 94 ServiceWorkerDevToolsManager::ServiceWorkerIdentifier( | 95 ServiceWorkerDevToolsManager::ServiceWorkerIdentifier( |
| 95 service_worker_context, service_worker_context_weak, | 96 service_worker_context, service_worker_context_weak, |
| 96 service_worker_version_id, url, scope), | 97 service_worker_version_id, url, scope), |
| 97 is_installed); | 98 is_installed); |
| 98 if (request.is_pending()) | 99 if (request.is_pending()) |
| 99 BindInterface(rph, std::move(request)); | 100 BindInterface(rph, std::move(request)); |
| 101 devtools_proxy = base::MakeUnique<EmbeddedWorkerInstance::DevToolsProxy>( |
| 102 process_id, worker_devtools_agent_route_id); |
| 100 } | 103 } |
| 101 BrowserThread::PostTask( | 104 BrowserThread::PostTask( |
| 102 BrowserThread::IO, | 105 BrowserThread::IO, FROM_HERE, |
| 103 FROM_HERE, | 106 base::Bind(callback, base::Passed(&devtools_proxy), wait_for_debugger)); |
| 104 base::Bind(callback, worker_devtools_agent_route_id, wait_for_debugger)); | |
| 105 } | 107 } |
| 106 | 108 |
| 107 void CallDetach(EmbeddedWorkerInstance* instance) { | 109 void CallDetach(EmbeddedWorkerInstance* instance) { |
| 108 // This could be called on the UI thread if |client_| still be valid when the | 110 // This could be called on the UI thread if |client_| still be valid when the |
| 109 // message loop on the UI thread gets destructed. | 111 // message loop on the UI thread gets destructed. |
| 110 // TODO(shimazu): Remove this after https://crbug.com/604762 is fixed | 112 // TODO(shimazu): Remove this after https://crbug.com/604762 is fixed |
| 111 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 113 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 112 DCHECK(ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()); | 114 DCHECK(ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()); |
| 113 return; | 115 return; |
| 114 } | 116 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 130 case EmbeddedWorkerInstance::THREAD_STARTED: | 132 case EmbeddedWorkerInstance::THREAD_STARTED: |
| 131 return true; | 133 return true; |
| 132 case EmbeddedWorkerInstance::STARTING_PHASE_MAX_VALUE: | 134 case EmbeddedWorkerInstance::STARTING_PHASE_MAX_VALUE: |
| 133 NOTREACHED(); | 135 NOTREACHED(); |
| 134 } | 136 } |
| 135 return false; | 137 return false; |
| 136 } | 138 } |
| 137 | 139 |
| 138 } // namespace | 140 } // namespace |
| 139 | 141 |
| 140 // Lives on IO thread, proxies notifications to DevToolsManager that lives on | 142 // Created on UI thread and moved to IO thread. Proxies notifications to |
| 141 // UI thread. Owned by EmbeddedWorkerInstance. | 143 // DevToolsManager that lives on UI thread. Owned by EmbeddedWorkerInstance. |
| 142 class EmbeddedWorkerInstance::DevToolsProxy : public base::NonThreadSafe { | 144 class EmbeddedWorkerInstance::DevToolsProxy { |
| 143 public: | 145 public: |
| 144 DevToolsProxy(int process_id, int agent_route_id) | 146 DevToolsProxy(int process_id, int agent_route_id) |
| 145 : process_id_(process_id), | 147 : process_id_(process_id), |
| 146 agent_route_id_(agent_route_id) {} | 148 agent_route_id_(agent_route_id) {} |
| 147 | 149 |
| 148 ~DevToolsProxy() { | 150 ~DevToolsProxy() { |
| 151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 149 BrowserThread::PostTask( | 152 BrowserThread::PostTask( |
| 150 BrowserThread::UI, | 153 BrowserThread::UI, |
| 151 FROM_HERE, | 154 FROM_HERE, |
| 152 base::Bind(NotifyWorkerDestroyedOnUI, | 155 base::Bind(NotifyWorkerDestroyedOnUI, |
| 153 process_id_, agent_route_id_)); | 156 process_id_, agent_route_id_)); |
| 154 } | 157 } |
| 155 | 158 |
| 156 void NotifyWorkerReadyForInspection() { | 159 void NotifyWorkerReadyForInspection() { |
| 157 DCHECK(CalledOnValidThread()); | 160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 158 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 161 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 159 base::Bind(NotifyWorkerReadyForInspectionOnUI, | 162 base::Bind(NotifyWorkerReadyForInspectionOnUI, |
| 160 process_id_, agent_route_id_)); | 163 process_id_, agent_route_id_)); |
| 161 } | 164 } |
| 162 | 165 |
| 163 void NotifyWorkerVersionInstalled() { | 166 void NotifyWorkerVersionInstalled() { |
| 164 DCHECK(CalledOnValidThread()); | 167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 165 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 168 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 166 base::Bind(NotifyWorkerVersionInstalledOnUI, | 169 base::Bind(NotifyWorkerVersionInstalledOnUI, |
| 167 process_id_, agent_route_id_)); | 170 process_id_, agent_route_id_)); |
| 168 } | 171 } |
| 169 | 172 |
| 170 void NotifyWorkerVersionDoomed() { | 173 void NotifyWorkerVersionDoomed() { |
| 171 DCHECK(CalledOnValidThread()); | 174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 172 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 175 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 173 base::Bind(NotifyWorkerVersionDoomedOnUI, | 176 base::Bind(NotifyWorkerVersionDoomedOnUI, |
| 174 process_id_, agent_route_id_)); | 177 process_id_, agent_route_id_)); |
| 175 } | 178 } |
| 176 | 179 |
| 177 bool ShouldNotifyWorkerStopIgnored() const { | 180 bool ShouldNotifyWorkerStopIgnored() const { |
| 178 return !worker_stop_ignored_notified_; | 181 return !worker_stop_ignored_notified_; |
| 179 } | 182 } |
| 180 | 183 |
| 181 void WorkerStopIgnoredNotified() { worker_stop_ignored_notified_ = true; } | 184 void WorkerStopIgnoredNotified() { worker_stop_ignored_notified_ = true; } |
| 182 | 185 |
| 183 int agent_route_id() const { return agent_route_id_; } | 186 int agent_route_id() const { return agent_route_id_; } |
| 184 | 187 |
| 185 private: | 188 private: |
| 186 const int process_id_; | 189 const int process_id_; |
| 187 const int agent_route_id_; | 190 const int agent_route_id_; |
| 188 bool worker_stop_ignored_notified_ = false; | 191 bool worker_stop_ignored_notified_ = false; |
| 192 |
| 189 DISALLOW_COPY_AND_ASSIGN(DevToolsProxy); | 193 DISALLOW_COPY_AND_ASSIGN(DevToolsProxy); |
| 190 }; | 194 }; |
| 191 | 195 |
| 192 // A handle for a worker process managed by ServiceWorkerProcessManager on the | 196 // A handle for a worker process managed by ServiceWorkerProcessManager on the |
| 193 // UI thread. | 197 // UI thread. |
| 194 class EmbeddedWorkerInstance::WorkerProcessHandle { | 198 class EmbeddedWorkerInstance::WorkerProcessHandle { |
| 195 public: | 199 public: |
| 196 WorkerProcessHandle(const base::WeakPtr<ServiceWorkerContextCore>& context, | 200 WorkerProcessHandle(const base::WeakPtr<ServiceWorkerContextCore>& context, |
| 197 int embedded_worker_id, | 201 int embedded_worker_id, |
| 198 int process_id, | 202 int process_id, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 started_during_browser_startup_(false), | 245 started_during_browser_startup_(false), |
| 242 weak_factory_(this) { | 246 weak_factory_(this) { |
| 243 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", "EmbeddedWorkerInstance::Start", | 247 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", "EmbeddedWorkerInstance::Start", |
| 244 this, "Script", script_url.spec()); | 248 this, "Script", script_url.spec()); |
| 245 } | 249 } |
| 246 | 250 |
| 247 ~StartTask() { | 251 ~StartTask() { |
| 248 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 252 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 249 TRACE_EVENT_ASYNC_END0("ServiceWorker", "EmbeddedWorkerInstance::Start", | 253 TRACE_EVENT_ASYNC_END0("ServiceWorker", "EmbeddedWorkerInstance::Start", |
| 250 this); | 254 this); |
| 251 | |
| 252 if (!instance_->context_) | 255 if (!instance_->context_) |
| 253 return; | 256 return; |
| 254 | 257 |
| 255 switch (state_) { | 258 switch (state_) { |
| 256 case ProcessAllocationState::NOT_ALLOCATED: | 259 case ProcessAllocationState::NOT_ALLOCATED: |
| 257 // Not necessary to release a process. | 260 // Not necessary to release a process. |
| 258 break; | 261 break; |
| 259 case ProcessAllocationState::ALLOCATING: | 262 case ProcessAllocationState::ALLOCATING: |
| 260 // Abort half-baked process allocation on the UI thread. | 263 // Abort half-baked process allocation on the UI thread. |
| 261 instance_->context_->process_manager()->ReleaseWorkerProcess( | 264 instance_->context_->process_manager()->ReleaseWorkerProcess( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 BrowserThread::PostTask( | 368 BrowserThread::PostTask( |
| 366 BrowserThread::UI, FROM_HERE, | 369 BrowserThread::UI, FROM_HERE, |
| 367 base::Bind(&SetupOnUI, process_id, instance_->context_.get(), | 370 base::Bind(&SetupOnUI, process_id, instance_->context_.get(), |
| 368 instance_->context_, service_worker_version_id, script_url, | 371 instance_->context_, service_worker_version_id, script_url, |
| 369 scope, is_installed_, base::Passed(&request_), | 372 scope, is_installed_, base::Passed(&request_), |
| 370 base::Bind(&StartTask::OnSetupOnUICompleted, | 373 base::Bind(&StartTask::OnSetupOnUICompleted, |
| 371 weak_factory_.GetWeakPtr(), base::Passed(¶ms), | 374 weak_factory_.GetWeakPtr(), base::Passed(¶ms), |
| 372 is_new_process))); | 375 is_new_process))); |
| 373 } | 376 } |
| 374 | 377 |
| 375 void OnSetupOnUICompleted(std::unique_ptr<EmbeddedWorkerStartParams> params, | 378 void OnSetupOnUICompleted( |
| 376 bool is_new_process, | 379 std::unique_ptr<EmbeddedWorkerStartParams> params, |
| 377 int worker_devtools_agent_route_id, | 380 bool is_new_process, |
| 378 bool wait_for_debugger) { | 381 std::unique_ptr<EmbeddedWorkerInstance::DevToolsProxy> devtools_proxy, |
| 382 bool wait_for_debugger) { |
| 379 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 383 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 380 TRACE_EVENT_ASYNC_STEP_PAST0("ServiceWorker", | 384 TRACE_EVENT_ASYNC_STEP_PAST0("ServiceWorker", |
| 381 "EmbeddedWorkerInstance::Start", this, | 385 "EmbeddedWorkerInstance::Start", this, |
| 382 "OnSetupOnUICompleted"); | 386 "OnSetupOnUICompleted"); |
| 383 | 387 |
| 388 params->worker_devtools_agent_route_id = devtools_proxy->agent_route_id(); |
| 389 params->wait_for_debugger = wait_for_debugger; |
| 390 |
| 384 // Notify the instance that it is registered to the devtools manager. | 391 // Notify the instance that it is registered to the devtools manager. |
| 385 instance_->OnRegisteredToDevToolsManager( | 392 instance_->OnRegisteredToDevToolsManager( |
| 386 is_new_process, worker_devtools_agent_route_id, wait_for_debugger); | 393 is_new_process, std::move(devtools_proxy), wait_for_debugger); |
| 387 | |
| 388 params->worker_devtools_agent_route_id = worker_devtools_agent_route_id; | |
| 389 params->wait_for_debugger = wait_for_debugger; | |
| 390 | 394 |
| 391 ServiceWorkerStatusCode status = | 395 ServiceWorkerStatusCode status = |
| 392 instance_->SendStartWorker(std::move(params)); | 396 instance_->SendStartWorker(std::move(params)); |
| 393 if (status != SERVICE_WORKER_OK) { | 397 if (status != SERVICE_WORKER_OK) { |
| 394 StatusCallback callback = start_callback_; | 398 StatusCallback callback = start_callback_; |
| 395 start_callback_.Reset(); | 399 start_callback_.Reset(); |
| 396 instance_->OnStartFailed(callback, status); | 400 instance_->OnStartFailed(callback, status); |
| 397 // |this| may be destroyed. | 401 // |this| may be destroyed. |
| 398 } | 402 } |
| 399 } | 403 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 } | 475 } |
| 472 | 476 |
| 473 bool EmbeddedWorkerInstance::Stop() { | 477 bool EmbeddedWorkerInstance::Stop() { |
| 474 DCHECK(status_ == EmbeddedWorkerStatus::STARTING || | 478 DCHECK(status_ == EmbeddedWorkerStatus::STARTING || |
| 475 status_ == EmbeddedWorkerStatus::RUNNING) | 479 status_ == EmbeddedWorkerStatus::RUNNING) |
| 476 << static_cast<int>(status_); | 480 << static_cast<int>(status_); |
| 477 | 481 |
| 478 // Abort an inflight start task. | 482 // Abort an inflight start task. |
| 479 inflight_start_task_.reset(); | 483 inflight_start_task_.reset(); |
| 480 | 484 |
| 481 if (status_ == EmbeddedWorkerStatus::STARTING && | 485 if (status_ == EmbeddedWorkerStatus::STARTING && |
| 482 !HasSentStartWorker(starting_phase())) { | 486 !HasSentStartWorker(starting_phase())) { |
| 483 // Don't send the StopWorker message when the StartWorker message hasn't | 487 // Don't send the StopWorker message when the StartWorker message hasn't |
| 484 // been sent. | 488 // been sent. |
| 485 // TODO(shimazu): Invoke OnStopping/OnStopped after the legacy IPC path is | 489 // TODO(shimazu): Invoke OnStopping/OnStopped after the legacy IPC path is |
| 486 // removed. | 490 // removed. |
| 487 OnDetached(); | 491 OnDetached(); |
| 488 return false; | 492 return false; |
| 489 } | 493 } |
| 490 client_->StopWorker(); | 494 client_->StopWorker(); |
| 491 | 495 |
| 492 status_ = EmbeddedWorkerStatus::STOPPING; | 496 status_ = EmbeddedWorkerStatus::STOPPING; |
| 493 for (auto& observer : listener_list_) | 497 for (auto& observer : listener_list_) |
| 494 observer.OnStopping(); | 498 observer.OnStopping(); |
| 495 return true; | 499 return true; |
| 496 } | 500 } |
| 497 | 501 |
| 498 void EmbeddedWorkerInstance::StopIfIdle() { | 502 void EmbeddedWorkerInstance::StopIfIdle() { |
| 499 if (devtools_attached_) { | 503 if (devtools_attached_) { |
| 500 if (devtools_proxy_) { | 504 if (devtools_proxy_) { |
| 501 // Check ShouldNotifyWorkerStopIgnored not to show the same message | 505 // Check ShouldNotifyWorkerStopIgnored not to show the same message |
| 502 // multiple times in DevTools. | 506 // multiple times in DevTools. |
| 503 if (devtools_proxy_->ShouldNotifyWorkerStopIgnored()) { | 507 if (devtools_proxy_->ShouldNotifyWorkerStopIgnored()) { |
| 504 AddMessageToConsole(blink::WebConsoleMessage::kLevelVerbose, | 508 AddMessageToConsole(blink::WebConsoleMessage::kLevelVerbose, |
| 505 kServiceWorkerTerminationCanceledMesage); | 509 kServiceWorkerTerminationCanceledMesage); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 | 559 |
| 556 process_handle_ = std::move(handle); | 560 process_handle_ = std::move(handle); |
| 557 starting_phase_ = REGISTERING_TO_DEVTOOLS; | 561 starting_phase_ = REGISTERING_TO_DEVTOOLS; |
| 558 start_situation_ = start_situation; | 562 start_situation_ = start_situation; |
| 559 for (auto& observer : listener_list_) | 563 for (auto& observer : listener_list_) |
| 560 observer.OnProcessAllocated(); | 564 observer.OnProcessAllocated(); |
| 561 } | 565 } |
| 562 | 566 |
| 563 void EmbeddedWorkerInstance::OnRegisteredToDevToolsManager( | 567 void EmbeddedWorkerInstance::OnRegisteredToDevToolsManager( |
| 564 bool is_new_process, | 568 bool is_new_process, |
| 565 int worker_devtools_agent_route_id, | 569 std::unique_ptr<DevToolsProxy> devtools_proxy, |
| 566 bool wait_for_debugger) { | 570 bool wait_for_debugger) { |
| 567 if (worker_devtools_agent_route_id != MSG_ROUTING_NONE) { | 571 if (devtools_proxy) { |
| 568 DCHECK(!devtools_proxy_); | 572 DCHECK(!devtools_proxy_); |
| 569 devtools_proxy_.reset( | 573 devtools_proxy_ = std::move(devtools_proxy); |
| 570 new DevToolsProxy(process_id(), worker_devtools_agent_route_id)); | |
| 571 } | 574 } |
| 572 if (wait_for_debugger) { | 575 if (wait_for_debugger) { |
| 573 // We don't measure the start time when wait_for_debugger flag is set. So | 576 // We don't measure the start time when wait_for_debugger flag is set. So |
| 574 // we set the NULL time here. | 577 // we set the NULL time here. |
| 575 step_time_ = base::TimeTicks(); | 578 step_time_ = base::TimeTicks(); |
| 576 } | 579 } |
| 577 for (auto& observer : listener_list_) | 580 for (auto& observer : listener_list_) |
| 578 observer.OnRegisteredToDevToolsManager(); | 581 observer.OnRegisteredToDevToolsManager(); |
| 579 } | 582 } |
| 580 | 583 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 void EmbeddedWorkerInstance::OnScriptReadStarted() { | 623 void EmbeddedWorkerInstance::OnScriptReadStarted() { |
| 621 starting_phase_ = SCRIPT_READ_STARTED; | 624 starting_phase_ = SCRIPT_READ_STARTED; |
| 622 } | 625 } |
| 623 | 626 |
| 624 void EmbeddedWorkerInstance::OnScriptReadFinished() { | 627 void EmbeddedWorkerInstance::OnScriptReadFinished() { |
| 625 starting_phase_ = SCRIPT_READ_FINISHED; | 628 starting_phase_ = SCRIPT_READ_FINISHED; |
| 626 } | 629 } |
| 627 | 630 |
| 628 void EmbeddedWorkerInstance::OnScriptLoaded() { | 631 void EmbeddedWorkerInstance::OnScriptLoaded() { |
| 629 using LoadSource = ServiceWorkerMetrics::LoadSource; | 632 using LoadSource = ServiceWorkerMetrics::LoadSource; |
| 630 | |
| 631 TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerInstance::OnScriptLoaded"); | 633 TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerInstance::OnScriptLoaded"); |
| 632 | 634 |
| 633 if (!inflight_start_task_) | 635 if (!inflight_start_task_) |
| 634 return; | 636 return; |
| 635 LoadSource source; | 637 LoadSource source; |
| 636 if (network_accessed_for_script_) { | 638 if (network_accessed_for_script_) { |
| 637 DCHECK(!inflight_start_task_->is_installed()); | 639 DCHECK(!inflight_start_task_->is_installed()); |
| 638 source = LoadSource::NETWORK; | 640 source = LoadSource::NETWORK; |
| 639 } else if (inflight_start_task_->is_installed()) { | 641 } else if (inflight_start_task_->is_installed()) { |
| 640 source = LoadSource::SERVICE_WORKER_STORAGE; | 642 source = LoadSource::SERVICE_WORKER_STORAGE; |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 case SCRIPT_READ_FINISHED: | 939 case SCRIPT_READ_FINISHED: |
| 938 return "Script read finished"; | 940 return "Script read finished"; |
| 939 case STARTING_PHASE_MAX_VALUE: | 941 case STARTING_PHASE_MAX_VALUE: |
| 940 NOTREACHED(); | 942 NOTREACHED(); |
| 941 } | 943 } |
| 942 NOTREACHED() << phase; | 944 NOTREACHED() << phase; |
| 943 return std::string(); | 945 return std::string(); |
| 944 } | 946 } |
| 945 | 947 |
| 946 } // namespace content | 948 } // namespace content |
| OLD | NEW |