| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 206 |
| 207 static const struct ManifestInfo { | 207 static const struct ManifestInfo { |
| 208 const char* name; | 208 const char* name; |
| 209 int resource_id; | 209 int resource_id; |
| 210 } kManifests[] = { | 210 } kManifests[] = { |
| 211 { kBrowserMojoApplicationName, IDR_MOJO_CONTENT_BROWSER_MANIFEST }, | 211 { kBrowserMojoApplicationName, IDR_MOJO_CONTENT_BROWSER_MANIFEST }, |
| 212 { kGpuMojoApplicationName, IDR_MOJO_CONTENT_GPU_MANIFEST }, | 212 { kGpuMojoApplicationName, IDR_MOJO_CONTENT_GPU_MANIFEST }, |
| 213 { kPluginMojoApplicationName, IDR_MOJO_CONTENT_PLUGIN_MANIFEST }, | 213 { kPluginMojoApplicationName, IDR_MOJO_CONTENT_PLUGIN_MANIFEST }, |
| 214 { kRendererMojoApplicationName, IDR_MOJO_CONTENT_RENDERER_MANIFEST }, | 214 { kRendererMojoApplicationName, IDR_MOJO_CONTENT_RENDERER_MANIFEST }, |
| 215 { kUtilityMojoApplicationName, IDR_MOJO_CONTENT_UTILITY_MANIFEST }, | 215 { kUtilityMojoApplicationName, IDR_MOJO_CONTENT_UTILITY_MANIFEST }, |
| 216 { "mojo:catalog", IDR_MOJO_CATALOG_MANIFEST }, | 216 { "service:catalog", IDR_MOJO_CATALOG_MANIFEST }, |
| 217 { file::kFileServiceName, IDR_MOJO_FILE_MANIFEST } | 217 { file::kFileServiceName, IDR_MOJO_FILE_MANIFEST } |
| 218 }; | 218 }; |
| 219 | 219 |
| 220 for (size_t i = 0; i < arraysize(kManifests); ++i) { | 220 for (size_t i = 0; i < arraysize(kManifests); ++i) { |
| 221 std::string contents = GetContentClient()->GetDataResource( | 221 std::string contents = GetContentClient()->GetDataResource( |
| 222 kManifests[i].resource_id, | 222 kManifests[i].resource_id, |
| 223 ui::ScaleFactor::SCALE_FACTOR_NONE).as_string(); | 223 ui::ScaleFactor::SCALE_FACTOR_NONE).as_string(); |
| 224 DCHECK(!contents.empty()); | 224 DCHECK(!contents.empty()); |
| 225 std::unique_ptr<base::Value> manifest_value = | 225 std::unique_ptr<base::Value> manifest_value = |
| 226 base::JSONReader::Read(contents); | 226 base::JSONReader::Read(contents); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 ->RegisterUnsandboxedOutOfProcessMojoApplications(&unsandboxed_apps); | 275 ->RegisterUnsandboxedOutOfProcessMojoApplications(&unsandboxed_apps); |
| 276 for (const auto& app : unsandboxed_apps) { | 276 for (const auto& app : unsandboxed_apps) { |
| 277 MojoShellConnection::GetForProcess()->AddServiceRequestHandler( | 277 MojoShellConnection::GetForProcess()->AddServiceRequestHandler( |
| 278 app.first, | 278 app.first, |
| 279 base::Bind(&StartServiceInUtilityProcess, app.first, app.second, | 279 base::Bind(&StartServiceInUtilityProcess, app.first, app.second, |
| 280 false /* use_sandbox */)); | 280 false /* use_sandbox */)); |
| 281 } | 281 } |
| 282 | 282 |
| 283 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) | 283 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) |
| 284 MojoShellConnection::GetForProcess()->AddServiceRequestHandler( | 284 MojoShellConnection::GetForProcess()->AddServiceRequestHandler( |
| 285 "mojo:media", base::Bind(&StartServiceInGpuProcess, "mojo:media")); | 285 "service:media", base::Bind(&StartServiceInGpuProcess, "service:media")); |
| 286 #endif | 286 #endif |
| 287 } | 287 } |
| 288 | 288 |
| 289 MojoShellContext::~MojoShellContext() { | 289 MojoShellContext::~MojoShellContext() { |
| 290 // NOTE: The in-process ServiceManager MUST be destroyed before the browser | 290 // NOTE: The in-process ServiceManager MUST be destroyed before the browser |
| 291 // process-wide MojoShellConnection. Otherwise it's possible for the | 291 // process-wide MojoShellConnection. Otherwise it's possible for the |
| 292 // ServiceManager to receive connection requests for exe:content_browser which | 292 // ServiceManager to receive connection requests for service:content_browser |
| 293 // it may attempt to service by launching a new instance of the browser. | 293 // which it may attempt to service by launching a new instance of the browser. |
| 294 if (in_process_context_) | 294 if (in_process_context_) |
| 295 in_process_context_->ShutDown(); | 295 in_process_context_->ShutDown(); |
| 296 if (MojoShellConnection::GetForProcess()) | 296 if (MojoShellConnection::GetForProcess()) |
| 297 MojoShellConnection::DestroyForProcess(); | 297 MojoShellConnection::DestroyForProcess(); |
| 298 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 298 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 299 base::Bind(&DestroyConnectorOnIOThread)); | 299 base::Bind(&DestroyConnectorOnIOThread)); |
| 300 } | 300 } |
| 301 | 301 |
| 302 // static | 302 // static |
| 303 shell::Connector* MojoShellContext::GetConnectorForIOThread() { | 303 shell::Connector* MojoShellContext::GetConnectorForIOThread() { |
| 304 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 304 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 305 return g_io_thread_connector.Get().get(); | 305 return g_io_thread_connector.Get().get(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 } // namespace content | 308 } // namespace content |
| OLD | NEW |