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

Unified Diff: services/catalog/instance.cc

Issue 2573283002: Use a static catalog manifest for the standalone Mash runner (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
« 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 cdcef14427c6d15c64faeae1c2825846c84a3318..65ebc0a9ed9075ba54ed9126cfa08f6666e0c6fc 100644
--- a/services/catalog/instance.cc
+++ b/services/catalog/instance.cc
@@ -8,7 +8,6 @@
#include "services/catalog/entry.h"
#include "services/catalog/manifest_provider.h"
#include "services/catalog/reader.h"
-#include "services/catalog/store.h"
namespace catalog {
namespace {
@@ -22,13 +21,8 @@ void AddEntry(const Entry& entry, std::vector<mojom::EntryPtr>* ary) {
} // namespace
-////////////////////////////////////////////////////////////////////////////////
-// Instance, public:
+Instance::Instance(Reader* system_reader) : system_reader_(system_reader) {}
-Instance::Instance(std::unique_ptr<Store> store, Reader* system_reader)
- : store_(std::move(store)),
- system_reader_(system_reader),
- weak_factory_(this) {}
Instance::~Instance() {}
void Instance::BindResolver(service_manager::mojom::ResolverRequest request) {
@@ -47,18 +41,14 @@ void Instance::BindCatalog(mojom::CatalogRequest request) {
void Instance::CacheReady(EntryCache* cache) {
system_cache_ = cache;
- DeserializeCatalog();
for (auto& request : pending_resolver_requests_)
BindResolver(std::move(request));
for (auto& request : pending_catalog_requests_)
BindCatalog(std::move(request));
}
-////////////////////////////////////////////////////////////////////////////////
-// Instance, service_manager::mojom::Resolver:
-
-void Instance::ResolveMojoName(const std::string& service_name,
- const ResolveMojoNameCallback& callback) {
+void Instance::ResolveServiceName(const std::string& service_name,
+ const ResolveServiceNameCallback& callback) {
DCHECK(system_cache_);
// TODO(beng): per-user catalogs.
@@ -68,17 +58,9 @@ void Instance::ResolveMojoName(const std::string& service_name,
return;
}
- // Manifests for mojo: names should always be in the catalog by this point.
- // DCHECK(type == service_manager::kNameType_Exe);
- system_reader_->CreateEntryForName(
- service_name, system_cache_,
- base::Bind(&Instance::OnReadManifest, weak_factory_.GetWeakPtr(),
- service_name, callback));
+ system_reader_->CreateEntryForName(service_name, system_cache_, callback);
}
-////////////////////////////////////////////////////////////////////////////////
-// Instance, mojom::Catalog:
-
void Instance::GetEntries(const base::Optional<std::vector<std::string>>& names,
const GetEntriesCallback& callback) {
DCHECK(system_cache_);
@@ -124,45 +106,4 @@ void Instance::GetEntriesSupportingScheme(
// TODO(beng): implement.
}
-////////////////////////////////////////////////////////////////////////////////
-// Instance, private:
-
-void Instance::DeserializeCatalog() {
- DCHECK(system_cache_);
- if (!store_)
- return;
- const base::ListValue* catalog = store_->GetStore();
- CHECK(catalog);
- // TODO(sky): make this handle aliases.
- // TODO(beng): implement this properly!
- for (const auto& v : *catalog) {
- const base::DictionaryValue* dictionary = nullptr;
- CHECK(v->GetAsDictionary(&dictionary));
- std::unique_ptr<Entry> entry = Entry::Deserialize(*dictionary);
- // TODO(beng): user catalog.
- if (entry)
- (*system_cache_)[entry->name()] = std::move(entry);
- }
-}
-
-void Instance::SerializeCatalog() {
- DCHECK(system_cache_);
- std::unique_ptr<base::ListValue> catalog(new base::ListValue);
- // TODO(beng): user catalog.
- for (const auto& entry : *system_cache_)
- catalog->Append(entry.second->Serialize());
- if (store_)
- store_->UpdateStore(std::move(catalog));
-}
-
-// static
-void Instance::OnReadManifest(base::WeakPtr<Instance> instance,
- const std::string& service_name,
- const ResolveMojoNameCallback& callback,
- service_manager::mojom::ResolveResultPtr result) {
- callback.Run(std::move(result));
- if (instance)
- instance->SerializeCatalog();
-}
-
} // namespace catalog
« 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