| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/arc/test/fake_arc_bridge_bootstrap.h" | |
| 6 | |
| 7 #include <memory> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "base/memory/ptr_util.h" | |
| 11 | |
| 12 namespace arc { | |
| 13 | |
| 14 FakeArcBridgeBootstrap::FakeArcBridgeBootstrap() = default; | |
| 15 | |
| 16 FakeArcBridgeBootstrap::~FakeArcBridgeBootstrap() = default; | |
| 17 | |
| 18 void FakeArcBridgeBootstrap::Start() { | |
| 19 if (boot_failure_emulation_enabled_) { | |
| 20 for (auto& observer : observer_list_) | |
| 21 observer.OnStopped(boot_failure_reason_); | |
| 22 } else if (!boot_suspended_) { | |
| 23 for (auto& observer : observer_list_) | |
| 24 observer.OnReady(); | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 void FakeArcBridgeBootstrap::Stop() { | |
| 29 StopWithReason(ArcBridgeService::StopReason::SHUTDOWN); | |
| 30 } | |
| 31 | |
| 32 void FakeArcBridgeBootstrap::StopWithReason( | |
| 33 ArcBridgeService::StopReason reason) { | |
| 34 for (auto& observer : observer_list_) | |
| 35 observer.OnStopped(reason); | |
| 36 } | |
| 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 | |
| 59 } // namespace arc | |
| OLD | NEW |