Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/arc/test/fake_arc_bridge_bootstrap.h" | 5 #include "components/arc/test/fake_arc_bridge_bootstrap.h" |
| 6 | 6 |
| 7 #include <utility> | |
|
Luis Héctor Chávez
2016/09/23 05:13:38
Why was this removed? You're still calling std::mo
hidehiko
2016/09/26 14:31:49
I removed std::move etc. at all in earlier PS so t
| |
| 8 | |
| 9 #include "base/logging.h" | 7 #include "base/logging.h" |
| 10 #include "components/arc/common/arc_bridge.mojom.h" | 8 #include "base/memory/ptr_util.h" |
| 11 #include "components/arc/test/fake_arc_bridge_instance.h" | |
| 12 #include "mojo/public/cpp/bindings/interface_request.h" | |
| 13 | 9 |
| 14 namespace arc { | 10 namespace arc { |
| 15 | 11 |
| 16 FakeArcBridgeBootstrap::FakeArcBridgeBootstrap(FakeArcBridgeInstance* instance) | 12 FakeArcBridgeBootstrap::FakeArcBridgeBootstrap() = default; |
| 17 : instance_(instance) { | 13 |
| 18 instance_->set_delegate(this); | 14 FakeArcBridgeBootstrap::~FakeArcBridgeBootstrap() = default; |
| 19 } | |
| 20 | 15 |
| 21 void FakeArcBridgeBootstrap::Start() { | 16 void FakeArcBridgeBootstrap::Start() { |
| 22 DCHECK(delegate_); | 17 DCHECK(delegate_); |
| 23 mojom::ArcBridgeInstancePtr instance; | 18 if (boot_failure_emulation_enabled_) { |
| 24 instance_->Bind(mojo::GetProxy(&instance)); | 19 delegate_->OnStopped(boot_failure_reason_); |
| 25 delegate_->OnConnectionEstablished(std::move(instance)); | 20 } else if (!boot_suspended_) { |
| 21 mojom::ArcBridgeInstancePtr instance_ptr; | |
| 22 instance_.Bind(mojo::GetProxy(&instance_ptr)); | |
| 23 delegate_->OnConnectionEstablished(std::move(instance_ptr)); | |
| 24 } | |
| 26 } | 25 } |
| 27 | 26 |
| 28 void FakeArcBridgeBootstrap::Stop() { | 27 void FakeArcBridgeBootstrap::Stop() { |
| 29 DCHECK(delegate_); | 28 StopWithReason(ArcBridgeService::StopReason::SHUTDOWN); |
| 30 instance_->Unbind(); | |
| 31 delegate_->OnStopped(ArcBridgeService::StopReason::SHUTDOWN); | |
| 32 } | 29 } |
| 33 | 30 |
| 34 void FakeArcBridgeBootstrap::OnStopped(ArcBridgeService::StopReason reason) { | 31 void FakeArcBridgeBootstrap::StopWithReason( |
| 32 ArcBridgeService::StopReason reason) { | |
| 35 DCHECK(delegate_); | 33 DCHECK(delegate_); |
| 36 instance_->Unbind(); | 34 instance_.Unbind(); |
| 37 delegate_->OnStopped(reason); | 35 delegate_->OnStopped(reason); |
| 38 } | 36 } |
| 39 | 37 |
| 38 void FakeArcBridgeBootstrap::EnableBootFailureEmulation( | |
| 39 ArcBridgeService::StopReason reason) { | |
| 40 DCHECK(!boot_failure_emulation_enabled_); | |
| 41 DCHECK(!boot_suspended_); | |
| 42 | |
| 43 boot_failure_emulation_enabled_ = true; | |
| 44 boot_failure_reason_ = reason; | |
| 45 } | |
| 46 | |
| 47 void FakeArcBridgeBootstrap::SuspendBoot() { | |
| 48 DCHECK(!boot_failure_emulation_enabled_); | |
| 49 DCHECK(!boot_suspended_); | |
| 50 | |
| 51 boot_suspended_ = true; | |
| 52 } | |
| 53 | |
| 54 // static | |
| 55 std::unique_ptr<ArcBridgeBootstrap> FakeArcBridgeBootstrap::Create() { | |
| 56 return base::MakeUnique<FakeArcBridgeBootstrap>(); | |
| 57 } | |
| 58 | |
| 40 } // namespace arc | 59 } // namespace arc |
| OLD | NEW |