Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 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 #ifndef CHROMEOS_ARC_BRIDGE_ARC_BRIDGE_SERVICE_H_ | |
| 6 #define CHROMEOS_ARC_BRIDGE_ARC_BRIDGE_SERVICE_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/observer_list.h" | |
| 10 #include "chromeos/arc/libarcbridge/arc_bridge.h" | |
| 11 #include "chromeos/dbus/dbus_method_call_status.h" | |
| 12 #include "components/keyed_service/core/keyed_service.h" | |
| 13 | |
| 14 class Profile; | |
|
oshima
2015/10/23 20:29:45
chromeos/ should not depend on Profile
Luis Héctor Chávez
2015/10/27 00:37:47
Done.
| |
| 15 | |
| 16 namespace arc { | |
| 17 | |
| 18 class ArcBridgeService : public KeyedService, public BridgeHostEndpoint { | |
|
satorux1
2015/10/23 06:10:58
class comment is missing. please describe what thi
Luis Héctor Chávez
2015/10/27 00:37:47
Done.
| |
| 19 public: | |
| 20 class Observer { | |
| 21 public: | |
| 22 // Called whenever an instance start request has finished. | |
| 23 virtual void OnInstanceStarted(bool success) {} | |
| 24 | |
| 25 // Called when an instance is ready for interaction. | |
| 26 virtual void OnInstanceReady() {} | |
| 27 | |
| 28 // Called when an instance has stopped. This is not called if | |
| 29 // OnInstanceStarted() was called with |success| = false. | |
| 30 virtual void OnInstanceStopped() {} | |
| 31 | |
| 32 protected: | |
| 33 virtual ~Observer() {} | |
| 34 }; | |
| 35 | |
| 36 explicit ArcBridgeService(Profile* profile); | |
| 37 virtual ~ArcBridgeService(); | |
| 38 | |
| 39 // HandleStartup() should be called upon profile startup. This will only | |
| 40 // launch an instance if the instance service is available and it is enabled. | |
| 41 void HandleStartup(); | |
| 42 | |
| 43 // Shuts down the running instance, if any. This is safe to call even if | |
| 44 // there is no instance running. | |
| 45 void Shutdown(); | |
| 46 | |
| 47 // Add or remove observers. | |
|
satorux1
2015/10/23 06:10:58
nit: Adds or removes
Luis Héctor Chávez
2015/10/27 00:37:48
Done.
| |
| 48 void AddObserver(Observer* observer); | |
| 49 void RemoveObserver(Observer* observer); | |
| 50 | |
| 51 // Methods to access preferences. | |
| 52 bool IsEnabled() { return enabled_; } | |
| 53 | |
| 54 // TODO(lhchavez): Setup a persistent Prefs object to store the setting. | |
| 55 void SetEnabled(bool enabled) { enabled_ = enabled; } | |
| 56 | |
| 57 bool IsRunning() const { return running_; } | |
|
satorux1
2015/10/23 06:10:58
function comment is missing.
// Returns true if t
Luis Héctor Chávez
2015/10/27 00:37:47
Done.
| |
| 58 | |
| 59 private: | |
| 60 // DBus callbacks. | |
| 61 void OnInstanceStarted(chromeos::DBusMethodCallStatus status, bool success); | |
| 62 void OnInstanceStopped(chromeos::DBusMethodCallStatus status); | |
| 63 | |
| 64 // arc::BridgeHostEndpoint overrides: | |
| 65 void OnInstanceReady() override; | |
| 66 void OnPong() override; | |
| 67 | |
| 68 // List of observers to notify of state changes. | |
| 69 // Makes sure list is empty on destruction. | |
| 70 base::ObserverList<Observer, true> observer_list_; | |
| 71 | |
| 72 // TODO(lhchavez): Move to a real preference. | |
| 73 bool enabled_; | |
| 74 | |
| 75 bool connected_; | |
| 76 bool running_; | |
|
satorux1
2015/10/23 06:10:58
enabled_, connected_, running_ sound similar to me
Luis Héctor Chávez
2015/10/27 00:37:47
Changed to an enum.
| |
| 77 Profile* profile_; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); | |
| 80 }; | |
| 81 | |
| 82 } // namespace arc | |
| 83 | |
| 84 #endif // CHROMEOS_ARC_BRIDGE_ARC_BRIDGE_SERVICE_H_ | |
| OLD | NEW |