| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/arc_bridge_service.h" | 5 #include "components/arc/arc_bridge_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 12 #include "chromeos/chromeos_switches.h" | 12 #include "chromeos/chromeos_switches.h" |
| 13 #include "components/arc/arc_bridge_service_impl.h" | 13 #include "components/arc/arc_bridge_service_impl.h" |
| 14 | 14 |
| 15 namespace arc { | 15 namespace arc { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // Weak pointer. This class is owned by ArcServiceManager. | 19 // Weak pointer. This class is owned by ArcServiceManager. |
| 20 ArcBridgeService* g_arc_bridge_service = nullptr; | 20 ArcBridgeService* g_arc_bridge_service = nullptr; |
| 21 | 21 |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 ArcBridgeService::ArcBridgeService() | 24 ArcBridgeService::ArcBridgeService() |
| 25 : available_(false), state_(State::STOPPED) { | 25 : video_service_(nullptr), available_(false), state_(State::STOPPED) { |
| 26 DCHECK(!g_arc_bridge_service); | 26 DCHECK(!g_arc_bridge_service); |
| 27 g_arc_bridge_service = this; | 27 g_arc_bridge_service = this; |
| 28 } | 28 } |
| 29 | 29 |
| 30 ArcBridgeService::~ArcBridgeService() { | 30 ArcBridgeService::~ArcBridgeService() { |
| 31 DCHECK(CalledOnValidThread()); | 31 DCHECK(CalledOnValidThread()); |
| 32 DCHECK(state() == State::STOPPING || state() == State::STOPPED); | 32 DCHECK(state() == State::STOPPING || state() == State::STOPPED); |
| 33 DCHECK(g_arc_bridge_service == this); | 33 DCHECK(g_arc_bridge_service == this); |
| 34 g_arc_bridge_service = nullptr; | 34 g_arc_bridge_service = nullptr; |
| 35 } | 35 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 void ArcBridgeService::AddProcessObserver(ProcessObserver* observer) { | 80 void ArcBridgeService::AddProcessObserver(ProcessObserver* observer) { |
| 81 DCHECK(CalledOnValidThread()); | 81 DCHECK(CalledOnValidThread()); |
| 82 process_observer_list_.AddObserver(observer); | 82 process_observer_list_.AddObserver(observer); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void ArcBridgeService::RemoveProcessObserver(ProcessObserver* observer) { | 85 void ArcBridgeService::RemoveProcessObserver(ProcessObserver* observer) { |
| 86 DCHECK(CalledOnValidThread()); | 86 DCHECK(CalledOnValidThread()); |
| 87 process_observer_list_.RemoveObserver(observer); | 87 process_observer_list_.RemoveObserver(observer); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void ArcBridgeService::SetVideoService(VideoService* service) { |
| 91 DCHECK(CalledOnValidThread()); |
| 92 video_service_ = service; |
| 93 } |
| 94 |
| 90 void ArcBridgeService::SetState(State state) { | 95 void ArcBridgeService::SetState(State state) { |
| 91 DCHECK(CalledOnValidThread()); | 96 DCHECK(CalledOnValidThread()); |
| 92 // DCHECK on enum classes not supported. | 97 // DCHECK on enum classes not supported. |
| 93 DCHECK(state_ != state); | 98 DCHECK(state_ != state); |
| 94 state_ = state; | 99 state_ = state; |
| 95 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); | 100 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); |
| 96 } | 101 } |
| 97 | 102 |
| 98 void ArcBridgeService::SetAvailable(bool available) { | 103 void ArcBridgeService::SetAvailable(bool available) { |
| 99 DCHECK(CalledOnValidThread()); | 104 DCHECK(CalledOnValidThread()); |
| 100 DCHECK(available_ != available); | 105 DCHECK(available_ != available); |
| 101 available_ = available; | 106 available_ = available; |
| 102 FOR_EACH_OBSERVER(Observer, observer_list(), OnAvailableChanged(available_)); | 107 FOR_EACH_OBSERVER(Observer, observer_list(), OnAvailableChanged(available_)); |
| 103 } | 108 } |
| 104 | 109 |
| 105 bool ArcBridgeService::CalledOnValidThread() { | 110 bool ArcBridgeService::CalledOnValidThread() { |
| 106 return thread_checker_.CalledOnValidThread(); | 111 return thread_checker_.CalledOnValidThread(); |
| 107 } | 112 } |
| 108 | 113 |
| 109 } // namespace arc | 114 } // namespace arc |
| OLD | NEW |