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 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // the filename of the file in this component's CRX. Returns false if this is | 43 // the filename of the file in this component's CRX. Returns false if this is |
44 // not possible (the file has been removed or modified, or its current | 44 // not possible (the file has been removed or modified, or its current |
45 // location is unknown). Otherwise, returns true. | 45 // location is unknown). Otherwise, returns true. |
46 virtual bool GetInstalledFile(const std::string& file, | 46 virtual bool GetInstalledFile(const std::string& file, |
47 base::FilePath* installed_file) = 0; | 47 base::FilePath* installed_file) = 0; |
48 | 48 |
49 protected: | 49 protected: |
50 virtual ~ComponentInstaller() {} | 50 virtual ~ComponentInstaller() {} |
51 }; | 51 }; |
52 | 52 |
| 53 // Defines an interface to observe a CrxComponent. |
| 54 class ComponentObserver { |
| 55 public: |
| 56 enum Events { |
| 57 // Sent when the component updater starts doing update checks. |
| 58 COMPONENT_UPDATER_STARTED, |
| 59 |
| 60 // Sent when the component updater is going to take a long nap. |
| 61 COMPONENT_UPDATER_SLEEPING, |
| 62 |
| 63 // Sent when there is a new version of a registered component. After |
| 64 // the notification is sent the component will be downloaded. |
| 65 COMPONENT_UPDATE_FOUND, |
| 66 |
| 67 // Sent when the new component has been downloaded and an installation |
| 68 // or upgrade is about to be attempted. |
| 69 COMPONENT_UPDATE_READY, |
| 70 }; |
| 71 |
| 72 virtual ~ComponentObserver() {} |
| 73 |
| 74 // The component updater service will call this function when an interesting |
| 75 // event happens for a specific component. |extra| is |event| dependent. |
| 76 virtual void OnEvent(Events event, int extra) = 0; |
| 77 }; |
| 78 |
53 // Describes a particular component that can be installed or updated. This | 79 // Describes a particular component that can be installed or updated. This |
54 // structure is required to register a component with the component updater. | 80 // structure is required to register a component with the component updater. |
55 // |pk_hash| is the SHA256 hash of the component's public key. If the component | 81 // |pk_hash| is the SHA256 hash of the component's public key. If the component |
56 // is to be installed then version should be "0" or "0.0", else it should be | 82 // is to be installed then version should be "0" or "0.0", else it should be |
57 // the current version. |fingerprint| and |name| are optional. | 83 // the current version. |observer|, |fingerprint|, and |name| are optional. |
58 struct CrxComponent { | 84 struct CrxComponent { |
59 std::vector<uint8> pk_hash; | 85 std::vector<uint8> pk_hash; |
60 ComponentInstaller* installer; | 86 ComponentInstaller* installer; |
| 87 ComponentObserver* observer; |
61 Version version; | 88 Version version; |
62 std::string fingerprint; | 89 std::string fingerprint; |
63 std::string name; | 90 std::string name; |
64 CrxComponent(); | 91 CrxComponent(); |
65 ~CrxComponent(); | 92 ~CrxComponent(); |
66 }; | 93 }; |
67 | 94 |
68 // The component update service is in charge of installing or upgrading | 95 // The component update service is in charge of installing or upgrading |
69 // select parts of chrome. Each part is called a component and managed by | 96 // select parts of chrome. Each part is called a component and managed by |
70 // instances of CrxComponent registered using RegisterComponent(). On the | 97 // instances of CrxComponent registered using RegisterComponent(). On the |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 175 |
149 virtual ~ComponentUpdateService() {} | 176 virtual ~ComponentUpdateService() {} |
150 }; | 177 }; |
151 | 178 |
152 // Creates the component updater. You must pass a valid |config| allocated on | 179 // Creates the component updater. You must pass a valid |config| allocated on |
153 // the heap which the component updater will own. | 180 // the heap which the component updater will own. |
154 ComponentUpdateService* ComponentUpdateServiceFactory( | 181 ComponentUpdateService* ComponentUpdateServiceFactory( |
155 ComponentUpdateService::Configurator* config); | 182 ComponentUpdateService::Configurator* config); |
156 | 183 |
157 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 184 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
OLD | NEW |