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

Unified Diff: services/catalog/instance.cc

Issue 2611183006: Service Manager: Miscellaneous catalog cleanup (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
Index: services/catalog/instance.cc
diff --git a/services/catalog/instance.cc b/services/catalog/instance.cc
index 65ebc0a9ed9075ba54ed9126cfa08f6666e0c6fc..dd177ef8c4e078bb5ae0d502763676e289c0f861 100644
--- a/services/catalog/instance.cc
+++ b/services/catalog/instance.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "services/catalog/entry.h"
+#include "services/catalog/entry_cache.h"
#include "services/catalog/manifest_provider.h"
#include "services/catalog/reader.h"
@@ -52,9 +53,10 @@ void Instance::ResolveServiceName(const std::string& service_name,
DCHECK(system_cache_);
// TODO(beng): per-user catalogs.
- auto entry = system_cache_->find(service_name);
- if (entry != system_cache_->end()) {
- callback.Run(service_manager::mojom::ResolveResult::From(*entry->second));
+ const Entry* entry = system_cache_->GetEntry(service_name);
+ if (entry) {
+ callback.Run(service_manager::mojom::ResolveResult::From(entry),
+ service_manager::mojom::ResolveResult::From(entry->parent()));
return;
}
@@ -68,17 +70,14 @@ void Instance::GetEntries(const base::Optional<std::vector<std::string>>& names,
std::vector<mojom::EntryPtr> entries;
if (!names.has_value()) {
// TODO(beng): user catalog.
- for (const auto& entry : *system_cache_)
+ for (const auto& entry : system_cache_->entries())
AddEntry(*entry.second, &entries);
} else {
for (const std::string& name : names.value()) {
- Entry* entry = nullptr;
+ const Entry* entry = system_cache_->GetEntry(name);
// TODO(beng): user catalog.
- if (system_cache_->find(name) != system_cache_->end())
- entry = (*system_cache_)[name].get();
- else
- continue;
- AddEntry(*entry, &entries);
+ if (entry)
+ AddEntry(*entry, &entries);
}
}
callback.Run(std::move(entries));
@@ -88,7 +87,7 @@ void Instance::GetEntriesProvidingCapability(
const std::string& capability,
const GetEntriesProvidingCapabilityCallback& callback) {
std::vector<mojom::EntryPtr> entries;
- for (const auto& entry : *system_cache_)
+ for (const auto& entry : system_cache_->entries())
if (entry.second->ProvidesCapability(capability))
entries.push_back(mojom::Entry::From(*entry.second));
callback.Run(std::move(entries));

Powered by Google App Engine
This is Rietveld 408576698