Chromium Code Reviews| 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/service_manager/service_manager_context.h" | 5 #include "content/browser/service_manager/service_manager_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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 | 108 |
| 109 #endif // ENABLE_MOJO_MEDIA_IN_GPU_PROCESS | 109 #endif // ENABLE_MOJO_MEDIA_IN_GPU_PROCESS |
| 110 | 110 |
| 111 // A ManifestProvider which resolves application names to builtin manifest | 111 // A ManifestProvider which resolves application names to builtin manifest |
| 112 // resources for the catalog service to consume. | 112 // resources for the catalog service to consume. |
| 113 class BuiltinManifestProvider : public catalog::ManifestProvider { | 113 class BuiltinManifestProvider : public catalog::ManifestProvider { |
| 114 public: | 114 public: |
| 115 BuiltinManifestProvider() {} | 115 BuiltinManifestProvider() {} |
| 116 ~BuiltinManifestProvider() override {} | 116 ~BuiltinManifestProvider() override {} |
| 117 | 117 |
| 118 void AddManifestValue(const std::string& name, | 118 void AddServiceManifest(std::string name, int resource_id) { |
| 119 std::unique_ptr<base::Value> manifest_contents) { | 119 std::string contents = |
| 120 GetContentClient() | |
| 121 ->GetDataResource(resource_id, ui::ScaleFactor::SCALE_FACTOR_NONE) | |
| 122 .as_string(); | |
| 123 CHECK(!contents.empty()); | |
|
piman
2016/11/28 23:04:37
If these are to investigate a bug, please document
Sam McNally
2016/11/28 23:33:22
Ken: thoughts?
Ken Rockot(use gerrit already)
2016/11/28 23:47:22
I'd rather just leave the CHECKs in. They aren't n
Sam McNally
2016/11/29 03:30:14
Changed to DCHECKs.
| |
| 124 | |
| 125 std::unique_ptr<base::Value> manifest_value = | |
| 126 base::JSONReader::Read(contents); | |
| 127 base::debug::Alias(&contents); | |
| 128 CHECK(manifest_value); | |
| 129 | |
| 130 std::unique_ptr<base::Value> overlay_value = | |
| 131 GetContentClient()->browser()->GetServiceManifestOverlay(name); | |
| 132 if (overlay_value) { | |
| 133 base::DictionaryValue* manifest_dictionary = nullptr; | |
| 134 CHECK(manifest_value->GetAsDictionary(&manifest_dictionary)); | |
| 135 base::DictionaryValue* overlay_dictionary = nullptr; | |
| 136 CHECK(overlay_value->GetAsDictionary(&overlay_dictionary)); | |
| 137 MergeDictionary(manifest_dictionary, overlay_dictionary); | |
| 138 } | |
| 139 | |
| 120 auto result = manifests_.insert( | 140 auto result = manifests_.insert( |
| 121 std::make_pair(name, std::move(manifest_contents))); | 141 std::make_pair(std::move(name), std::move(manifest_value))); |
| 122 DCHECK(result.second) << "Duplicate manifest entry: " << name; | 142 DCHECK(result.second) << "Duplicate manifest entry: " << name; |
| 123 } | 143 } |
| 124 | 144 |
| 125 private: | 145 private: |
| 126 // catalog::ManifestProvider: | 146 // catalog::ManifestProvider: |
| 127 std::unique_ptr<base::Value> GetManifest(const std::string& name) override { | 147 std::unique_ptr<base::Value> GetManifest(const std::string& name) override { |
| 128 auto it = manifests_.find(name); | 148 auto it = manifests_.find(name); |
| 129 return it != manifests_.end() ? it->second->CreateDeepCopy() : nullptr; | 149 return it != manifests_.end() ? it->second->CreateDeepCopy() : nullptr; |
| 130 } | 150 } |
| 131 | 151 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 { mojom::kBrowserServiceName, IDR_MOJO_CONTENT_BROWSER_MANIFEST }, | 236 { mojom::kBrowserServiceName, IDR_MOJO_CONTENT_BROWSER_MANIFEST }, |
| 217 { mojom::kGpuServiceName, IDR_MOJO_CONTENT_GPU_MANIFEST }, | 237 { mojom::kGpuServiceName, IDR_MOJO_CONTENT_GPU_MANIFEST }, |
| 218 { mojom::kPluginServiceName, IDR_MOJO_CONTENT_PLUGIN_MANIFEST }, | 238 { mojom::kPluginServiceName, IDR_MOJO_CONTENT_PLUGIN_MANIFEST }, |
| 219 { mojom::kRendererServiceName, IDR_MOJO_CONTENT_RENDERER_MANIFEST }, | 239 { mojom::kRendererServiceName, IDR_MOJO_CONTENT_RENDERER_MANIFEST }, |
| 220 { mojom::kUtilityServiceName, IDR_MOJO_CONTENT_UTILITY_MANIFEST }, | 240 { mojom::kUtilityServiceName, IDR_MOJO_CONTENT_UTILITY_MANIFEST }, |
| 221 { catalog::mojom::kServiceName, IDR_MOJO_CATALOG_MANIFEST }, | 241 { catalog::mojom::kServiceName, IDR_MOJO_CATALOG_MANIFEST }, |
| 222 { file::mojom::kServiceName, IDR_MOJO_FILE_MANIFEST } | 242 { file::mojom::kServiceName, IDR_MOJO_FILE_MANIFEST } |
| 223 }; | 243 }; |
| 224 | 244 |
| 225 for (size_t i = 0; i < arraysize(kManifests); ++i) { | 245 for (size_t i = 0; i < arraysize(kManifests); ++i) { |
| 226 std::string contents = GetContentClient()->GetDataResource( | |
| 227 kManifests[i].resource_id, | |
| 228 ui::ScaleFactor::SCALE_FACTOR_NONE).as_string(); | |
| 229 base::debug::Alias(&i); | 246 base::debug::Alias(&i); |
| 230 CHECK(!contents.empty()); | 247 manifest_provider->AddServiceManifest(kManifests[i].name, |
| 231 | 248 kManifests[i].resource_id); |
| 232 std::unique_ptr<base::Value> manifest_value = | 249 } |
| 233 base::JSONReader::Read(contents); | 250 for (const auto& manifest : |
| 234 base::debug::Alias(&contents); | 251 GetContentClient()->browser()->GetExtraServiceManifests()) { |
| 235 CHECK(manifest_value); | 252 manifest_provider->AddServiceManifest(std::move(manifest.name), |
| 236 | 253 manifest.resource_id); |
| 237 std::unique_ptr<base::Value> overlay_value = | |
| 238 GetContentClient()->browser()->GetServiceManifestOverlay( | |
| 239 kManifests[i].name); | |
| 240 if (overlay_value) { | |
| 241 base::DictionaryValue* manifest_dictionary = nullptr; | |
| 242 CHECK(manifest_value->GetAsDictionary(&manifest_dictionary)); | |
| 243 base::DictionaryValue* overlay_dictionary = nullptr; | |
| 244 CHECK(overlay_value->GetAsDictionary(&overlay_dictionary)); | |
| 245 MergeDictionary(manifest_dictionary, overlay_dictionary); | |
| 246 } | |
| 247 | |
| 248 manifest_provider->AddManifestValue(kManifests[i].name, | |
| 249 std::move(manifest_value)); | |
| 250 } | 254 } |
| 251 in_process_context_ = new InProcessServiceManagerContext; | 255 in_process_context_ = new InProcessServiceManagerContext; |
| 252 request = in_process_context_->Start(std::move(manifest_provider)); | 256 request = in_process_context_->Start(std::move(manifest_provider)); |
| 253 } | 257 } |
| 254 ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create( | 258 ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create( |
| 255 std::move(request), | 259 std::move(request), |
| 256 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); | 260 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); |
| 257 | 261 |
| 258 ContentBrowserClient::StaticServiceMap services; | 262 ContentBrowserClient::StaticServiceMap services; |
| 259 GetContentClient()->browser()->RegisterInProcessServices(&services); | 263 GetContentClient()->browser()->RegisterInProcessServices(&services); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 base::Bind(&DestroyConnectorOnIOThread)); | 315 base::Bind(&DestroyConnectorOnIOThread)); |
| 312 } | 316 } |
| 313 | 317 |
| 314 // static | 318 // static |
| 315 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { | 319 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { |
| 316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 320 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 317 return g_io_thread_connector.Get().get(); | 321 return g_io_thread_connector.Get().get(); |
| 318 } | 322 } |
| 319 | 323 |
| 320 } // namespace content | 324 } // namespace content |
| OLD | NEW |