| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 enum UpdateStatusOperation { | 33 enum UpdateStatusOperation { |
| 34 UPDATE_STATUS_ERROR = -1, | 34 UPDATE_STATUS_ERROR = -1, |
| 35 UPDATE_STATUS_IDLE = 0, | 35 UPDATE_STATUS_IDLE = 0, |
| 36 UPDATE_STATUS_CHECKING_FOR_UPDATE, | 36 UPDATE_STATUS_CHECKING_FOR_UPDATE, |
| 37 UPDATE_STATUS_UPDATE_AVAILABLE, | 37 UPDATE_STATUS_UPDATE_AVAILABLE, |
| 38 UPDATE_STATUS_DOWNLOADING, | 38 UPDATE_STATUS_DOWNLOADING, |
| 39 UPDATE_STATUS_VERIFYING, | 39 UPDATE_STATUS_VERIFYING, |
| 40 UPDATE_STATUS_FINALIZING, | 40 UPDATE_STATUS_FINALIZING, |
| 41 UPDATE_STATUS_UPDATED_NEED_REBOOT, | 41 UPDATE_STATUS_UPDATED_NEED_REBOOT, |
| 42 UPDATE_STATUS_REPORTING_ERROR_EVENT, | 42 UPDATE_STATUS_REPORTING_ERROR_EVENT, |
| 43 UPDATE_STATUS_ATTEMPTING_ROLLBACK | 43 UPDATE_STATUS_ATTEMPTING_ROLLBACK, |
| 44 UPDATE_STATUS_NEED_PERMISSION_TO_UPDATE, |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 // The status of the ongoing update attempt. | 47 // The status of the ongoing update attempt. |
| 47 struct Status { | 48 struct Status { |
| 48 Status() : status(UPDATE_STATUS_IDLE), | 49 Status() : status(UPDATE_STATUS_IDLE), |
| 49 download_progress(0.0), | 50 download_progress(0.0), |
| 50 last_checked_time(0), | 51 last_checked_time(0), |
| 51 new_size(0) { | 52 new_size(0) { |
| 52 } | 53 } |
| 53 | 54 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 77 ~UpdateEngineClient() override; | 78 ~UpdateEngineClient() override; |
| 78 | 79 |
| 79 // Adds and removes the observer. | 80 // Adds and removes the observer. |
| 80 virtual void AddObserver(Observer* observer) = 0; | 81 virtual void AddObserver(Observer* observer) = 0; |
| 81 virtual void RemoveObserver(Observer* observer) = 0; | 82 virtual void RemoveObserver(Observer* observer) = 0; |
| 82 // Returns true if this object has the given observer. | 83 // Returns true if this object has the given observer. |
| 83 virtual bool HasObserver(const Observer* observer) const = 0; | 84 virtual bool HasObserver(const Observer* observer) const = 0; |
| 84 | 85 |
| 85 // Called once RequestUpdateCheck() is complete. Takes one parameter: | 86 // Called once RequestUpdateCheck() is complete. Takes one parameter: |
| 86 // - UpdateCheckResult: the result of the update check. | 87 // - UpdateCheckResult: the result of the update check. |
| 87 typedef base::Callback<void(UpdateCheckResult)> UpdateCheckCallback; | 88 using UpdateCheckCallback = base::Callback<void(UpdateCheckResult)>; |
| 88 | 89 |
| 89 // Requests an update check and calls |callback| when completed. | 90 // Requests an update check and calls |callback| when completed. |
| 90 virtual void RequestUpdateCheck(const UpdateCheckCallback& callback) = 0; | 91 virtual void RequestUpdateCheck(const UpdateCheckCallback& callback) = 0; |
| 91 | 92 |
| 92 // Reboots if update has been performed. | 93 // Reboots if update has been performed. |
| 93 virtual void RebootAfterUpdate() = 0; | 94 virtual void RebootAfterUpdate() = 0; |
| 94 | 95 |
| 95 // Starts Rollback. | 96 // Starts Rollback. |
| 96 virtual void Rollback() = 0; | 97 virtual void Rollback() = 0; |
| 97 | 98 |
| 98 // Called once CanRollbackCheck() is complete. Takes one parameter: | 99 // Called once CanRollbackCheck() is complete. Takes one parameter: |
| 99 // - bool: the result of the rollback availability check. | 100 // - bool: the result of the rollback availability check. |
| 100 typedef base::Callback<void(bool can_rollback)> RollbackCheckCallback; | 101 using RollbackCheckCallback = base::Callback<void(bool can_rollback)>; |
| 101 | 102 |
| 102 // Checks if Rollback is available and calls |callback| when completed. | 103 // Checks if Rollback is available and calls |callback| when completed. |
| 103 virtual void CanRollbackCheck( | 104 virtual void CanRollbackCheck( |
| 104 const RollbackCheckCallback& callback) = 0; | 105 const RollbackCheckCallback& callback) = 0; |
| 105 | 106 |
| 106 // Called once GetChannel() is complete. Takes one parameter; | 107 // Called once GetChannel() is complete. Takes one parameter; |
| 107 // - string: the channel name like "beta-channel". | 108 // - string: the channel name like "beta-channel". |
| 108 typedef base::Callback<void(const std::string& channel_name)> | 109 using GetChannelCallback = |
| 109 GetChannelCallback; | 110 base::Callback<void(const std::string& channel_name)>; |
| 110 | 111 |
| 111 // Returns the last status the object received from the update engine. | 112 // Returns the last status the object received from the update engine. |
| 112 // | 113 // |
| 113 // Ideally, the D-Bus client should be state-less, but there are clients | 114 // Ideally, the D-Bus client should be state-less, but there are clients |
| 114 // that need this information. | 115 // that need this information. |
| 115 virtual Status GetLastStatus() = 0; | 116 virtual Status GetLastStatus() = 0; |
| 116 | 117 |
| 117 // Changes the current channel of the device to the target | 118 // Changes the current channel of the device to the target |
| 118 // channel. If the target channel is a less stable channel than the | 119 // channel. If the target channel is a less stable channel than the |
| 119 // current channel, then the channel change happens immediately (at | 120 // current channel, then the channel change happens immediately (at |
| (...skipping 10 matching lines...) Expand all Loading... |
| 130 // If |get_current_channel| is set to true, calls |callback| with | 131 // If |get_current_channel| is set to true, calls |callback| with |
| 131 // the name of the channel that the device is currently | 132 // the name of the channel that the device is currently |
| 132 // on. Otherwise, it calls it with the name of the channel the | 133 // 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 // device is supposed to be (in case of a pending channel |
| 134 // change). On error, calls |callback| with an empty string. | 135 // change). On error, calls |callback| with an empty string. |
| 135 virtual void GetChannel(bool get_current_channel, | 136 virtual void GetChannel(bool get_current_channel, |
| 136 const GetChannelCallback& callback) = 0; | 137 const GetChannelCallback& callback) = 0; |
| 137 | 138 |
| 138 // Called once GetEolStatus() is complete. Takes one parameter; | 139 // Called once GetEolStatus() is complete. Takes one parameter; |
| 139 // - EndOfLife Status: the end of life status of the device. | 140 // - EndOfLife Status: the end of life status of the device. |
| 140 typedef base::Callback<void(update_engine::EndOfLifeStatus status)> | 141 using GetEolStatusCallback = |
| 141 GetEolStatusCallback; | 142 base::Callback<void(update_engine::EndOfLifeStatus status)>; |
| 142 | 143 |
| 143 // Get EndOfLife status of the device and calls |callback| when completed. | 144 // Get EndOfLife status of the device and calls |callback| when completed. |
| 144 virtual void GetEolStatus(const GetEolStatusCallback& callback) = 0; | 145 virtual void GetEolStatus(const GetEolStatusCallback& callback) = 0; |
| 145 | 146 |
| 146 // Either allow or disallow receiving updates over cellular connections. | 147 // Either allow or disallow receiving updates over cellular connections. |
| 147 // Synchronous (blocking) method. | 148 // Synchronous (blocking) method. |
| 148 virtual void SetUpdateOverCellularPermission( | 149 virtual void SetUpdateOverCellularPermission( |
| 149 bool allowed, | 150 bool allowed, |
| 150 const base::Closure& callback) = 0; | 151 const base::Closure& callback) = 0; |
| 151 | 152 |
| 153 // Called once SetUpdateOverCellularTarget() is complete. Takes one parameter; |
| 154 // - success: indicates whether the target is set successfully. |
| 155 using SetUpdateOverCellularTargetCallback = |
| 156 base::Callback<void(bool success)>; |
| 157 |
| 158 // Sets the target in the preferences maintained by update engine which then |
| 159 // performs update to this given target after RequestUpdateCheck() is invoked |
| 160 // in the |callback|. |
| 161 // - target_version: the Chrome OS version we want to update to. |
| 162 // - target_size: the size of that Chrome OS version in bytes. |
| 163 // These two parameters are a failsafe to prevent downloading an update user |
| 164 // didn't agree to. They should be set using the version and size we received |
| 165 // from update engine when it broadcasts NEED_PERMISSION_TO_UPDATE. They are |
| 166 // used by update engine to double-check with update server in case there's a |
| 167 // new update available or a delta update becomes a full update with larger |
| 168 // size. |
| 169 virtual void SetUpdateOverCellularTarget( |
| 170 const std::string& target_version, |
| 171 int64_t target_size, |
| 172 const SetUpdateOverCellularTargetCallback& callback) = 0; |
| 173 |
| 152 // Returns an empty UpdateCheckCallback that does nothing. | 174 // Returns an empty UpdateCheckCallback that does nothing. |
| 153 static UpdateCheckCallback EmptyUpdateCheckCallback(); | 175 static UpdateCheckCallback EmptyUpdateCheckCallback(); |
| 154 | 176 |
| 155 // Creates the instance. | 177 // Creates the instance. |
| 156 static UpdateEngineClient* Create(DBusClientImplementationType type); | 178 static UpdateEngineClient* Create(DBusClientImplementationType type); |
| 157 | 179 |
| 158 // Returns true if |target_channel| is more stable than |current_channel|. | 180 // Returns true if |target_channel| is more stable than |current_channel|. |
| 159 static bool IsTargetChannelMoreStable(const std::string& current_channel, | 181 static bool IsTargetChannelMoreStable(const std::string& current_channel, |
| 160 const std::string& target_channel); | 182 const std::string& target_channel); |
| 161 | 183 |
| 162 protected: | 184 protected: |
| 163 // Create() should be used instead. | 185 // Create() should be used instead. |
| 164 UpdateEngineClient(); | 186 UpdateEngineClient(); |
| 165 | 187 |
| 166 private: | 188 private: |
| 167 DISALLOW_COPY_AND_ASSIGN(UpdateEngineClient); | 189 DISALLOW_COPY_AND_ASSIGN(UpdateEngineClient); |
| 168 }; | 190 }; |
| 169 | 191 |
| 170 } // namespace chromeos | 192 } // namespace chromeos |
| 171 | 193 |
| 172 #endif // CHROMEOS_DBUS_UPDATE_ENGINE_CLIENT_H_ | 194 #endif // CHROMEOS_DBUS_UPDATE_ENGINE_CLIENT_H_ |
| OLD | NEW |