Chromium Code Reviews| Index: components/arc/test/fake_arc_bridge_bootstrap.cc |
| diff --git a/components/arc/test/fake_arc_bridge_bootstrap.cc b/components/arc/test/fake_arc_bridge_bootstrap.cc |
| index 054ebad5b402fe32ad523cc944bdd527c240bc6e..4f594d25d29c422a04042769fe435b6446ac2ec3 100644 |
| --- a/components/arc/test/fake_arc_bridge_bootstrap.cc |
| +++ b/components/arc/test/fake_arc_bridge_bootstrap.cc |
| @@ -4,37 +4,55 @@ |
| #include "components/arc/test/fake_arc_bridge_bootstrap.h" |
| -#include <utility> |
| - |
| #include "base/logging.h" |
| -#include "components/arc/common/arc_bridge.mojom.h" |
| -#include "components/arc/test/fake_arc_bridge_instance.h" |
| -#include "mojo/public/cpp/bindings/interface_request.h" |
| +#include "base/memory/ptr_util.h" |
| namespace arc { |
| -FakeArcBridgeBootstrap::FakeArcBridgeBootstrap(FakeArcBridgeInstance* instance) |
| - : instance_(instance) { |
| - instance_->set_delegate(this); |
| -} |
| +FakeArcBridgeBootstrap::FakeArcBridgeBootstrap() = default; |
| + |
| +FakeArcBridgeBootstrap::~FakeArcBridgeBootstrap() = default; |
| void FakeArcBridgeBootstrap::Start() { |
| DCHECK(delegate_); |
| - mojom::ArcBridgeInstancePtr instance; |
| - instance_->Bind(mojo::GetProxy(&instance)); |
| - delegate_->OnConnectionEstablished(std::move(instance)); |
| + if (boot_failure_emulation_enabled_) { |
| + delegate_->OnStopped(boot_failure_reason_); |
| + } else if (!boot_suspended_) { |
| + mojom::ArcBridgeInstancePtr instance_ptr; |
| + instance_.Bind(mojo::GetProxy(&instance_ptr)); |
| + delegate_->OnConnectionEstablished(std::move(instance_ptr)); |
| + } |
| } |
| void FakeArcBridgeBootstrap::Stop() { |
| - DCHECK(delegate_); |
| - instance_->Unbind(); |
| - delegate_->OnStopped(ArcBridgeService::StopReason::SHUTDOWN); |
| + StopWithReason(ArcBridgeService::StopReason::SHUTDOWN); |
| } |
| -void FakeArcBridgeBootstrap::OnStopped(ArcBridgeService::StopReason reason) { |
| +void FakeArcBridgeBootstrap::StopWithReason( |
| + ArcBridgeService::StopReason reason) { |
| DCHECK(delegate_); |
| - instance_->Unbind(); |
| + instance_.Unbind(); |
| delegate_->OnStopped(reason); |
| } |
| +void FakeArcBridgeBootstrap::EnableBootFailureEmulation( |
| + ArcBridgeService::StopReason reason) { |
| + DCHECK(!boot_failure_emulation_enabled_); |
| + DCHECK(!boot_suspended_); |
| + |
| + boot_failure_emulation_enabled_ = true; |
| + boot_failure_reason_ = reason; |
| +} |
| + |
| +void FakeArcBridgeBootstrap::SuspendBoot() { |
| + DCHECK(!boot_failure_emulation_enabled_); |
| + DCHECK(!boot_suspended_); |
| + |
| + boot_suspended_ = true; |
| +} |
| + |
| +std::unique_ptr<ArcBridgeBootstrap> FakeArcBridgeBootstrap::Create() { |
|
Luis Héctor Chávez
2016/09/15 23:08:49
nit: //static.
hidehiko
2016/09/20 13:35:20
Done.
|
| + return base::MakeUnique<FakeArcBridgeBootstrap>(); |
| +} |
| + |
| } // namespace arc |