Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: content/browser/service_worker/embedded_worker_instance.cc

Issue 2606593002: [ServiceWorker] Associate interfaces.
Patch Set: Fix unit tests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 13 #include "base/threading/non_thread_safe.h"
14 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
15 #include "content/browser/devtools/service_worker_devtools_manager.h" 15 #include "content/browser/devtools/service_worker_devtools_manager.h"
16 #include "content/browser/service_worker/embedded_worker_registry.h" 16 #include "content/browser/service_worker/embedded_worker_registry.h"
17 #include "content/browser/service_worker/embedded_worker_status.h" 17 #include "content/browser/service_worker/embedded_worker_status.h"
18 #include "content/browser/service_worker/service_worker_context_core.h" 18 #include "content/browser/service_worker/service_worker_context_core.h"
19 #include "content/common/content_switches_internal.h" 19 #include "content/common/content_switches_internal.h"
20 #include "content/common/service_worker/embedded_worker_messages.h" 20 #include "content/common/service_worker/embedded_worker_messages.h"
21 #include "content/common/service_worker/embedded_worker_settings.h" 21 #include "content/common/service_worker/embedded_worker_settings.h"
22 #include "content/common/service_worker/embedded_worker_setup.mojom.h" 22 #include "content/common/service_worker/embedded_worker_setup.mojom.h"
23 #include "content/common/service_worker/embedded_worker_start_params.h" 23 #include "content/common/service_worker/embedded_worker_start_params.h"
24 #include "content/common/service_worker/service_worker_types.h" 24 #include "content/common/service_worker/service_worker_types.h"
25 #include "content/common/service_worker/service_worker_utils.h" 25 #include "content/common/service_worker/service_worker_utils.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/content_browser_client.h" 27 #include "content/public/browser/content_browser_client.h"
28 #include "content/public/browser/render_process_host.h" 28 #include "content/public/browser/render_process_host.h"
29 #include "content/public/common/associated_interface_provider.h"
29 #include "content/public/common/child_process_host.h" 30 #include "content/public/common/child_process_host.h"
30 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
31 #include "ipc/ipc_message.h" 32 #include "ipc/ipc_message.h"
32 #include "url/gurl.h" 33 #include "url/gurl.h"
33 34
34 namespace content { 35 namespace content {
35 36
36 namespace { 37 namespace {
37 38
38 // When a service worker version's failure count exceeds 39 // When a service worker version's failure count exceeds
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 72 }
72 73
73 void SetupOnUI( 74 void SetupOnUI(
74 int process_id, 75 int process_id,
75 const ServiceWorkerContextCore* service_worker_context, 76 const ServiceWorkerContextCore* service_worker_context,
76 const base::WeakPtr<ServiceWorkerContextCore>& service_worker_context_weak, 77 const base::WeakPtr<ServiceWorkerContextCore>& service_worker_context_weak,
77 int64_t service_worker_version_id, 78 int64_t service_worker_version_id,
78 const GURL& url, 79 const GURL& url,
79 const GURL& scope, 80 const GURL& scope,
80 bool is_installed, 81 bool is_installed,
81 mojom::EmbeddedWorkerInstanceClientRequest request, 82 const base::Callback<
82 const base::Callback<void(int worker_devtools_agent_route_id, 83 void(int worker_devtools_agent_route_id,
83 bool wait_for_debugger)>& callback) { 84 bool wait_for_debugger,
85 mojom::EmbeddedWorkerInstanceClientAssociatedPtrInfo ptr_info)>&
86 callback) {
84 DCHECK_CURRENTLY_ON(BrowserThread::UI); 87 DCHECK_CURRENTLY_ON(BrowserThread::UI);
85 int worker_devtools_agent_route_id = MSG_ROUTING_NONE; 88 int worker_devtools_agent_route_id = MSG_ROUTING_NONE;
86 bool wait_for_debugger = false; 89 bool wait_for_debugger = false;
90 mojom::EmbeddedWorkerInstanceClientAssociatedPtr client_ptr;
87 if (RenderProcessHost* rph = RenderProcessHost::FromID(process_id)) { 91 if (RenderProcessHost* rph = RenderProcessHost::FromID(process_id)) {
88 // |rph| may be NULL in unit tests. 92 // |rph| may be NULL in unit tests.
89 worker_devtools_agent_route_id = rph->GetNextRoutingID(); 93 worker_devtools_agent_route_id = rph->GetNextRoutingID();
90 wait_for_debugger = 94 wait_for_debugger =
91 ServiceWorkerDevToolsManager::GetInstance()->WorkerCreated( 95 ServiceWorkerDevToolsManager::GetInstance()->WorkerCreated(
92 process_id, worker_devtools_agent_route_id, 96 process_id, worker_devtools_agent_route_id,
93 ServiceWorkerDevToolsManager::ServiceWorkerIdentifier( 97 ServiceWorkerDevToolsManager::ServiceWorkerIdentifier(
94 service_worker_context, service_worker_context_weak, 98 service_worker_context, service_worker_context_weak,
95 service_worker_version_id, url, scope), 99 service_worker_version_id, url, scope),
96 is_installed); 100 is_installed);
97 if (request.is_pending()) 101
98 rph->GetRemoteInterfaces()->GetInterface(std::move(request)); 102 if (rph->GetChannel()) {
103 rph->GetChannel()->GetRemoteAssociatedInterface(&client_ptr);
104 } else {
105 // In unit tests we establish associated interface connections via
106 // MockRenderProcessHost.
107 DCHECK(rph->GetAssociatedInterfaceProviderForTesting());
108 rph->GetAssociatedInterfaceProviderForTesting()->GetInterface(
109 &client_ptr);
110 }
111 } else {
112 // No render process host, just connect to a dummy implementation to ensure
113 // client_ptr to be bound.
114 mojo::GetDummyProxyForTesting(&client_ptr);
99 } 115 }
100 BrowserThread::PostTask( 116 BrowserThread::PostTask(
101 BrowserThread::IO, 117 BrowserThread::IO, FROM_HERE,
102 FROM_HERE, 118 base::Bind(callback, worker_devtools_agent_route_id, wait_for_debugger,
103 base::Bind(callback, worker_devtools_agent_route_id, wait_for_debugger)); 119 base::Passed(client_ptr.PassInterface())));
104 } 120 }
105 121
106 void SetupEventDispatcherOnUIThread( 122 void SetupEventDispatcherOnUIThread(
107 int process_id, 123 int process_id,
108 int thread_id, 124 int thread_id,
109 mojom::ServiceWorkerEventDispatcherRequest request) { 125 mojom::ServiceWorkerEventDispatcherRequest request) {
110 DCHECK(!ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()); 126 DCHECK(!ServiceWorkerUtils::IsMojoForServiceWorkerEnabled());
111 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); 127 RenderProcessHost* rph = RenderProcessHost::FromID(process_id);
112 // |rph| or its InterfaceProvider may be NULL in unit tests. 128 // |rph| may be NULL in unit tests.
113 if (!rph || !rph->GetRemoteInterfaces()) 129 if (!rph)
114 return; 130 return;
115 mojom::EmbeddedWorkerSetupPtr setup; 131 mojom::EmbeddedWorkerSetupAssociatedPtr setup;
116 rph->GetRemoteInterfaces()->GetInterface(&setup); 132 if (rph->GetChannel()) {
133 rph->GetChannel()->GetRemoteAssociatedInterface(&setup);
134 } else {
135 // In unit tests we establish associated interface connections via
136 // MockRenderProcessHost.
137 DCHECK(rph->GetAssociatedInterfaceProviderForTesting());
138 rph->GetAssociatedInterfaceProviderForTesting()->GetInterface(&setup);
139 }
117 setup->AttachServiceWorkerEventDispatcher(thread_id, std::move(request)); 140 setup->AttachServiceWorkerEventDispatcher(thread_id, std::move(request));
118 } 141 }
119 142
120 void CallDetach(EmbeddedWorkerInstance* instance) { 143 void CallDetach(EmbeddedWorkerInstance* instance) {
121 // This could be called on the UI thread if |client_| still be valid when the 144 // This could be called on the UI thread if |client_| still be valid when the
122 // message loop on the UI thread gets destructed. 145 // message loop on the UI thread gets destructed.
123 // TODO(shimazu): Remove this after https://crbug.com/604762 is fixed 146 // TODO(shimazu): Remove this after https://crbug.com/604762 is fixed
124 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 147 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
125 DCHECK(ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()); 148 DCHECK(ServiceWorkerUtils::IsMojoForServiceWorkerEnabled());
126 return; 149 return;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 240
218 // A task to allocate a worker process and to send a start worker message. This 241 // A task to allocate a worker process and to send a start worker message. This
219 // is created on EmbeddedWorkerInstance::Start(), owned by the instance and 242 // is created on EmbeddedWorkerInstance::Start(), owned by the instance and
220 // destroyed on EmbeddedWorkerInstance::OnScriptEvaluated(). 243 // destroyed on EmbeddedWorkerInstance::OnScriptEvaluated().
221 // We can abort starting worker by destroying this task anytime during the 244 // We can abort starting worker by destroying this task anytime during the
222 // sequence. 245 // sequence.
223 class EmbeddedWorkerInstance::StartTask { 246 class EmbeddedWorkerInstance::StartTask {
224 public: 247 public:
225 enum class ProcessAllocationState { NOT_ALLOCATED, ALLOCATING, ALLOCATED }; 248 enum class ProcessAllocationState { NOT_ALLOCATED, ALLOCATING, ALLOCATED };
226 249
227 StartTask(EmbeddedWorkerInstance* instance, 250 StartTask(EmbeddedWorkerInstance* instance, const GURL& script_url)
228 const GURL& script_url,
229 mojom::EmbeddedWorkerInstanceClientRequest request)
230 : instance_(instance), 251 : instance_(instance),
231 request_(std::move(request)),
232 state_(ProcessAllocationState::NOT_ALLOCATED), 252 state_(ProcessAllocationState::NOT_ALLOCATED),
233 is_installed_(false), 253 is_installed_(false),
234 started_during_browser_startup_(false), 254 started_during_browser_startup_(false),
235 weak_factory_(this) { 255 weak_factory_(this) {
236 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", "EmbeddedWorkerInstance::Start", 256 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", "EmbeddedWorkerInstance::Start",
237 this, "Script", script_url.spec()); 257 this, "Script", script_url.spec());
238 } 258 }
239 259
240 ~StartTask() { 260 ~StartTask() {
241 DCHECK_CURRENTLY_ON(BrowserThread::IO); 261 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 params->settings.data_saver_enabled = settings.data_saver_enabled; 372 params->settings.data_saver_enabled = settings.data_saver_enabled;
353 373
354 // Register the instance to DevToolsManager on UI thread. 374 // Register the instance to DevToolsManager on UI thread.
355 const int64_t service_worker_version_id = params->service_worker_version_id; 375 const int64_t service_worker_version_id = params->service_worker_version_id;
356 const GURL& scope = params->scope; 376 const GURL& scope = params->scope;
357 GURL script_url(params->script_url); 377 GURL script_url(params->script_url);
358 BrowserThread::PostTask( 378 BrowserThread::PostTask(
359 BrowserThread::UI, FROM_HERE, 379 BrowserThread::UI, FROM_HERE,
360 base::Bind(&SetupOnUI, process_id, instance_->context_.get(), 380 base::Bind(&SetupOnUI, process_id, instance_->context_.get(),
361 instance_->context_, service_worker_version_id, script_url, 381 instance_->context_, service_worker_version_id, script_url,
362 scope, is_installed_, base::Passed(&request_), 382 scope, is_installed_,
363 base::Bind(&StartTask::OnSetupOnUICompleted, 383 base::Bind(&StartTask::OnSetupOnUICompleted,
364 weak_factory_.GetWeakPtr(), base::Passed(&params), 384 weak_factory_.GetWeakPtr(), base::Passed(&params),
365 is_new_process))); 385 is_new_process)));
366 } 386 }
367 387
368 void OnSetupOnUICompleted(std::unique_ptr<EmbeddedWorkerStartParams> params, 388 void OnSetupOnUICompleted(
369 bool is_new_process, 389 std::unique_ptr<EmbeddedWorkerStartParams> params,
370 int worker_devtools_agent_route_id, 390 bool is_new_process,
371 bool wait_for_debugger) { 391 int worker_devtools_agent_route_id,
392 bool wait_for_debugger,
393 mojom::EmbeddedWorkerInstanceClientAssociatedPtrInfo ptr_info) {
372 DCHECK_CURRENTLY_ON(BrowserThread::IO); 394 DCHECK_CURRENTLY_ON(BrowserThread::IO);
373 TRACE_EVENT_ASYNC_STEP_PAST0("ServiceWorker", 395 TRACE_EVENT_ASYNC_STEP_PAST0("ServiceWorker",
374 "EmbeddedWorkerInstance::Start", this, 396 "EmbeddedWorkerInstance::Start", this,
375 "OnSetupOnUICompleted"); 397 "OnSetupOnUICompleted");
376 398
377 // Notify the instance that it is registered to the devtools manager. 399 // Notify the instance that it is registered to the devtools manager.
378 instance_->OnRegisteredToDevToolsManager( 400 instance_->OnRegisteredToDevToolsManager(
379 is_new_process, worker_devtools_agent_route_id, wait_for_debugger); 401 is_new_process, worker_devtools_agent_route_id, wait_for_debugger);
380 402
381 params->worker_devtools_agent_route_id = worker_devtools_agent_route_id; 403 params->worker_devtools_agent_route_id = worker_devtools_agent_route_id;
382 params->wait_for_debugger = wait_for_debugger; 404 params->wait_for_debugger = wait_for_debugger;
383 405
384 if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) 406 if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled())
385 SendMojoStartWorker(std::move(params)); 407 SendMojoStartWorker(std::move(params), std::move(ptr_info));
386 else 408 else
387 SendStartWorker(std::move(params)); 409 SendStartWorker(std::move(params));
388 } 410 }
389 411
390 void SendStartWorker(std::unique_ptr<EmbeddedWorkerStartParams> params) { 412 void SendStartWorker(std::unique_ptr<EmbeddedWorkerStartParams> params) {
391 DCHECK_CURRENTLY_ON(BrowserThread::IO); 413 DCHECK_CURRENTLY_ON(BrowserThread::IO);
392 ServiceWorkerStatusCode status = instance_->registry_->SendStartWorker( 414 ServiceWorkerStatusCode status = instance_->registry_->SendStartWorker(
393 std::move(params), instance_->process_id()); 415 std::move(params), instance_->process_id());
394 TRACE_EVENT_ASYNC_STEP_PAST1( 416 TRACE_EVENT_ASYNC_STEP_PAST1(
395 "ServiceWorker", "EmbeddedWorkerInstance::Start", this, 417 "ServiceWorker", "EmbeddedWorkerInstance::Start", this,
396 "SendStartWorker", "Status", ServiceWorkerStatusToString(status)); 418 "SendStartWorker", "Status", ServiceWorkerStatusToString(status));
397 if (status != SERVICE_WORKER_OK) { 419 if (status != SERVICE_WORKER_OK) {
398 StatusCallback callback = start_callback_; 420 StatusCallback callback = start_callback_;
399 start_callback_.Reset(); 421 start_callback_.Reset();
400 instance_->OnStartFailed(callback, status); 422 instance_->OnStartFailed(callback, status);
401 // |this| may be destroyed. 423 // |this| may be destroyed.
402 return; 424 return;
403 } 425 }
404 instance_->OnStartWorkerMessageSent(); 426 instance_->OnStartWorkerMessageSent();
405 427
406 // |start_callback_| will be called via RunStartCallback() when the script 428 // |start_callback_| will be called via RunStartCallback() when the script
407 // is evaluated. 429 // is evaluated.
408 } 430 }
409 431
410 void SendMojoStartWorker(std::unique_ptr<EmbeddedWorkerStartParams> params) { 432 void SendMojoStartWorker(
433 std::unique_ptr<EmbeddedWorkerStartParams> params,
434 mojom::EmbeddedWorkerInstanceClientAssociatedPtrInfo ptr_info) {
411 ServiceWorkerStatusCode status = 435 ServiceWorkerStatusCode status =
412 instance_->SendMojoStartWorker(std::move(params)); 436 instance_->SendMojoStartWorker(std::move(params), std::move(ptr_info));
413 if (status != SERVICE_WORKER_OK) { 437 if (status != SERVICE_WORKER_OK) {
414 StatusCallback callback = start_callback_; 438 StatusCallback callback = start_callback_;
415 start_callback_.Reset(); 439 start_callback_.Reset();
416 instance_->OnStartFailed(callback, status); 440 instance_->OnStartFailed(callback, status);
417 // |this| may be destroyed. 441 // |this| may be destroyed.
418 return; 442 return;
419 } 443 }
420 } 444 }
421 445
422 // |instance_| must outlive |this|. 446 // |instance_| must outlive |this|.
423 EmbeddedWorkerInstance* instance_; 447 EmbeddedWorkerInstance* instance_;
424 448
425 // Ownership is transferred by base::Passed() to a task after process
426 // allocation.
427 mojom::EmbeddedWorkerInstanceClientRequest request_;
428
429 StatusCallback start_callback_; 449 StatusCallback start_callback_;
430 ProcessAllocationState state_; 450 ProcessAllocationState state_;
431 451
432 // Used for UMA. 452 // Used for UMA.
433 bool is_installed_; 453 bool is_installed_;
434 bool started_during_browser_startup_; 454 bool started_during_browser_startup_;
435 455
436 base::WeakPtrFactory<StartTask> weak_factory_; 456 base::WeakPtrFactory<StartTask> weak_factory_;
437 457
438 DISALLOW_COPY_AND_ASSIGN(StartTask); 458 DISALLOW_COPY_AND_ASSIGN(StartTask);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 starting_phase_ = ALLOCATING_PROCESS; 491 starting_phase_ = ALLOCATING_PROCESS;
472 network_accessed_for_script_ = false; 492 network_accessed_for_script_ = false;
473 for (auto& observer : listener_list_) 493 for (auto& observer : listener_list_)
474 observer.OnStarting(); 494 observer.OnStarting();
475 495
476 params->embedded_worker_id = embedded_worker_id_; 496 params->embedded_worker_id = embedded_worker_id_;
477 params->worker_devtools_agent_route_id = MSG_ROUTING_NONE; 497 params->worker_devtools_agent_route_id = MSG_ROUTING_NONE;
478 params->wait_for_debugger = false; 498 params->wait_for_debugger = false;
479 params->settings.v8_cache_options = GetV8CacheOptions(); 499 params->settings.v8_cache_options = GetV8CacheOptions();
480 500
481 mojom::EmbeddedWorkerInstanceClientRequest request;
482 if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) {
483 request = mojo::MakeRequest(&client_);
484 client_.set_connection_error_handler(
485 base::Bind(&CallDetach, base::Unretained(this)));
486 }
487
488 pending_dispatcher_request_ = std::move(dispatcher_request); 501 pending_dispatcher_request_ = std::move(dispatcher_request);
489 502
490 inflight_start_task_.reset( 503 inflight_start_task_.reset(new StartTask(this, params->script_url));
491 new StartTask(this, params->script_url, std::move(request)));
492 inflight_start_task_->Start(std::move(params), callback); 504 inflight_start_task_->Start(std::move(params), callback);
493 } 505 }
494 506
495 ServiceWorkerStatusCode EmbeddedWorkerInstance::Stop() { 507 ServiceWorkerStatusCode EmbeddedWorkerInstance::Stop() {
496 DCHECK(status_ == EmbeddedWorkerStatus::STARTING || 508 DCHECK(status_ == EmbeddedWorkerStatus::STARTING ||
497 status_ == EmbeddedWorkerStatus::RUNNING) 509 status_ == EmbeddedWorkerStatus::RUNNING)
498 << static_cast<int>(status_); 510 << static_cast<int>(status_);
499 511
500 // Abort an inflight start task. 512 // Abort an inflight start task.
501 inflight_start_task_.reset(); 513 inflight_start_task_.reset();
502 514
503 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_IPC_FAILED; 515 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_IPC_FAILED;
504 if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) { 516 if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) {
505 status = SERVICE_WORKER_OK; 517 // |client_| may be not bound yet, or has become broken.
506 client_->StopWorker(base::Bind(&EmbeddedWorkerRegistry::OnWorkerStopped, 518 if (client_ && !client_.encountered_error()) {
507 base::Unretained(registry_.get()), 519 status = SERVICE_WORKER_OK;
508 process_id(), embedded_worker_id())); 520 client_->StopWorker(base::Bind(&EmbeddedWorkerRegistry::OnWorkerStopped,
521 base::Unretained(registry_.get()),
522 process_id(), embedded_worker_id()));
523 }
509 } else { 524 } else {
510 status = registry_->StopWorker(process_id(), embedded_worker_id_); 525 status = registry_->StopWorker(process_id(), embedded_worker_id_);
511 } 526 }
512 UMA_HISTOGRAM_ENUMERATION("ServiceWorker.SendStopWorker.Status", status, 527 UMA_HISTOGRAM_ENUMERATION("ServiceWorker.SendStopWorker.Status", status,
513 SERVICE_WORKER_ERROR_MAX_VALUE); 528 SERVICE_WORKER_ERROR_MAX_VALUE);
514 // StopWorker could fail if we were starting up and don't have a process yet, 529 // StopWorker could fail if we were starting up and don't have a process yet,
515 // or we can no longer communicate with the process. So just detach. 530 // or we can no longer communicate with the process. So just detach.
516 if (status != SERVICE_WORKER_OK) { 531 if (status != SERVICE_WORKER_OK) {
517 OnDetached(); 532 OnDetached();
518 return status; 533 return status;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 if (wait_for_debugger) { 614 if (wait_for_debugger) {
600 // We don't measure the start time when wait_for_debugger flag is set. So 615 // We don't measure the start time when wait_for_debugger flag is set. So
601 // we set the NULL time here. 616 // we set the NULL time here.
602 step_time_ = base::TimeTicks(); 617 step_time_ = base::TimeTicks();
603 } 618 }
604 for (auto& observer : listener_list_) 619 for (auto& observer : listener_list_)
605 observer.OnRegisteredToDevToolsManager(); 620 observer.OnRegisteredToDevToolsManager();
606 } 621 }
607 622
608 ServiceWorkerStatusCode EmbeddedWorkerInstance::SendMojoStartWorker( 623 ServiceWorkerStatusCode EmbeddedWorkerInstance::SendMojoStartWorker(
609 std::unique_ptr<EmbeddedWorkerStartParams> params) { 624 std::unique_ptr<EmbeddedWorkerStartParams> params,
625 mojom::EmbeddedWorkerInstanceClientAssociatedPtrInfo ptr_info) {
610 if (!context_) 626 if (!context_)
611 return SERVICE_WORKER_ERROR_ABORT; 627 return SERVICE_WORKER_ERROR_ABORT;
628 DCHECK(ServiceWorkerUtils::IsMojoForServiceWorkerEnabled());
612 DCHECK(pending_dispatcher_request_.is_pending()); 629 DCHECK(pending_dispatcher_request_.is_pending());
630 DCHECK(ptr_info.is_valid());
631 client_.Bind(std::move(ptr_info));
632 client_.set_connection_error_handler(
633 base::Bind(&CallDetach, base::Unretained(this)));
613 client_->StartWorker(*params, std::move(pending_dispatcher_request_)); 634 client_->StartWorker(*params, std::move(pending_dispatcher_request_));
614 registry_->BindWorkerToProcess(process_id(), embedded_worker_id()); 635 registry_->BindWorkerToProcess(process_id(), embedded_worker_id());
615 TRACE_EVENT_ASYNC_STEP_PAST1("ServiceWorker", "EmbeddedWorkerInstance::Start", 636 TRACE_EVENT_ASYNC_STEP_PAST1("ServiceWorker", "EmbeddedWorkerInstance::Start",
616 this, "SendStartWorker", "Status", "mojo"); 637 this, "SendStartWorker", "Status", "mojo");
617 OnStartWorkerMessageSent(); 638 OnStartWorkerMessageSent();
618 return SERVICE_WORKER_OK; 639 return SERVICE_WORKER_OK;
619 } 640 }
620 641
621 void EmbeddedWorkerInstance::OnStartWorkerMessageSent() { 642 void EmbeddedWorkerInstance::OnStartWorkerMessageSent() {
622 if (!step_time_.is_null()) { 643 if (!step_time_.is_null()) {
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 case SCRIPT_READ_FINISHED: 963 case SCRIPT_READ_FINISHED:
943 return "Script read finished"; 964 return "Script read finished";
944 case STARTING_PHASE_MAX_VALUE: 965 case STARTING_PHASE_MAX_VALUE:
945 NOTREACHED(); 966 NOTREACHED();
946 } 967 }
947 NOTREACHED() << phase; 968 NOTREACHED() << phase;
948 return std::string(); 969 return std::string();
949 } 970 }
950 971
951 } // namespace content 972 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698