| 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" | 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/mojo/service_registry_impl.h" | 20 #include "content/common/mojo/service_registry_impl.h" |
| 21 #include "content/common/service_worker/embedded_worker_messages.h" | 21 #include "content/common/service_worker/embedded_worker_messages.h" |
| 22 #include "content/common/service_worker/embedded_worker_settings.h" | 22 #include "content/common/service_worker/embedded_worker_settings.h" |
| 23 #include "content/common/service_worker/embedded_worker_setup.mojom.h" | 23 #include "content/common/service_worker/embedded_worker_setup.mojom.h" |
| 24 #include "content/common/service_worker/service_worker_types.h" | 24 #include "content/common/service_worker/service_worker_types.h" |
| 25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/content_browser_client.h" | 26 #include "content/public/browser/content_browser_client.h" |
| 27 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
| 28 #include "content/public/common/child_process_host.h" | 28 #include "content/public/common/child_process_host.h" |
| 29 #include "ipc/ipc_message.h" | 29 #include "ipc/ipc_message.h" |
| 30 #include "services/shell/public/cpp/interface_provider.h" |
| 30 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| 33 | 34 |
| 34 namespace { | 35 namespace { |
| 35 | 36 |
| 36 // When a service worker version's failure count exceeds | 37 // When a service worker version's failure count exceeds |
| 37 // |kMaxSameProcessFailureCount|, the embedded worker is forced to start in a | 38 // |kMaxSameProcessFailureCount|, the embedded worker is forced to start in a |
| 38 // new process. | 39 // new process. |
| 39 const int kMaxSameProcessFailureCount = 2; | 40 const int kMaxSameProcessFailureCount = 2; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 FROM_HERE, | 100 FROM_HERE, |
| 100 base::Bind(callback, worker_devtools_agent_route_id, wait_for_debugger)); | 101 base::Bind(callback, worker_devtools_agent_route_id, wait_for_debugger)); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void SetupMojoOnUIThread( | 104 void SetupMojoOnUIThread( |
| 104 int process_id, | 105 int process_id, |
| 105 int thread_id, | 106 int thread_id, |
| 106 shell::mojom::InterfaceProviderRequest services, | 107 shell::mojom::InterfaceProviderRequest services, |
| 107 shell::mojom::InterfaceProviderPtrInfo exposed_services) { | 108 shell::mojom::InterfaceProviderPtrInfo exposed_services) { |
| 108 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); | 109 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); |
| 109 // |rph| or its ServiceRegistry may be NULL in unit tests. | 110 // |rph| or its InterfaceProvider may be NULL in unit tests. |
| 110 if (!rph || !rph->GetServiceRegistry()) | 111 if (!rph || !rph->GetRemoteInterfaces()) |
| 111 return; | 112 return; |
| 112 mojom::EmbeddedWorkerSetupPtr setup; | 113 mojom::EmbeddedWorkerSetupPtr setup; |
| 113 rph->GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&setup)); | 114 rph->GetRemoteInterfaces()->GetInterface(&setup); |
| 114 setup->ExchangeInterfaceProviders( | 115 setup->ExchangeInterfaceProviders( |
| 115 thread_id, std::move(services), | 116 thread_id, std::move(services), |
| 116 mojo::MakeProxy(std::move(exposed_services))); | 117 mojo::MakeProxy(std::move(exposed_services))); |
| 117 } | 118 } |
| 118 | 119 |
| 119 } // namespace | 120 } // namespace |
| 120 | 121 |
| 121 // Lives on IO thread, proxies notifications to DevToolsManager that lives on | 122 // Lives on IO thread, proxies notifications to DevToolsManager that lives on |
| 122 // UI thread. Owned by EmbeddedWorkerInstance. | 123 // UI thread. Owned by EmbeddedWorkerInstance. |
| 123 class EmbeddedWorkerInstance::DevToolsProxy : public base::NonThreadSafe { | 124 class EmbeddedWorkerInstance::DevToolsProxy : public base::NonThreadSafe { |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 case SCRIPT_READ_FINISHED: | 871 case SCRIPT_READ_FINISHED: |
| 871 return "Script read finished"; | 872 return "Script read finished"; |
| 872 case STARTING_PHASE_MAX_VALUE: | 873 case STARTING_PHASE_MAX_VALUE: |
| 873 NOTREACHED(); | 874 NOTREACHED(); |
| 874 } | 875 } |
| 875 NOTREACHED() << phase; | 876 NOTREACHED() << phase; |
| 876 return std::string(); | 877 return std::string(); |
| 877 } | 878 } |
| 878 | 879 |
| 879 } // namespace content | 880 } // namespace content |
| OLD | NEW |