OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CHROMEOS_DBUS_UPDATE_ENGINE_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_UPDATE_ENGINE_CLIENT_H_ |
6 #define CHROMEOS_DBUS_UPDATE_ENGINE_CLIENT_H_ | 6 #define CHROMEOS_DBUS_UPDATE_ENGINE_CLIENT_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "chromeos/chromeos_export.h" | 10 #include "chromeos/chromeos_export.h" |
11 #include "chromeos/dbus/dbus_client_implementation_type.h" | 11 #include "chromeos/dbus/dbus_client_implementation_type.h" |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 namespace dbus { | 15 namespace dbus { |
16 class Bus; | 16 class Bus; |
17 } // namespace | 17 } |
18 | 18 |
19 namespace chromeos { | 19 namespace chromeos { |
20 | 20 |
21 // UpdateEngineClient is used to communicate with the update engine. | 21 // UpdateEngineClient is used to communicate with the update engine. |
22 class CHROMEOS_EXPORT UpdateEngineClient { | 22 class CHROMEOS_EXPORT UpdateEngineClient { |
23 public: | 23 public: |
24 // Edges for state machine | 24 // Edges for state machine |
25 // IDLE->CHECKING_FOR_UPDATE | 25 // IDLE->CHECKING_FOR_UPDATE |
26 // CHECKING_FOR_UPDATE->IDLE | 26 // CHECKING_FOR_UPDATE->IDLE |
27 // CHECKING_FOR_UPDATE->UPDATE_AVAILABLE | 27 // CHECKING_FOR_UPDATE->UPDATE_AVAILABLE |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Called once RequestUpdateCheck() is complete. Takes one parameter: | 80 // Called once RequestUpdateCheck() is complete. Takes one parameter: |
81 // - UpdateCheckResult: the result of the update check. | 81 // - UpdateCheckResult: the result of the update check. |
82 typedef base::Callback<void(UpdateCheckResult)> UpdateCheckCallback; | 82 typedef base::Callback<void(UpdateCheckResult)> UpdateCheckCallback; |
83 | 83 |
84 // Requests an update check and calls |callback| when completed. | 84 // Requests an update check and calls |callback| when completed. |
85 virtual void RequestUpdateCheck(const UpdateCheckCallback& callback) = 0; | 85 virtual void RequestUpdateCheck(const UpdateCheckCallback& callback) = 0; |
86 | 86 |
87 // Reboots if update has been performed. | 87 // Reboots if update has been performed. |
88 virtual void RebootAfterUpdate() = 0; | 88 virtual void RebootAfterUpdate() = 0; |
89 | 89 |
| 90 // DEPRECATED: Use SetChannel instead. |
90 // Requests to set the release track (channel). |track| should look like | 91 // Requests to set the release track (channel). |track| should look like |
91 // "beta-channel" or "dev-channel". | 92 // "beta-channel" or "dev-channel". |
92 virtual void SetReleaseTrack(const std::string& track) = 0; | 93 virtual void SetReleaseTrack(const std::string& track) = 0; |
93 | 94 |
94 // Called once GetReleaseTrack() is complete. Takes one parameter; | 95 // Called once GetReleaseTrack() is complete. Takes one parameter; |
95 // - string: the release track name like "beta-channel". | 96 // - string: the release track name like "beta-channel". |
96 typedef base::Callback<void(const std::string&)> GetReleaseTrackCallback; | 97 typedef base::Callback<void(const std::string& channel_name)> |
| 98 GetReleaseTrackCallback; |
97 | 99 |
| 100 // Called once GetChannel() is complete. Takes one parameter; |
| 101 // - string: the channel name like "beta-channel". |
| 102 typedef base::Callback<void(const std::string& channel_name)> |
| 103 GetChannelCallback; |
| 104 |
| 105 // DEPRECATED: Use GetChannel() instead. |
98 // Requests to get the release track and calls |callback| with the | 106 // Requests to get the release track and calls |callback| with the |
99 // release track (channel). On error, calls |callback| with an empty | 107 // release track (channel). On error, calls |callback| with an empty |
100 // string. | 108 // string. |
101 virtual void GetReleaseTrack(const GetReleaseTrackCallback& callback) = 0; | 109 virtual void GetReleaseTrack(const GetReleaseTrackCallback& callback) = 0; |
102 | 110 |
103 // Returns the last status the object received from the update engine. | 111 // Returns the last status the object received from the update engine. |
104 // | 112 // |
105 // Ideally, the D-Bus client should be state-less, but there are clients | 113 // Ideally, the D-Bus client should be state-less, but there are clients |
106 // that need this information. | 114 // that need this information. |
107 virtual Status GetLastStatus() = 0; | 115 virtual Status GetLastStatus() = 0; |
108 | 116 |
| 117 // Changes the current channel of the device to the target |
| 118 // channel. If the target channel is a less stable channel than the |
| 119 // current channel, then the channel change happens immediately (at |
| 120 // the next update check). If the target channel is a more stable |
| 121 // channel, then if |is_powerwash_allowed| is set to true, then also |
| 122 // the change happens immediately but with a powerwash if |
| 123 // required. Otherwise, the change takes effect eventually (when the |
| 124 // version on the target channel goes above the version number of |
| 125 // what the device currently has). |target_channel| should look like |
| 126 // "dev-channel", "beta-channel" or "stable-channel". |
| 127 virtual void SetChannel(const std::string& target_channel, |
| 128 bool is_powerwash_allowed) = 0; |
| 129 |
| 130 // If |get_current_channel| is set to true, calls |callback| with |
| 131 // the name of the channel that the device is currently |
| 132 // on. Otherwise, it calls it with the name of the channel the |
| 133 // device is supposed to be (in case of a pending channel |
| 134 // change). On error, calls |callback| with an empty string. |
| 135 virtual void GetChannel(bool get_current_channel, |
| 136 const GetChannelCallback& callback) = 0; |
| 137 |
109 // Returns an empty UpdateCheckCallback that does nothing. | 138 // Returns an empty UpdateCheckCallback that does nothing. |
110 static UpdateCheckCallback EmptyUpdateCheckCallback(); | 139 static UpdateCheckCallback EmptyUpdateCheckCallback(); |
111 | 140 |
112 // Creates the instance. | 141 // Creates the instance. |
113 static UpdateEngineClient* Create(DBusClientImplementationType type, | 142 static UpdateEngineClient* Create(DBusClientImplementationType type, |
114 dbus::Bus* bus); | 143 dbus::Bus* bus); |
115 | 144 |
116 protected: | 145 protected: |
117 // Create() should be used instead. | 146 // Create() should be used instead. |
118 UpdateEngineClient(); | 147 UpdateEngineClient(); |
119 | 148 |
120 private: | 149 private: |
121 DISALLOW_COPY_AND_ASSIGN(UpdateEngineClient); | 150 DISALLOW_COPY_AND_ASSIGN(UpdateEngineClient); |
122 }; | 151 }; |
123 | 152 |
124 } // namespace chromeos | 153 } // namespace chromeos |
125 | 154 |
126 #endif // CHROMEOS_DBUS_UPDATE_ENGINE_CLIENT_H_ | 155 #endif // CHROMEOS_DBUS_UPDATE_ENGINE_CLIENT_H_ |
OLD | NEW |