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 is called from a task runner. |
blundell
2014/07/15 08:45:20
"from a task runner" is not particularly informati
tommycli
2014/07/15 18:58:25
Done.
| |
50 virtual bool Install(const base::DictionaryValue& manifest, | 50 virtual bool Install(const base::DictionaryValue& manifest, |
51 const base::FilePath& unpack_path) = 0; | 51 const base::FilePath& unpack_path) = 0; |
52 | 52 |
53 // Set |installed_file| to the full path to the installed |file|. |file| is | 53 // 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 | 54 // 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 | 55 // not possible (the file has been removed or modified, or its current |
56 // location is unknown). Otherwise, returns true. | 56 // location is unknown). Otherwise, returns true. |
57 virtual bool GetInstalledFile(const std::string& file, | 57 virtual bool GetInstalledFile(const std::string& file, |
58 base::FilePath* installed_file) = 0; | 58 base::FilePath* installed_file) = 0; |
59 | 59 |
(...skipping 29 matching lines...) Expand all Loading... | |
89 // to package extensions. To the update service each component is identified | 89 // 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 | 90 // 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 | 91 // available and its version is bigger than (CrxComponent::version), it will |
92 // be downloaded, verified and unpacked. Then component-specific installer | 92 // be downloaded, verified and unpacked. Then component-specific installer |
93 // ComponentInstaller::Install (of CrxComponent::installer) will be called. | 93 // ComponentInstaller::Install (of CrxComponent::installer) will be called. |
94 // | 94 // |
95 // During the normal operation of the component updater some specific | 95 // During the normal operation of the component updater some specific |
96 // notifications are fired, like COMPONENT_UPDATER_STARTED and | 96 // notifications are fired, like COMPONENT_UPDATER_STARTED and |
97 // COMPONENT_UPDATE_FOUND. See notification_type.h for more details. | 97 // COMPONENT_UPDATE_FOUND. See notification_type.h for more details. |
98 // | 98 // |
99 // All methods are safe to call ONLY from chrome's UI thread. | 99 // All methods are safe to call ONLY from the browser's main thread. |
100 class ComponentUpdateService { | 100 class ComponentUpdateService { |
101 public: | 101 public: |
102 enum Status { kOk, kReplaced, kInProgress, kError }; | 102 enum Status { kOk, kReplaced, kInProgress, kError }; |
103 | 103 |
104 // Defines an interface to observe ComponentUpdateService. It provides | 104 // Defines an interface to observe ComponentUpdateService. It provides |
105 // notifications when state changes occur for the service or for the | 105 // notifications when state changes occur for the service or for the |
106 // registered components. | 106 // registered components. |
107 class Observer { | 107 class Observer { |
108 public: | 108 public: |
109 enum Events { | 109 enum Events { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 const std::string& component_id) = 0; | 211 const std::string& component_id) = 0; |
212 }; | 212 }; |
213 | 213 |
214 // Creates the component updater. You must pass a valid |config| allocated on | 214 // Creates the component updater. You must pass a valid |config| allocated on |
215 // the heap which the component updater will own. | 215 // the heap which the component updater will own. |
216 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config); | 216 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config); |
217 | 217 |
218 } // namespace component_updater | 218 } // namespace component_updater |
219 | 219 |
220 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 220 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
OLD | NEW |