Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Side by Side Diff: content/browser/service_manager/service_manager_context.cc

Issue 2501913002: Change the NaCl loader and broker processes to use the ServiceManager. (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 #endif // ENABLE_MOJO_MEDIA_IN_GPU_PROCESS 108 #endif // ENABLE_MOJO_MEDIA_IN_GPU_PROCESS
109 109
110 // A ManifestProvider which resolves application names to builtin manifest 110 // A ManifestProvider which resolves application names to builtin manifest
111 // resources for the catalog service to consume. 111 // resources for the catalog service to consume.
112 class BuiltinManifestProvider : public catalog::ManifestProvider { 112 class BuiltinManifestProvider : public catalog::ManifestProvider {
113 public: 113 public:
114 BuiltinManifestProvider() {} 114 BuiltinManifestProvider() {}
115 ~BuiltinManifestProvider() override {} 115 ~BuiltinManifestProvider() override {}
116 116
117 void AddManifestValue(const std::string& name, 117 void AddServiceManifest(base::StringPiece name, int resource_id) {
118 std::unique_ptr<base::Value> manifest_contents) { 118 std::string contents =
119 GetContentClient()
120 ->GetDataResource(resource_id, ui::ScaleFactor::SCALE_FACTOR_NONE)
121 .as_string();
122 DCHECK(!contents.empty());
123
124 std::unique_ptr<base::Value> manifest_value =
125 base::JSONReader::Read(contents);
126 DCHECK(manifest_value);
127
128 std::unique_ptr<base::Value> overlay_value =
129 GetContentClient()->browser()->GetServiceManifestOverlay(name);
130 if (overlay_value) {
131 base::DictionaryValue* manifest_dictionary = nullptr;
132 bool result = manifest_value->GetAsDictionary(&manifest_dictionary);
133 DCHECK(result);
134 base::DictionaryValue* overlay_dictionary = nullptr;
135 result = overlay_value->GetAsDictionary(&overlay_dictionary);
136 DCHECK(result);
137 MergeDictionary(manifest_dictionary, overlay_dictionary);
138 }
139
119 auto result = manifests_.insert( 140 auto result = manifests_.insert(
120 std::make_pair(name, std::move(manifest_contents))); 141 std::make_pair(name.as_string(), std::move(manifest_value)));
121 DCHECK(result.second) << "Duplicate manifest entry: " << name; 142 DCHECK(result.second) << "Duplicate manifest entry: " << name;
122 } 143 }
123 144
124 private: 145 private:
125 // catalog::ManifestProvider: 146 // catalog::ManifestProvider:
126 std::unique_ptr<base::Value> GetManifest(const std::string& name) override { 147 std::unique_ptr<base::Value> GetManifest(const std::string& name) override {
127 auto it = manifests_.find(name); 148 auto it = manifests_.find(name);
128 return it != manifests_.end() ? it->second->CreateDeepCopy() : nullptr; 149 return it != manifests_.end() ? it->second->CreateDeepCopy() : nullptr;
129 } 150 }
130 151
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 { mojom::kBrowserServiceName, IDR_MOJO_CONTENT_BROWSER_MANIFEST }, 252 { mojom::kBrowserServiceName, IDR_MOJO_CONTENT_BROWSER_MANIFEST },
232 { mojom::kGpuServiceName, IDR_MOJO_CONTENT_GPU_MANIFEST }, 253 { mojom::kGpuServiceName, IDR_MOJO_CONTENT_GPU_MANIFEST },
233 { mojom::kPluginServiceName, IDR_MOJO_CONTENT_PLUGIN_MANIFEST }, 254 { mojom::kPluginServiceName, IDR_MOJO_CONTENT_PLUGIN_MANIFEST },
234 { mojom::kRendererServiceName, IDR_MOJO_CONTENT_RENDERER_MANIFEST }, 255 { mojom::kRendererServiceName, IDR_MOJO_CONTENT_RENDERER_MANIFEST },
235 { mojom::kUtilityServiceName, IDR_MOJO_CONTENT_UTILITY_MANIFEST }, 256 { mojom::kUtilityServiceName, IDR_MOJO_CONTENT_UTILITY_MANIFEST },
236 { catalog::mojom::kServiceName, IDR_MOJO_CATALOG_MANIFEST }, 257 { catalog::mojom::kServiceName, IDR_MOJO_CATALOG_MANIFEST },
237 { file::mojom::kServiceName, IDR_MOJO_FILE_MANIFEST } 258 { file::mojom::kServiceName, IDR_MOJO_FILE_MANIFEST }
238 }; 259 };
239 260
240 for (size_t i = 0; i < arraysize(kManifests); ++i) { 261 for (size_t i = 0; i < arraysize(kManifests); ++i) {
241 std::string contents = GetContentClient()->GetDataResource( 262 manifest_provider->AddServiceManifest(kManifests[i].name,
242 kManifests[i].resource_id, 263 kManifests[i].resource_id);
243 ui::ScaleFactor::SCALE_FACTOR_NONE).as_string(); 264 }
244 base::debug::Alias(&i); 265 for (const auto& manifest :
245 CHECK(!contents.empty()); 266 GetContentClient()->browser()->GetExtraServiceManifests()) {
246 267 manifest_provider->AddServiceManifest(manifest.name,
247 std::unique_ptr<base::Value> manifest_value = 268 manifest.resource_id);
248 base::JSONReader::Read(contents);
249 base::debug::Alias(&contents);
250 CHECK(manifest_value);
251
252 std::unique_ptr<base::Value> overlay_value =
253 GetContentClient()->browser()->GetServiceManifestOverlay(
254 kManifests[i].name);
255 if (overlay_value) {
256 base::DictionaryValue* manifest_dictionary = nullptr;
257 CHECK(manifest_value->GetAsDictionary(&manifest_dictionary));
258 base::DictionaryValue* overlay_dictionary = nullptr;
259 CHECK(overlay_value->GetAsDictionary(&overlay_dictionary));
260 MergeDictionary(manifest_dictionary, overlay_dictionary);
261 }
262
263 manifest_provider->AddManifestValue(kManifests[i].name,
264 std::move(manifest_value));
265 } 269 }
266 in_process_context_ = new InProcessServiceManagerContext; 270 in_process_context_ = new InProcessServiceManagerContext;
267 request = in_process_context_->Start(std::move(manifest_provider)); 271 request = in_process_context_->Start(std::move(manifest_provider));
268 } 272 }
269 ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create( 273 ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create(
270 std::move(request), 274 std::move(request),
271 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); 275 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)));
272 276
273 ContentBrowserClient::StaticServiceMap services; 277 ContentBrowserClient::StaticServiceMap services;
274 GetContentClient()->browser()->RegisterInProcessServices(&services); 278 GetContentClient()->browser()->RegisterInProcessServices(&services);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 base::Bind(&DestroyConnectorOnIOThread)); 330 base::Bind(&DestroyConnectorOnIOThread));
327 } 331 }
328 332
329 // static 333 // static
330 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { 334 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() {
331 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
332 return g_io_thread_connector.Get().get(); 336 return g_io_thread_connector.Get().get();
333 } 337 }
334 338
335 } // namespace content 339 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_child_process_host_impl.cc ('k') | content/public/browser/browser_child_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698