| 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 <iosfwd> | 8 #include <iosfwd> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Return true if ARC has been enabled through a commandline | 96 // Return true if ARC has been enabled through a commandline |
| 97 // switch. | 97 // switch. |
| 98 static bool GetEnabled(const base::CommandLine* command_line); | 98 static bool GetEnabled(const base::CommandLine* command_line); |
| 99 | 99 |
| 100 // Return true if ARC is available on the current board. | 100 // Return true if ARC is available on the current board. |
| 101 static bool GetAvailable(const base::CommandLine* command_line); | 101 static bool GetAvailable(const base::CommandLine* command_line); |
| 102 | 102 |
| 103 // HandleStartup() should be called upon profile startup. This will only | 103 // HandleStartup() should be called upon profile startup. This will only |
| 104 // launch an instance if the instance is enabled. | 104 // launch an instance if the instance is enabled. |
| 105 // This can only be called on the thread that this class was created on. | 105 // This can only be called on the thread that this class was created on. |
| 106 virtual void HandleStartup() = 0; | |
| 107 | 106 |
| 108 // Shutdown() should be called when the browser is shutting down. This can | 107 // Starts the ARC service, then it will connect the Mojo channel. When the |
| 109 // only be called on the thread that this class was created on. | 108 // bridge becomes ready, OnBridgeReady() is called. |
| 110 virtual void Shutdown() = 0; | 109 virtual void RequestStart() = 0; |
| 110 |
| 111 // Stops the ARC service. |
| 112 virtual void RequestStop() = 0; |
| 113 |
| 114 // OnShutdown() should be called when the browser is shutting down. This can |
| 115 // only be called on the thread that this class was created on. We assume that |
| 116 // when this function is called, MessageLoop is no longer exists. |
| 117 virtual void OnShutdown() = 0; |
| 111 | 118 |
| 112 // Adds or removes observers. This can only be called on the thread that this | 119 // Adds or removes observers. This can only be called on the thread that this |
| 113 // class was created on. RemoveObserver does nothing if |observer| is not in | 120 // class was created on. RemoveObserver does nothing if |observer| is not in |
| 114 // the list. | 121 // the list. |
| 115 void AddObserver(Observer* observer); | 122 void AddObserver(Observer* observer); |
| 116 void RemoveObserver(Observer* observer); | 123 void RemoveObserver(Observer* observer); |
| 117 | 124 |
| 118 InstanceHolder<mojom::AppInstance>* app() { return &app_; } | 125 InstanceHolder<mojom::AppInstance>* app() { return &app_; } |
| 119 InstanceHolder<mojom::AudioInstance>* audio() { return &audio_; } | 126 InstanceHolder<mojom::AudioInstance>* audio() { return &audio_; } |
| 120 InstanceHolder<mojom::AuthInstance>* auth() { return &auth_; } | 127 InstanceHolder<mojom::AuthInstance>* auth() { return &auth_; } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 void SetStopReason(StopReason stop_reason); | 244 void SetStopReason(StopReason stop_reason); |
| 238 | 245 |
| 239 base::ObserverList<Observer>& observer_list() { return observer_list_; } | 246 base::ObserverList<Observer>& observer_list() { return observer_list_; } |
| 240 | 247 |
| 241 bool CalledOnValidThread(); | 248 bool CalledOnValidThread(); |
| 242 | 249 |
| 243 private: | 250 private: |
| 244 friend class ArcBridgeTest; | 251 friend class ArcBridgeTest; |
| 245 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); | 252 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); |
| 246 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); | 253 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); |
| 247 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); | 254 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, StopMidStartup); |
| 248 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart); | 255 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart); |
| 249 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, OnBridgeStopped); | 256 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, OnBridgeStopped); |
| 257 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Shutdown); |
| 250 | 258 |
| 251 base::ObserverList<Observer> observer_list_; | 259 base::ObserverList<Observer> observer_list_; |
| 252 | 260 |
| 253 base::ThreadChecker thread_checker_; | 261 base::ThreadChecker thread_checker_; |
| 254 | 262 |
| 255 // The current state of the bridge. | 263 // The current state of the bridge. |
| 256 ArcBridgeService::State state_; | 264 ArcBridgeService::State state_; |
| 257 | 265 |
| 258 // The reason the bridge is stopped. | 266 // The reason the bridge is stopped. |
| 259 StopReason stop_reason_; | 267 StopReason stop_reason_; |
| 260 | 268 |
| 261 // WeakPtrFactory to use callbacks. | 269 // WeakPtrFactory to use callbacks. |
| 262 base::WeakPtrFactory<ArcBridgeService> weak_factory_; | 270 base::WeakPtrFactory<ArcBridgeService> weak_factory_; |
| 263 | 271 |
| 264 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); | 272 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); |
| 265 }; | 273 }; |
| 266 | 274 |
| 267 // Defines "<<" operator for LOGging purpose. | 275 // Defines "<<" operator for LOGging purpose. |
| 268 std::ostream& operator<<( | 276 std::ostream& operator<<( |
| 269 std::ostream& os, ArcBridgeService::StopReason reason); | 277 std::ostream& os, ArcBridgeService::StopReason reason); |
| 270 | 278 |
| 271 } // namespace arc | 279 } // namespace arc |
| 272 | 280 |
| 273 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 281 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
| OLD | NEW |