| 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 #ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 5 #ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
| 6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/files/scoped_file.h" | |
| 12 #include "base/gtest_prod_util.h" | |
| 13 #include "base/macros.h" | 11 #include "base/macros.h" |
| 14 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 15 #include "base/values.h" | |
| 16 #include "components/arc/common/arc_bridge.mojom.h" | 13 #include "components/arc/common/arc_bridge.mojom.h" |
| 17 #include "components/arc/instance_holder.h" | 14 #include "components/arc/instance_holder.h" |
| 18 | 15 |
| 19 namespace base { | 16 namespace base { |
| 20 class CommandLine; | 17 class CommandLine; |
| 21 } // namespace base | 18 } // namespace base |
| 22 | 19 |
| 23 namespace arc { | 20 namespace arc { |
| 24 | 21 |
| 25 class ArcBridgeTest; | 22 class ArcBridgeTest; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 InstanceHolder<mojom::VideoInstance>* video() { return &video_; } | 115 InstanceHolder<mojom::VideoInstance>* video() { return &video_; } |
| 119 | 116 |
| 120 // Gets if ARC is currently running. | 117 // Gets if ARC is currently running. |
| 121 bool ready() const { return state() == State::READY; } | 118 bool ready() const { return state() == State::READY; } |
| 122 | 119 |
| 123 // Gets if ARC is currently stopped. This is not exactly !ready() since there | 120 // Gets if ARC is currently stopped. This is not exactly !ready() since there |
| 124 // are transient states between ready() and stopped(). | 121 // are transient states between ready() and stopped(). |
| 125 bool stopped() const { return state() == State::STOPPED; } | 122 bool stopped() const { return state() == State::STOPPED; } |
| 126 | 123 |
| 127 protected: | 124 protected: |
| 125 // TODO(hidehiko): This state is obsolete. Clean this up. |
| 128 // The possible states of the bridge. In the normal flow, the state changes | 126 // The possible states of the bridge. In the normal flow, the state changes |
| 129 // in the following sequence: | 127 // in the following sequence: |
| 130 // | 128 // |
| 131 // STOPPED | 129 // STOPPED |
| 132 // PrerequisitesChanged() -> | 130 // PrerequisitesChanged() -> |
| 133 // CONNECTING | 131 // CONNECTING |
| 134 // OnConnectionEstablished() -> | 132 // OnConnectionEstablished() -> |
| 135 // READY | 133 // READY |
| 136 // | 134 // |
| 137 // The ArcBridgeBootstrap state machine can be thought of being substates of | 135 // The ArcBridgeBootstrap state machine can be thought of being substates of |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // Sets the reason the bridge is stopped. This function must be always called | 191 // Sets the reason the bridge is stopped. This function must be always called |
| 194 // before SetState(State::STOPPED) to report a correct reason with | 192 // before SetState(State::STOPPED) to report a correct reason with |
| 195 // Observer::OnBridgeStopped(). | 193 // Observer::OnBridgeStopped(). |
| 196 void SetStopReason(StopReason stop_reason); | 194 void SetStopReason(StopReason stop_reason); |
| 197 | 195 |
| 198 base::ObserverList<Observer>& observer_list() { return observer_list_; } | 196 base::ObserverList<Observer>& observer_list() { return observer_list_; } |
| 199 | 197 |
| 200 bool CalledOnValidThread(); | 198 bool CalledOnValidThread(); |
| 201 | 199 |
| 202 private: | 200 private: |
| 203 friend class ArcBridgeTest; | |
| 204 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); | |
| 205 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); | |
| 206 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); | |
| 207 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart); | |
| 208 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, OnBridgeStopped); | |
| 209 | |
| 210 base::ObserverList<Observer> observer_list_; | 201 base::ObserverList<Observer> observer_list_; |
| 211 | 202 |
| 212 base::ThreadChecker thread_checker_; | 203 base::ThreadChecker thread_checker_; |
| 213 | 204 |
| 214 // The current state of the bridge. | 205 // The current state of the bridge. |
| 215 ArcBridgeService::State state_; | 206 ArcBridgeService::State state_; |
| 216 | 207 |
| 217 // The reason the bridge is stopped. | 208 // The reason the bridge is stopped. |
| 218 StopReason stop_reason_; | 209 StopReason stop_reason_; |
| 219 | 210 |
| 220 // WeakPtrFactory to use callbacks. | 211 // WeakPtrFactory to use callbacks. |
| 221 base::WeakPtrFactory<ArcBridgeService> weak_factory_; | 212 base::WeakPtrFactory<ArcBridgeService> weak_factory_; |
| 222 | 213 |
| 223 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); | 214 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); |
| 224 }; | 215 }; |
| 225 | 216 |
| 226 } // namespace arc | 217 } // namespace arc |
| 227 | 218 |
| 228 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 219 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
| OLD | NEW |