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

Unified Diff: components/arc/arc_service_manager.cc

Issue 1684063002: Add ArcEnabled policy implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@26869593
Patch Set: Inject ArcBridgeService for testing. Created 4 years, 9 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 | « components/arc/arc_service_manager.h ('k') | components/arc/test/fake_arc_bridge_bootstrap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/arc_service_manager.cc
diff --git a/components/arc/arc_service_manager.cc b/components/arc/arc_service_manager.cc
index 9563358882366ef55ed533b5c0829aa875478ff8..6907813a146b5efc06b2a2315c380d77e376583c 100644
--- a/components/arc/arc_service_manager.cc
+++ b/components/arc/arc_service_manager.cc
@@ -22,14 +22,23 @@ namespace {
// Weak pointer. This class is owned by ChromeBrowserMainPartsChromeos.
ArcServiceManager* g_arc_service_manager = nullptr;
+// This pointer is owned by ArcServiceManager.
+ArcBridgeService* g_arc_bridge_service_for_testing = nullptr;
hidehiko 2016/03/16 16:45:35 Could you avoid the global var here? Would it be p
Polina Bondarenko 2016/03/17 13:40:28 Fixed: 1) Create ArcServiceManager(fake arc_bridge
+
} // namespace
-ArcServiceManager::ArcServiceManager()
- : arc_bridge_service_(
- new ArcBridgeServiceImpl(ArcBridgeBootstrap::Create())) {
+ArcServiceManager::ArcServiceManager() {
DCHECK(!g_arc_service_manager);
g_arc_service_manager = this;
+ if (g_arc_bridge_service_for_testing) {
+ arc_bridge_service_.reset(g_arc_bridge_service_for_testing);
+ g_arc_bridge_service_for_testing = nullptr;
+ } else {
+ arc_bridge_service_.reset(new ArcBridgeServiceImpl(
+ ArcBridgeBootstrap::Create()));
+ }
+
AddService(make_scoped_ptr(new ArcClipboardBridge(arc_bridge_service())));
AddService(make_scoped_ptr(new ArcImeBridge(arc_bridge_service())));
AddService(make_scoped_ptr(new ArcInputBridge(arc_bridge_service())));
@@ -41,6 +50,9 @@ ArcServiceManager::~ArcServiceManager() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(g_arc_service_manager == this);
g_arc_service_manager = nullptr;
+ if (g_arc_bridge_service_for_testing) {
+ delete g_arc_bridge_service_for_testing;
+ }
}
// static
@@ -69,4 +81,13 @@ void ArcServiceManager::OnPrimaryUserProfilePrepared(
new ArcNotificationManager(arc_bridge_service(), account_id)));
}
+//static
+void ArcServiceManager::SetArcBridgeServiceForTesting(
+ scoped_ptr<ArcBridgeService> arc_bridge_service) {
+ if (g_arc_bridge_service_for_testing) {
+ delete g_arc_bridge_service_for_testing;
+ }
+ g_arc_bridge_service_for_testing = arc_bridge_service.release();
+}
+
} // namespace arc
« no previous file with comments | « components/arc/arc_service_manager.h ('k') | components/arc/test/fake_arc_bridge_bootstrap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698