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

Unified Diff: components/arc/arc_bridge_service_impl.h

Issue 2194193002: Fix ArcBridgeBootstrap race issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 3 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_bridge_service.cc ('k') | components/arc/arc_bridge_service_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/arc_bridge_service_impl.h
diff --git a/components/arc/arc_bridge_service_impl.h b/components/arc/arc_bridge_service_impl.h
index a9b5c44ccc5f21aa823ace2ef3e07fd1c160e56f..872582bc64b09989a9bba8a12795f07f97b60df7 100644
--- a/components/arc/arc_bridge_service_impl.h
+++ b/components/arc/arc_bridge_service_impl.h
@@ -27,13 +27,26 @@ namespace arc {
class ArcBridgeServiceImpl : public ArcBridgeService,
public ArcBridgeBootstrap::Delegate {
public:
- explicit ArcBridgeServiceImpl(std::unique_ptr<ArcBridgeBootstrap> bootstrap);
+ // This is the factory interface to inject ArcBridgeBootstrap instance
+ // for testing purpose.
+ using ArcBridgeBootstrapFactory =
+ base::Callback<std::unique_ptr<ArcBridgeBootstrap>()>;
+
+ ArcBridgeServiceImpl();
~ArcBridgeServiceImpl() override;
void HandleStartup() override;
void Shutdown() override;
+ // Inject a factory to create ArcBridgeBootstrap instance for testing
+ // purpose. |factory| must not be null.
+ void SetArcBridgeBootstrapFactoryForTesting(
+ const ArcBridgeBootstrapFactory& factory);
+
+ // Returns the current bootstrap instance for testing purpose.
+ ArcBridgeBootstrap* GetBootstrapForTesting() { return bootstrap_.get(); }
+
// Normally, reconnecting after connection shutdown happens after a short
// delay. When testing, however, we'd like it to happen immediately to avoid
// adding unnecessary delays.
@@ -72,6 +85,9 @@ class ArcBridgeServiceImpl : public ArcBridgeService,
// Delay the reconnection.
bool use_delay_before_reconnecting_ = true;
+ // Factory to inject a fake ArcBridgeBootstrap instance for testing.
+ ArcBridgeBootstrapFactory factory_;
+
// WeakPtrFactory to use callbacks.
base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_;
« no previous file with comments | « components/arc/arc_bridge_service.cc ('k') | components/arc/arc_bridge_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698