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

Unified Diff: services/catalog/instance.cc

Issue 2651953002: Revert of [Service Manager] Get rid of dynamic service discovery (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/catalog/instance.h ('k') | services/catalog/public/tools/catalog.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/catalog/instance.cc
diff --git a/services/catalog/instance.cc b/services/catalog/instance.cc
index 348106b7eb1db41d68a83fdc3e02a7fc7601e1f7..dd177ef8c4e078bb5ae0d502763676e289c0f861 100644
--- a/services/catalog/instance.cc
+++ b/services/catalog/instance.cc
@@ -4,13 +4,11 @@
#include "services/catalog/instance.h"
-#include <memory>
-
#include "base/bind.h"
-#include "base/values.h"
#include "services/catalog/entry.h"
#include "services/catalog/entry_cache.h"
#include "services/catalog/manifest_provider.h"
+#include "services/catalog/reader.h"
namespace catalog {
namespace {
@@ -24,19 +22,30 @@
} // namespace
-Instance::Instance(EntryCache* system_cache,
- ManifestProvider* service_manifest_provider)
- : system_cache_(system_cache),
- service_manifest_provider_(service_manifest_provider) {}
+Instance::Instance(Reader* system_reader) : system_reader_(system_reader) {}
Instance::~Instance() {}
void Instance::BindResolver(service_manager::mojom::ResolverRequest request) {
- resolver_bindings_.AddBinding(this, std::move(request));
+ if (system_cache_)
+ resolver_bindings_.AddBinding(this, std::move(request));
+ else
+ pending_resolver_requests_.push_back(std::move(request));
}
void Instance::BindCatalog(mojom::CatalogRequest request) {
- catalog_bindings_.AddBinding(this, std::move(request));
+ if (system_cache_)
+ catalog_bindings_.AddBinding(this, std::move(request));
+ else
+ pending_catalog_requests_.push_back(std::move(request));
+}
+
+void Instance::CacheReady(EntryCache* cache) {
+ system_cache_ = cache;
+ for (auto& request : pending_resolver_requests_)
+ BindResolver(std::move(request));
+ for (auto& request : pending_catalog_requests_)
+ BindCatalog(std::move(request));
}
void Instance::ResolveServiceName(const std::string& service_name,
@@ -49,27 +58,9 @@
callback.Run(service_manager::mojom::ResolveResult::From(entry),
service_manager::mojom::ResolveResult::From(entry->parent()));
return;
- } else if (service_manifest_provider_) {
- auto manifest = service_manifest_provider_->GetManifest(service_name);
- if (manifest) {
- auto entry = Entry::Deserialize(*manifest);
- if (entry) {
- callback.Run(
- service_manager::mojom::ResolveResult::From(
- const_cast<const Entry*>(entry.get())),
- service_manager::mojom::ResolveResult::From(entry->parent()));
-
- bool added = system_cache_->AddRootEntry(std::move(entry));
- DCHECK(added);
- return;
- } else {
- LOG(ERROR) << "Received malformed manifest for " << service_name;
- }
- }
}
- LOG(ERROR) << "Unable to locate service manifest for " << service_name;
- callback.Run(nullptr, nullptr);
+ system_reader_->CreateEntryForName(service_name, system_cache_, callback);
}
void Instance::GetEntries(const base::Optional<std::vector<std::string>>& names,
« no previous file with comments | « services/catalog/instance.h ('k') | services/catalog/public/tools/catalog.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698