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

Unified Diff: components/arc/arc_service_manager.cc

Issue 2622843002: arc: Provide a per-service getter for ArcServiceManager (Closed)
Patch Set: I forgot how to ::type 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: components/arc/arc_service_manager.cc
diff --git a/components/arc/arc_service_manager.cc b/components/arc/arc_service_manager.cc
index 9204fef44844ccd7fc9ea29da2e6ba91aaba29fe..e4911e8a9157b8cc34c2c126af56dc171a0e8d49 100644
--- a/components/arc/arc_service_manager.cc
+++ b/components/arc/arc_service_manager.cc
@@ -4,8 +4,6 @@
#include "components/arc/arc_service_manager.h"
-#include <utility>
-
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/task_runner.h"
@@ -75,11 +73,28 @@ ArcBridgeService* ArcServiceManager::arc_bridge_service() {
return arc_bridge_service_.get();
}
-void ArcServiceManager::AddService(std::unique_ptr<ArcService> service) {
+void ArcServiceManager::AddServiceInternal(
+ std::unique_ptr<ArcService> service) {
DCHECK(thread_checker_.CalledOnValidThread());
services_.emplace_back(std::move(service));
}
+void ArcServiceManager::AddNamedServiceInternal(
+ const std::string& name,
+ std::unique_ptr<ArcService> service) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(named_services_.find(name) == named_services_.end());
Yusuke Sato 2017/01/10 07:11:10 What about making this a CHECK? Otherwise, L87 wil
Luis Héctor Chávez 2017/01/10 18:41:55 CHECKs are frowned upon outside of base/. I will a
+ named_services_.insert(std::make_pair(name, std::move(service)));
hidehiko 2017/01/10 08:03:12 emplace?
Luis Héctor Chávez 2017/01/10 18:41:55 emplace is not supported for maps: https://chromiu
hidehiko 2017/01/11 05:17:44 Oh, good to know. Thank you!
+}
+
+ArcService* ArcServiceManager::GetNamedServiceInternal(
+ const std::string& name) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ auto service = named_services_.find(name);
+ DCHECK(service != named_services_.end());
+ return service->second.get();
+}
+
void ArcServiceManager::AddObserver(Observer* observer) {
DCHECK(thread_checker_.CalledOnValidThread());
observer_list_.AddObserver(observer);
@@ -100,6 +115,7 @@ void ArcServiceManager::Shutdown() {
icon_loader_ = nullptr;
activity_resolver_ = nullptr;
services_.clear();
+ named_services_.clear();
}
} // namespace arc
« components/arc/arc_service_manager.h ('K') | « components/arc/arc_service_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698