| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
| 6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 namespace component_updater { | 31 namespace component_updater { |
| 32 | 32 |
| 33 class Configurator; | 33 class Configurator; |
| 34 class OnDemandUpdater; | 34 class OnDemandUpdater; |
| 35 | 35 |
| 36 // Component specific installers must derive from this class and implement | 36 // Component specific installers must derive from this class and implement |
| 37 // OnUpdateError() and Install(). A valid instance of this class must be | 37 // OnUpdateError() and Install(). A valid instance of this class must be |
| 38 // given to ComponentUpdateService::RegisterComponent(). | 38 // given to ComponentUpdateService::RegisterComponent(). |
| 39 class ComponentInstaller { | 39 class ComponentInstaller { |
| 40 public: | 40 public: |
| 41 // Called by the component updater on the UI thread when there was a | 41 // Called by the component updater on the main thread when there was a |
| 42 // problem unpacking or verifying the component. |error| is a non-zero | 42 // problem unpacking or verifying the component. |error| is a non-zero |
| 43 // value which is only meaningful to the component updater. | 43 // value which is only meaningful to the component updater. |
| 44 virtual void OnUpdateError(int error) = 0; | 44 virtual void OnUpdateError(int error) = 0; |
| 45 | 45 |
| 46 // Called by the component updater when a component has been unpacked | 46 // Called by the component updater when a component has been unpacked |
| 47 // and is ready to be installed. |manifest| contains the CRX manifest | 47 // and is ready to be installed. |manifest| contains the CRX manifest |
| 48 // json dictionary and |unpack_path| contains the temporary directory | 48 // json dictionary and |unpack_path| contains the temporary directory |
| 49 // with all the unpacked CRX files. | 49 // with all the unpacked CRX files. This method may be called from |
| 50 // a thread other than the main thread. |
| 50 virtual bool Install(const base::DictionaryValue& manifest, | 51 virtual bool Install(const base::DictionaryValue& manifest, |
| 51 const base::FilePath& unpack_path) = 0; | 52 const base::FilePath& unpack_path) = 0; |
| 52 | 53 |
| 53 // Set |installed_file| to the full path to the installed |file|. |file| is | 54 // Set |installed_file| to the full path to the installed |file|. |file| is |
| 54 // the filename of the file in this component's CRX. Returns false if this is | 55 // the filename of the file in this component's CRX. Returns false if this is |
| 55 // not possible (the file has been removed or modified, or its current | 56 // not possible (the file has been removed or modified, or its current |
| 56 // location is unknown). Otherwise, returns true. | 57 // location is unknown). Otherwise, returns true. |
| 57 virtual bool GetInstalledFile(const std::string& file, | 58 virtual bool GetInstalledFile(const std::string& file, |
| 58 base::FilePath* installed_file) = 0; | 59 base::FilePath* installed_file) = 0; |
| 59 | 60 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 89 // to package extensions. To the update service each component is identified | 90 // to package extensions. To the update service each component is identified |
| 90 // by its public key hash (CrxComponent::pk_hash). If there is an update | 91 // by its public key hash (CrxComponent::pk_hash). If there is an update |
| 91 // available and its version is bigger than (CrxComponent::version), it will | 92 // available and its version is bigger than (CrxComponent::version), it will |
| 92 // be downloaded, verified and unpacked. Then component-specific installer | 93 // be downloaded, verified and unpacked. Then component-specific installer |
| 93 // ComponentInstaller::Install (of CrxComponent::installer) will be called. | 94 // ComponentInstaller::Install (of CrxComponent::installer) will be called. |
| 94 // | 95 // |
| 95 // During the normal operation of the component updater some specific | 96 // During the normal operation of the component updater some specific |
| 96 // notifications are fired, like COMPONENT_UPDATER_STARTED and | 97 // notifications are fired, like COMPONENT_UPDATER_STARTED and |
| 97 // COMPONENT_UPDATE_FOUND. See notification_type.h for more details. | 98 // COMPONENT_UPDATE_FOUND. See notification_type.h for more details. |
| 98 // | 99 // |
| 99 // All methods are safe to call ONLY from chrome's UI thread. | 100 // All methods are safe to call ONLY from the browser's main thread. |
| 100 class ComponentUpdateService { | 101 class ComponentUpdateService { |
| 101 public: | 102 public: |
| 102 enum Status { kOk, kReplaced, kInProgress, kError }; | 103 enum Status { kOk, kReplaced, kInProgress, kError }; |
| 103 | 104 |
| 104 // Defines an interface to observe ComponentUpdateService. It provides | 105 // Defines an interface to observe ComponentUpdateService. It provides |
| 105 // notifications when state changes occur for the service or for the | 106 // notifications when state changes occur for the service or for the |
| 106 // registered components. | 107 // registered components. |
| 107 class Observer { | 108 class Observer { |
| 108 public: | 109 public: |
| 109 enum Events { | 110 enum Events { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 const std::string& component_id) = 0; | 212 const std::string& component_id) = 0; |
| 212 }; | 213 }; |
| 213 | 214 |
| 214 // Creates the component updater. You must pass a valid |config| allocated on | 215 // Creates the component updater. You must pass a valid |config| allocated on |
| 215 // the heap which the component updater will own. | 216 // the heap which the component updater will own. |
| 216 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config); | 217 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config); |
| 217 | 218 |
| 218 } // namespace component_updater | 219 } // namespace component_updater |
| 219 | 220 |
| 220 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 221 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
| OLD | NEW |