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_UPDATE_CLIENT_UPDATE_CLIENT_H_ | 5 #ifndef COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_ |
6 #define COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_ | 6 #define COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 }; | 255 }; |
256 | 256 |
257 // Adds an observer for this class. An observer should not be added more | 257 // Adds an observer for this class. An observer should not be added more |
258 // than once. The caller retains the ownership of the observer object. | 258 // than once. The caller retains the ownership of the observer object. |
259 virtual void AddObserver(Observer* observer) = 0; | 259 virtual void AddObserver(Observer* observer) = 0; |
260 | 260 |
261 // Removes an observer. It is safe for an observer to be removed while | 261 // Removes an observer. It is safe for an observer to be removed while |
262 // the observers are being notified. | 262 // the observers are being notified. |
263 virtual void RemoveObserver(Observer* observer) = 0; | 263 virtual void RemoveObserver(Observer* observer) = 0; |
264 | 264 |
265 // Installs the specified CRX. Calls back after the install has been handled. | 265 // Installs the specified CRX. Calls back on |completion_callback| after the |
266 // Calls back on |completion_callback| after the update has been handled. The | 266 // update has been handled. The |error| parameter of the |completion_callback| |
267 // |error| parameter of the |completion_callback| contains an error code in | 267 // contains an error code in the case of a run-time error, or 0 if the |
268 // the case of a run-time error, or 0 if the Install has been handled | 268 // install has been handled successfully. Overlapping calls of this function |
269 // successfully. | 269 // are executed concurrently, as long as the id parameter is different, |
| 270 // meaning that installs of different components are parallelized. |
| 271 // The |Install| function is intended to be used for foreground installs of |
| 272 // one CRX. These cases are usually associated with on-demand install |
| 273 // scenarios, which are triggered by user actions. Installs are never |
| 274 // queued up. |
270 virtual void Install(const std::string& id, | 275 virtual void Install(const std::string& id, |
271 const CrxDataCallback& crx_data_callback, | 276 const CrxDataCallback& crx_data_callback, |
272 const CompletionCallback& completion_callback) = 0; | 277 const CompletionCallback& completion_callback) = 0; |
273 | 278 |
274 // Updates the specified CRXs. Calls back on |crx_data_callback| before the | 279 // Updates the specified CRXs. Calls back on |crx_data_callback| before the |
275 // update is attempted to give the caller the opportunity to provide the | 280 // update is attempted to give the caller the opportunity to provide the |
276 // instances of CrxComponent to be used for this update. | 281 // instances of CrxComponent to be used for this update. The |Update| function |
| 282 // is intended to be used for background updates of several CRXs. Overlapping |
| 283 // calls to this function result in a queuing behavior, and the execution |
| 284 // of each call is serialized. In addition, updates are always queued up when |
| 285 // installs are running. |
277 virtual void Update(const std::vector<std::string>& ids, | 286 virtual void Update(const std::vector<std::string>& ids, |
278 const CrxDataCallback& crx_data_callback, | 287 const CrxDataCallback& crx_data_callback, |
279 const CompletionCallback& completion_callback) = 0; | 288 const CompletionCallback& completion_callback) = 0; |
280 | 289 |
281 // Returns status details about a CRX update. The function returns true in | 290 // Returns status details about a CRX update. The function returns true in |
282 // case of success and false in case of errors, such as |id| was | 291 // case of success and false in case of errors, such as |id| was |
283 // invalid or not known. | 292 // invalid or not known. |
284 virtual bool GetCrxUpdateState(const std::string& id, | 293 virtual bool GetCrxUpdateState(const std::string& id, |
285 CrxUpdateItem* update_item) const = 0; | 294 CrxUpdateItem* update_item) const = 0; |
286 | 295 |
| 296 // Returns true if the |id| is found in any running task. |
287 virtual bool IsUpdating(const std::string& id) const = 0; | 297 virtual bool IsUpdating(const std::string& id) const = 0; |
288 | 298 |
289 protected: | 299 protected: |
290 friend class base::RefCounted<UpdateClient>; | 300 friend class base::RefCounted<UpdateClient>; |
291 | 301 |
292 virtual ~UpdateClient() {} | 302 virtual ~UpdateClient() {} |
293 }; | 303 }; |
294 | 304 |
295 // Creates an instance of the update client. | 305 // Creates an instance of the update client. |
296 scoped_refptr<UpdateClient> UpdateClientFactory( | 306 scoped_refptr<UpdateClient> UpdateClientFactory( |
297 const scoped_refptr<Configurator>& config); | 307 const scoped_refptr<Configurator>& config); |
298 | 308 |
299 } // namespace update_client | 309 } // namespace update_client |
300 | 310 |
301 #endif // COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_ | 311 #endif // COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_ |
OLD | NEW |