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

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: 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 ae9969b9f98b80715253542251713da4f4c910f1..80b062bc5f8f7acdb3d541bd863745fb9f27c6ce 100644
--- a/content/browser/service_manager/service_manager_context.cc
+++ b/content/browser/service_manager/service_manager_context.cc
@@ -113,10 +113,31 @@ class BuiltinManifestProvider : public catalog::ManifestProvider {
BuiltinManifestProvider() {}
~BuiltinManifestProvider() override {}
- void AddManifestValue(const std::string& name,
- std::unique_ptr<base::Value> manifest_contents) {
+ void AddServiceManifest(std::string name, int resource_id) {
dcheng 2016/12/19 05:03:25 If you're feeling ambitious, StringPiece is probab
Sam McNally 2016/12/19 09:36:18 Done.
+ 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(std::move(name), std::move(manifest_value)));
DCHECK(result.second) << "Duplicate manifest entry: " << name;
}
@@ -237,30 +258,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(std::move(manifest.name),
+ manifest.resource_id);
}
in_process_context_ = new InProcessServiceManagerContext;
request = in_process_context_->Start(std::move(manifest_provider));

Powered by Google App Engine
This is Rietveld 408576698