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" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 // |rph| or its InterfaceProvider may be NULL in unit tests. | 114 // |rph| or its InterfaceProvider may be NULL in unit tests. |
| 115 if (!rph || !rph->GetRemoteInterfaces()) | 115 if (!rph || !rph->GetRemoteInterfaces()) |
| 116 return; | 116 return; |
| 117 mojom::EmbeddedWorkerSetupPtr setup; | 117 mojom::EmbeddedWorkerSetupPtr setup; |
| 118 rph->GetRemoteInterfaces()->GetInterface(&setup); | 118 rph->GetRemoteInterfaces()->GetInterface(&setup); |
| 119 setup->ExchangeInterfaceProviders( | 119 setup->ExchangeInterfaceProviders( |
| 120 thread_id, std::move(remote_interfaces), | 120 thread_id, std::move(remote_interfaces), |
| 121 mojo::MakeProxy(std::move(exposed_interfaces))); | 121 mojo::MakeProxy(std::move(exposed_interfaces))); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void CallDetach(EmbeddedWorkerInstance* instance) { | |
|
nhiroki
2016/11/02 08:42:39
Just to confirm: A raw pointer is safe here becaus
shimazu
2016/11/04 01:09:21
Done.
| |
| 125 // This could be called on the UI thread if |client_| still be valid when the | |
| 126 // message loop on the UI thread gets destructed. | |
| 127 // TODO(shimazu): Remove this after https://crbug.com/604762 is fixed | |
| 128 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | |
| 129 DCHECK(ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()); | |
| 130 return; | |
| 131 } | |
| 132 instance->Detach(); | |
| 133 } | |
| 134 | |
| 124 } // namespace | 135 } // namespace |
| 125 | 136 |
| 126 // Lives on IO thread, proxies notifications to DevToolsManager that lives on | 137 // Lives on IO thread, proxies notifications to DevToolsManager that lives on |
| 127 // UI thread. Owned by EmbeddedWorkerInstance. | 138 // UI thread. Owned by EmbeddedWorkerInstance. |
| 128 class EmbeddedWorkerInstance::DevToolsProxy : public base::NonThreadSafe { | 139 class EmbeddedWorkerInstance::DevToolsProxy : public base::NonThreadSafe { |
| 129 public: | 140 public: |
| 130 DevToolsProxy(int process_id, int agent_route_id) | 141 DevToolsProxy(int process_id, int agent_route_id) |
| 131 : process_id_(process_id), | 142 : process_id_(process_id), |
| 132 agent_route_id_(agent_route_id) {} | 143 agent_route_id_(agent_route_id) {} |
| 133 | 144 |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 | 481 |
| 471 params->embedded_worker_id = embedded_worker_id_; | 482 params->embedded_worker_id = embedded_worker_id_; |
| 472 params->worker_devtools_agent_route_id = MSG_ROUTING_NONE; | 483 params->worker_devtools_agent_route_id = MSG_ROUTING_NONE; |
| 473 params->wait_for_debugger = false; | 484 params->wait_for_debugger = false; |
| 474 params->settings.v8_cache_options = GetV8CacheOptions(); | 485 params->settings.v8_cache_options = GetV8CacheOptions(); |
| 475 | 486 |
| 476 mojom::EmbeddedWorkerInstanceClientRequest request; | 487 mojom::EmbeddedWorkerInstanceClientRequest request; |
| 477 if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) { | 488 if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) { |
| 478 request = mojo::GetProxy(&client_); | 489 request = mojo::GetProxy(&client_); |
| 479 client_.set_connection_error_handler( | 490 client_.set_connection_error_handler( |
| 480 base::Bind(&EmbeddedWorkerInstance::Detach, base::Unretained(this))); | 491 base::Bind(&CallDetach, base::Unretained(this))); |
| 481 } | 492 } |
| 482 | 493 |
| 483 inflight_start_task_.reset( | 494 inflight_start_task_.reset( |
| 484 new StartTask(this, params->script_url, std::move(request))); | 495 new StartTask(this, params->script_url, std::move(request))); |
| 485 inflight_start_task_->Start(std::move(params), callback); | 496 inflight_start_task_->Start(std::move(params), callback); |
| 486 } | 497 } |
| 487 | 498 |
| 488 ServiceWorkerStatusCode EmbeddedWorkerInstance::Stop() { | 499 ServiceWorkerStatusCode EmbeddedWorkerInstance::Stop() { |
| 489 DCHECK(status_ == EmbeddedWorkerStatus::STARTING || | 500 DCHECK(status_ == EmbeddedWorkerStatus::STARTING || |
| 490 status_ == EmbeddedWorkerStatus::RUNNING) | 501 status_ == EmbeddedWorkerStatus::RUNNING) |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 972 case SCRIPT_READ_FINISHED: | 983 case SCRIPT_READ_FINISHED: |
| 973 return "Script read finished"; | 984 return "Script read finished"; |
| 974 case STARTING_PHASE_MAX_VALUE: | 985 case STARTING_PHASE_MAX_VALUE: |
| 975 NOTREACHED(); | 986 NOTREACHED(); |
| 976 } | 987 } |
| 977 NOTREACHED() << phase; | 988 NOTREACHED() << phase; |
| 978 return std::string(); | 989 return std::string(); |
| 979 } | 990 } |
| 980 | 991 |
| 981 } // namespace content | 992 } // namespace content |
| OLD | NEW |