Chromium Code Reviews| 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..8d9b90cf556f5181bc8e4c68b759ef8a03941e01 100644 |
| --- a/components/arc/arc_bridge_service_impl.h |
| +++ b/components/arc/arc_bridge_service_impl.h |
| @@ -27,13 +27,28 @@ 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) { |
| + factory_ = factory; |
|
Luis Héctor Chávez
2016/09/23 05:13:38
nit: maybe add a DCHECK(!factory.is_null()) to enf
hidehiko
2016/09/26 14:31:49
Done. Moved to .cc.
|
| + } |
| + |
| + // 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 +87,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_; |