| 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_session.h" | 5 #include "components/arc/test/fake_arc_session.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 | 11 |
| 12 namespace arc { | 12 namespace arc { |
| 13 | 13 |
| 14 FakeArcSession::FakeArcSession() = default; | 14 FakeArcSession::FakeArcSession() = default; |
| 15 | 15 |
| 16 FakeArcSession::~FakeArcSession() = default; | 16 FakeArcSession::~FakeArcSession() = default; |
| 17 | 17 |
| 18 void FakeArcSession::Start() { | 18 void FakeArcSession::Start() { |
| 19 if (boot_failure_emulation_enabled_) { | 19 if (boot_failure_emulation_enabled_) { |
| 20 for (auto& observer : observer_list_) | 20 for (auto& observer : observer_list_) |
| 21 observer.OnStopped(boot_failure_reason_); | 21 observer.OnSessionStopped(boot_failure_reason_); |
| 22 } else if (!boot_suspended_) { | 22 } else if (!boot_suspended_) { |
| 23 for (auto& observer : observer_list_) | 23 for (auto& observer : observer_list_) |
| 24 observer.OnReady(); | 24 observer.OnSessionReady(); |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 | 27 |
| 28 void FakeArcSession::Stop() { | 28 void FakeArcSession::Stop() { |
| 29 StopWithReason(ArcBridgeService::StopReason::SHUTDOWN); | 29 StopWithReason(ArcSessionObserver::StopReason::SHUTDOWN); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void FakeArcSession::OnShutdown() { | 32 void FakeArcSession::OnShutdown() { |
| 33 StopWithReason(ArcBridgeService::StopReason::SHUTDOWN); | 33 StopWithReason(ArcSessionObserver::StopReason::SHUTDOWN); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void FakeArcSession::StopWithReason(ArcBridgeService::StopReason reason) { | 36 void FakeArcSession::StopWithReason(ArcSessionObserver::StopReason reason) { |
| 37 for (auto& observer : observer_list_) | 37 for (auto& observer : observer_list_) |
| 38 observer.OnStopped(reason); | 38 observer.OnSessionStopped(reason); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void FakeArcSession::EnableBootFailureEmulation( | 41 void FakeArcSession::EnableBootFailureEmulation( |
| 42 ArcBridgeService::StopReason reason) { | 42 ArcSessionObserver::StopReason reason) { |
| 43 DCHECK(!boot_failure_emulation_enabled_); | 43 DCHECK(!boot_failure_emulation_enabled_); |
| 44 DCHECK(!boot_suspended_); | 44 DCHECK(!boot_suspended_); |
| 45 | 45 |
| 46 boot_failure_emulation_enabled_ = true; | 46 boot_failure_emulation_enabled_ = true; |
| 47 boot_failure_reason_ = reason; | 47 boot_failure_reason_ = reason; |
| 48 } | 48 } |
| 49 | 49 |
| 50 void FakeArcSession::SuspendBoot() { | 50 void FakeArcSession::SuspendBoot() { |
| 51 DCHECK(!boot_failure_emulation_enabled_); | 51 DCHECK(!boot_failure_emulation_enabled_); |
| 52 DCHECK(!boot_suspended_); | 52 DCHECK(!boot_suspended_); |
| 53 | 53 |
| 54 boot_suspended_ = true; | 54 boot_suspended_ = true; |
| 55 } | 55 } |
| 56 | 56 |
| 57 // static | 57 // static |
| 58 std::unique_ptr<ArcSession> FakeArcSession::Create() { | 58 std::unique_ptr<ArcSession> FakeArcSession::Create() { |
| 59 return base::MakeUnique<FakeArcSession>(); | 59 return base::MakeUnique<FakeArcSession>(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace arc | 62 } // namespace arc |
| OLD | NEW |