OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/mojo/mojo_shell_context.h" | 5 #include "content/browser/mojo/mojo_shell_context.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 base::Passed(GetProxy(&service_factory)), | 68 base::Passed(GetProxy(&service_factory)), |
69 process_name, use_sandbox)); | 69 process_name, use_sandbox)); |
70 service_factory->CreateService(std::move(request), service_name); | 70 service_factory->CreateService(std::move(request), service_name); |
71 } | 71 } |
72 | 72 |
73 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) | 73 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) |
74 | 74 |
75 // Request shell::mojom::ServiceFactory from GPU process host. Must be called on | 75 // Request shell::mojom::ServiceFactory from GPU process host. Must be called on |
76 // IO thread. | 76 // IO thread. |
77 void RequestGpuServiceFactory(shell::mojom::ServiceFactoryRequest request) { | 77 void RequestGpuServiceFactory(shell::mojom::ServiceFactoryRequest request) { |
78 BrowserChildProcessHostDelegate* process_host = | 78 GpuProcessHost* process_host = |
79 GpuProcessHost::Get(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED); | 79 GpuProcessHost::Get(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED); |
80 if (!process_host) { | 80 if (!process_host) { |
81 DLOG(ERROR) << "GPU process host not available."; | 81 DLOG(ERROR) << "GPU process host not available."; |
82 return; | 82 return; |
83 } | 83 } |
84 | 84 |
85 // TODO(xhwang): It's possible that |process_host| is non-null, but the actual | 85 // TODO(xhwang): It's possible that |process_host| is non-null, but the actual |
86 // process is dead. In that case, |request| will be dropped and application | 86 // process is dead. In that case, |request| will be dropped and application |
87 // load requests through ServiceFactory will also fail. Make sure we handle | 87 // load requests through ServiceFactory will also fail. Make sure we handle |
88 // these cases correctly. | 88 // these cases correctly. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 private: | 174 private: |
175 friend class base::RefCountedThreadSafe<InProcessServiceManagerContext>; | 175 friend class base::RefCountedThreadSafe<InProcessServiceManagerContext>; |
176 | 176 |
177 ~InProcessServiceManagerContext() {} | 177 ~InProcessServiceManagerContext() {} |
178 | 178 |
179 void StartOnIOThread( | 179 void StartOnIOThread( |
180 std::unique_ptr<BuiltinManifestProvider> manifest_provider, | 180 std::unique_ptr<BuiltinManifestProvider> manifest_provider, |
181 shell::mojom::ServicePtrInfo embedder_service_proxy_info) { | 181 shell::mojom::ServicePtrInfo embedder_service_proxy_info) { |
182 manifest_provider_ = std::move(manifest_provider); | 182 manifest_provider_ = std::move(manifest_provider); |
183 | 183 |
184 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner = | 184 base::SequencedWorkerPool* blocking_pool = BrowserThread::GetBlockingPool(); |
185 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE); | |
186 std::unique_ptr<shell::NativeRunnerFactory> native_runner_factory( | 185 std::unique_ptr<shell::NativeRunnerFactory> native_runner_factory( |
187 new shell::InProcessNativeRunnerFactory( | 186 new shell::InProcessNativeRunnerFactory(blocking_pool)); |
188 BrowserThread::GetBlockingPool())); | 187 catalog_.reset( |
189 catalog_.reset(new catalog::Catalog( | 188 new catalog::Catalog(blocking_pool, nullptr, manifest_provider_.get())); |
190 file_task_runner.get(), nullptr, manifest_provider_.get())); | |
191 service_manager_.reset(new shell::ServiceManager( | 189 service_manager_.reset(new shell::ServiceManager( |
192 std::move(native_runner_factory), catalog_->TakeService())); | 190 std::move(native_runner_factory), catalog_->TakeService())); |
193 | 191 |
194 shell::mojom::ServiceRequest request = | 192 shell::mojom::ServiceRequest request = |
195 service_manager_->StartEmbedderService(kBrowserMojoApplicationName); | 193 service_manager_->StartEmbedderService(kBrowserMojoApplicationName); |
196 mojo::FuseInterface( | 194 mojo::FuseInterface( |
197 std::move(request), std::move(embedder_service_proxy_info)); | 195 std::move(request), std::move(embedder_service_proxy_info)); |
198 } | 196 } |
199 | 197 |
200 void ShutDownOnIOThread() { | 198 void ShutDownOnIOThread() { |
201 service_manager_.reset(); | 199 service_manager_.reset(); |
202 catalog_.reset(); | 200 catalog_.reset(); |
203 manifest_provider_.reset(); | 201 manifest_provider_.reset(); |
204 } | 202 } |
205 | 203 |
206 std::unique_ptr<BuiltinManifestProvider> manifest_provider_; | 204 std::unique_ptr<BuiltinManifestProvider> manifest_provider_; |
207 std::unique_ptr<catalog::Catalog> catalog_; | 205 std::unique_ptr<catalog::Catalog> catalog_; |
208 std::unique_ptr<shell::ServiceManager> service_manager_; | 206 std::unique_ptr<shell::ServiceManager> service_manager_; |
209 | 207 |
210 DISALLOW_COPY_AND_ASSIGN(InProcessServiceManagerContext); | 208 DISALLOW_COPY_AND_ASSIGN(InProcessServiceManagerContext); |
211 }; | 209 }; |
212 | 210 |
213 | |
214 MojoShellContext::MojoShellContext() { | 211 MojoShellContext::MojoShellContext() { |
215 shell::mojom::ServiceRequest request; | 212 shell::mojom::ServiceRequest request; |
216 if (shell::ShellIsRemote()) { | 213 if (shell::ShellIsRemote()) { |
217 mojo::edk::SetParentPipeHandleFromCommandLine(); | 214 mojo::edk::SetParentPipeHandleFromCommandLine(); |
218 request = shell::GetServiceRequestFromCommandLine(); | 215 request = shell::GetServiceRequestFromCommandLine(); |
219 } else { | 216 } else { |
220 // Allow the embedder to register additional Mojo application manifests | 217 // Allow the embedder to register additional Mojo application manifests |
221 // beyond the default ones below. | 218 // beyond the default ones below. |
222 std::unique_ptr<ContentBrowserClient::MojoApplicationManifestMap> manifests( | 219 std::unique_ptr<ContentBrowserClient::MojoApplicationManifestMap> manifests( |
223 new ContentBrowserClient::MojoApplicationManifestMap); | 220 new ContentBrowserClient::MojoApplicationManifestMap); |
224 GetContentClient()->browser()->RegisterMojoApplicationManifests( | 221 GetContentClient()->browser()->RegisterMojoApplicationManifests( |
225 manifests.get()); | 222 manifests.get()); |
226 std::unique_ptr<BuiltinManifestProvider> manifest_provider = | 223 std::unique_ptr<BuiltinManifestProvider> manifest_provider = |
227 base::MakeUnique<BuiltinManifestProvider>(); | 224 base::MakeUnique<BuiltinManifestProvider>(); |
228 manifest_provider->AddManifests(std::move(manifests)); | 225 manifest_provider->AddManifests(std::move(manifests)); |
229 manifest_provider->AddManifestResource(kBrowserMojoApplicationName, | 226 manifest_provider->AddManifestResource(kBrowserMojoApplicationName, |
230 IDR_MOJO_CONTENT_BROWSER_MANIFEST); | 227 IDR_MOJO_CONTENT_BROWSER_MANIFEST); |
231 manifest_provider->AddManifestResource(kGpuMojoApplicationName, | 228 manifest_provider->AddManifestResource(kGpuMojoApplicationName, |
232 IDR_MOJO_CONTENT_GPU_MANIFEST); | 229 IDR_MOJO_CONTENT_GPU_MANIFEST); |
| 230 manifest_provider->AddManifestResource(kPluginMojoApplicationName, |
| 231 IDR_MOJO_CONTENT_PLUGIN_MANIFEST); |
233 manifest_provider->AddManifestResource(kRendererMojoApplicationName, | 232 manifest_provider->AddManifestResource(kRendererMojoApplicationName, |
234 IDR_MOJO_CONTENT_RENDERER_MANIFEST); | 233 IDR_MOJO_CONTENT_RENDERER_MANIFEST); |
235 manifest_provider->AddManifestResource(kUtilityMojoApplicationName, | 234 manifest_provider->AddManifestResource(kUtilityMojoApplicationName, |
236 IDR_MOJO_CONTENT_UTILITY_MANIFEST); | 235 IDR_MOJO_CONTENT_UTILITY_MANIFEST); |
237 manifest_provider->AddManifestResource("mojo:catalog", | 236 manifest_provider->AddManifestResource("mojo:catalog", |
238 IDR_MOJO_CATALOG_MANIFEST); | 237 IDR_MOJO_CATALOG_MANIFEST); |
239 manifest_provider->AddManifestResource(file::kFileServiceName, | 238 manifest_provider->AddManifestResource(file::kFileServiceName, |
240 IDR_MOJO_FILE_MANIFEST); | 239 IDR_MOJO_FILE_MANIFEST); |
241 | 240 |
242 in_process_context_ = new InProcessServiceManagerContext; | 241 in_process_context_ = new InProcessServiceManagerContext; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 in_process_context_->ShutDown(); | 296 in_process_context_->ShutDown(); |
298 } | 297 } |
299 | 298 |
300 // static | 299 // static |
301 shell::Connector* MojoShellContext::GetConnectorForIOThread() { | 300 shell::Connector* MojoShellContext::GetConnectorForIOThread() { |
302 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
303 return g_io_thread_connector.Get().get(); | 302 return g_io_thread_connector.Get().get(); |
304 } | 303 } |
305 | 304 |
306 } // namespace content | 305 } // namespace content |
OLD | NEW |