Chromium Code Reviews| Index: components/arc/arc_bridge_bootstrap.cc |
| diff --git a/components/arc/arc_bridge_bootstrap.cc b/components/arc/arc_bridge_bootstrap.cc |
| index 1d7a94f55178b590325f95b1ce23fff6f1c2afb5..a7e860ef8bad09e106e478dc24f8f63e533a1778 100644 |
| --- a/components/arc/arc_bridge_bootstrap.cc |
| +++ b/components/arc/arc_bridge_bootstrap.cc |
| @@ -34,6 +34,8 @@ namespace arc { |
| namespace { |
| +ArcBridgeBootstrap* g_bootstrap_for_testing = nullptr; |
| + |
| // We do not know the PID of ARC, since Chrome does not create it directly. |
| // Since Mojo in POSIX does not use the child PID except as an unique |
| // identifier for the routing table, rather than doing a lot of plumbing in the |
| @@ -341,11 +343,31 @@ void ArcBridgeBootstrapImpl::SetState(State state) { |
| } // namespace |
| ArcBridgeBootstrap::ArcBridgeBootstrap() {} |
| -ArcBridgeBootstrap::~ArcBridgeBootstrap() {} |
| + |
| +ArcBridgeBootstrap::~ArcBridgeBootstrap() { |
| + if (g_bootstrap_for_testing) { |
| + delete g_bootstrap_for_testing; |
| + } |
| +} |
| // static |
| scoped_ptr<ArcBridgeBootstrap> ArcBridgeBootstrap::Create() { |
| - return make_scoped_ptr(new ArcBridgeBootstrapImpl()); |
| + if (g_bootstrap_for_testing) { |
| + ArcBridgeBootstrap *result = g_bootstrap_for_testing; |
|
bartfab (slow)
2016/03/07 13:44:04
Nit 1: const pointer.
Nit 2: Move the * to the typ
Polina Bondarenko
2016/03/09 17:59:15
Done.
|
| + g_bootstrap_for_testing = nullptr; |
| + return make_scoped_ptr(result); |
| + } else { |
| + return make_scoped_ptr(new ArcBridgeBootstrapImpl()); |
| + } |
| +} |
| + |
| +// static |
| +void ArcBridgeBootstrap::SetBootstrapForTesting( |
| + scoped_ptr<ArcBridgeBootstrap> bootstrap) { |
| + if (g_bootstrap_for_testing) { |
| + delete g_bootstrap_for_testing; |
| + } |
| + g_bootstrap_for_testing = bootstrap.release(); |
| } |
| } // namespace arc |