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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_manager/service_manager_context.cc
diff --git a/content/browser/service_manager/service_manager_context.cc b/content/browser/service_manager/service_manager_context.cc
index 7eab3423c23ccac10a4ee7ca4639dc0d406bd2ba..c6076ce6e0b7c1cb56f9c433032dd5dc5718b80d 100644
--- a/content/browser/service_manager/service_manager_context.cc
+++ b/content/browser/service_manager/service_manager_context.cc
@@ -114,10 +114,31 @@ class BuiltinManifestProvider : public catalog::ManifestProvider {
BuiltinManifestProvider() {}
~BuiltinManifestProvider() override {}
- void AddManifestValue(const std::string& name,
- std::unique_ptr<base::Value> manifest_contents) {
+ void AddServiceManifest(base::StringPiece name, int resource_id) {
+ std::string contents =
+ GetContentClient()
+ ->GetDataResource(resource_id, ui::ScaleFactor::SCALE_FACTOR_NONE)
+ .as_string();
+ DCHECK(!contents.empty());
+
+ std::unique_ptr<base::Value> manifest_value =
+ base::JSONReader::Read(contents);
+ DCHECK(manifest_value);
+
+ std::unique_ptr<base::Value> overlay_value =
+ GetContentClient()->browser()->GetServiceManifestOverlay(name);
+ if (overlay_value) {
+ base::DictionaryValue* manifest_dictionary = nullptr;
+ bool result = manifest_value->GetAsDictionary(&manifest_dictionary);
+ DCHECK(result);
+ base::DictionaryValue* overlay_dictionary = nullptr;
+ result = overlay_value->GetAsDictionary(&overlay_dictionary);
+ DCHECK(result);
+ MergeDictionary(manifest_dictionary, overlay_dictionary);
+ }
+
auto result = manifests_.insert(
- std::make_pair(name, std::move(manifest_contents)));
+ std::make_pair(name.as_string(), std::move(manifest_value)));
DCHECK(result.second) << "Duplicate manifest entry: " << name;
}
@@ -238,30 +259,13 @@ ServiceManagerContext::ServiceManagerContext() {
};
for (size_t i = 0; i < arraysize(kManifests); ++i) {
- std::string contents = GetContentClient()->GetDataResource(
- kManifests[i].resource_id,
- ui::ScaleFactor::SCALE_FACTOR_NONE).as_string();
- base::debug::Alias(&i);
- CHECK(!contents.empty());
-
- std::unique_ptr<base::Value> manifest_value =
- base::JSONReader::Read(contents);
- base::debug::Alias(&contents);
- CHECK(manifest_value);
-
- std::unique_ptr<base::Value> overlay_value =
- GetContentClient()->browser()->GetServiceManifestOverlay(
- kManifests[i].name);
- if (overlay_value) {
- base::DictionaryValue* manifest_dictionary = nullptr;
- CHECK(manifest_value->GetAsDictionary(&manifest_dictionary));
- base::DictionaryValue* overlay_dictionary = nullptr;
- CHECK(overlay_value->GetAsDictionary(&overlay_dictionary));
- MergeDictionary(manifest_dictionary, overlay_dictionary);
- }
-
- manifest_provider->AddManifestValue(kManifests[i].name,
- std::move(manifest_value));
+ manifest_provider->AddServiceManifest(kManifests[i].name,
+ kManifests[i].resource_id);
+ }
+ for (const auto& manifest :
+ GetContentClient()->browser()->GetExtraServiceManifests()) {
+ manifest_provider->AddServiceManifest(manifest.name,
+ manifest.resource_id);
}
in_process_context_ = new InProcessServiceManagerContext;
request = in_process_context_->Start(std::move(manifest_provider));
« 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