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