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

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

Issue 2684433003: Files required by a service now listed in manifest. (Closed)
Patch Set: Addressed @boliu and @jam's comments. Created 3 years, 10 months 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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "content/browser/child_process_launcher.h"
18 #include "content/browser/gpu/gpu_process_host.h" 19 #include "content/browser/gpu/gpu_process_host.h"
19 #include "content/browser/service_manager/merge_dictionary.h" 20 #include "content/browser/service_manager/merge_dictionary.h"
20 #include "content/common/service_manager/service_manager_connection_impl.h" 21 #include "content/common/service_manager/service_manager_connection_impl.h"
21 #include "content/grit/content_resources.h" 22 #include "content/grit/content_resources.h"
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/content_browser_client.h" 24 #include "content/public/browser/content_browser_client.h"
24 #include "content/public/browser/utility_process_host.h" 25 #include "content/public/browser/utility_process_host.h"
25 #include "content/public/browser/utility_process_host_client.h" 26 #include "content/public/browser/utility_process_host_client.h"
26 #include "content/public/common/content_client.h" 27 #include "content/public/common/content_client.h"
27 #include "content/public/common/service_manager_connection.h" 28 #include "content/public/common/service_manager_connection.h"
28 #include "content/public/common/service_names.mojom.h" 29 #include "content/public/common/service_names.mojom.h"
29 #include "mojo/edk/embedder/embedder.h" 30 #include "mojo/edk/embedder/embedder.h"
30 #include "services/catalog/catalog.h" 31 #include "services/catalog/catalog.h"
31 #include "services/catalog/manifest_provider.h" 32 #include "services/catalog/manifest_provider.h"
33 #include "services/catalog/public/cpp/manifest_parsing_util.h"
32 #include "services/catalog/public/interfaces/constants.mojom.h" 34 #include "services/catalog/public/interfaces/constants.mojom.h"
33 #include "services/catalog/store.h" 35 #include "services/catalog/store.h"
34 #include "services/device/device_service.h" 36 #include "services/device/device_service.h"
35 #include "services/device/public/interfaces/constants.mojom.h" 37 #include "services/device/public/interfaces/constants.mojom.h"
36 #include "services/service_manager/connect_params.h" 38 #include "services/service_manager/connect_params.h"
37 #include "services/service_manager/public/cpp/connector.h" 39 #include "services/service_manager/public/cpp/connector.h"
38 #include "services/service_manager/public/cpp/service.h" 40 #include "services/service_manager/public/cpp/service.h"
39 #include "services/service_manager/public/interfaces/service.mojom.h" 41 #include "services/service_manager/public/interfaces/service.mojom.h"
40 #include "services/service_manager/runner/common/client_util.h" 42 #include "services/service_manager/runner/common/client_util.h"
41 #include "services/service_manager/service_manager.h" 43 #include "services/service_manager/service_manager.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 if (overlay_value) { 135 if (overlay_value) {
134 base::DictionaryValue* manifest_dictionary = nullptr; 136 base::DictionaryValue* manifest_dictionary = nullptr;
135 bool result = manifest_value->GetAsDictionary(&manifest_dictionary); 137 bool result = manifest_value->GetAsDictionary(&manifest_dictionary);
136 DCHECK(result); 138 DCHECK(result);
137 base::DictionaryValue* overlay_dictionary = nullptr; 139 base::DictionaryValue* overlay_dictionary = nullptr;
138 result = overlay_value->GetAsDictionary(&overlay_dictionary); 140 result = overlay_value->GetAsDictionary(&overlay_dictionary);
139 DCHECK(result); 141 DCHECK(result);
140 MergeDictionary(manifest_dictionary, overlay_dictionary); 142 MergeDictionary(manifest_dictionary, overlay_dictionary);
141 } 143 }
142 144
145 std::unique_ptr<catalog::RequiredFileMap> required_files =
146 base::MakeUnique<catalog::RequiredFileMap>();
147 if (catalog::PopulateRequiredFiles(*manifest_value, required_files.get())) {
148 ChildProcessLauncher::SetRegisteredFilesForService(
149 name.as_string(), std::move(required_files));
150 }
151
143 auto result = manifests_.insert( 152 auto result = manifests_.insert(
144 std::make_pair(name.as_string(), std::move(manifest_value))); 153 std::make_pair(name.as_string(), std::move(manifest_value)));
145 DCHECK(result.second) << "Duplicate manifest entry: " << name; 154 DCHECK(result.second) << "Duplicate manifest entry: " << name;
146 } 155 }
147 156
148 private: 157 private:
149 // catalog::ManifestProvider: 158 // catalog::ManifestProvider:
150 std::unique_ptr<base::Value> GetManifest(const std::string& name) override { 159 std::unique_ptr<base::Value> GetManifest(const std::string& name) override {
151 auto it = manifests_.find(name); 160 auto it = manifests_.find(name);
152 return it != manifests_.end() ? it->second->CreateDeepCopy() : nullptr; 161 return it != manifests_.end() ? it->second->CreateDeepCopy() : nullptr;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 ServiceManagerConnection::GetForProcess()->GetConnector()->Clone(); 306 ServiceManagerConnection::GetForProcess()->GetConnector()->Clone();
298 307
299 ServiceManagerConnection::GetForProcess()->Start(); 308 ServiceManagerConnection::GetForProcess()->Start();
300 309
301 ContentBrowserClient::OutOfProcessServiceMap sandboxed_services; 310 ContentBrowserClient::OutOfProcessServiceMap sandboxed_services;
302 GetContentClient() 311 GetContentClient()
303 ->browser() 312 ->browser()
304 ->RegisterOutOfProcessServices(&sandboxed_services); 313 ->RegisterOutOfProcessServices(&sandboxed_services);
305 for (const auto& service : sandboxed_services) { 314 for (const auto& service : sandboxed_services) {
306 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler( 315 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler(
307 service.first, 316 service.first, base::Bind(&StartServiceInUtilityProcess, service.first,
308 base::Bind(&StartServiceInUtilityProcess, service.first, service.second, 317 service.second, true /* use_sandbox */));
309 true /* use_sandbox */));
310 } 318 }
311 319
312 ContentBrowserClient::OutOfProcessServiceMap unsandboxed_services; 320 ContentBrowserClient::OutOfProcessServiceMap unsandboxed_services;
313 GetContentClient() 321 GetContentClient()
314 ->browser() 322 ->browser()
315 ->RegisterUnsandboxedOutOfProcessServices(&unsandboxed_services); 323 ->RegisterUnsandboxedOutOfProcessServices(&unsandboxed_services);
316 unsandboxed_services.insert( 324 unsandboxed_services.insert(
317 std::make_pair(shape_detection::mojom::kServiceName, 325 std::make_pair(shape_detection::mojom::kServiceName,
318 base::ASCIIToUTF16("Shape Detection Service"))); 326 base::ASCIIToUTF16("Shape Detection Service")));
319 for (const auto& service : unsandboxed_services) { 327 for (const auto& service : unsandboxed_services) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 base::Bind(&DestroyConnectorOnIOThread)); 359 base::Bind(&DestroyConnectorOnIOThread));
352 } 360 }
353 361
354 // static 362 // static
355 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { 363 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() {
356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 364 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
357 return g_io_thread_connector.Get().get(); 365 return g_io_thread_connector.Get().get();
358 } 366 }
359 367
360 } // namespace content 368 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698