OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 5 #ifndef COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
6 #define COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 6 #define COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 class ResourceThrottle; | 32 class ResourceThrottle; |
33 } | 33 } |
34 | 34 |
35 namespace net { | 35 namespace net { |
36 class URLRequestContextGetter; | 36 class URLRequestContextGetter; |
37 class URLRequest; | 37 class URLRequest; |
38 } | 38 } |
39 | 39 |
| 40 namespace policy { |
| 41 class ComponentUpdaterPolicyTest; |
| 42 } |
| 43 |
40 namespace update_client { | 44 namespace update_client { |
41 class ComponentInstaller; | 45 class ComponentInstaller; |
42 class Configurator; | 46 class Configurator; |
43 struct CrxComponent; | 47 struct CrxComponent; |
44 struct CrxUpdateItem; | 48 struct CrxUpdateItem; |
45 } | 49 } |
46 | 50 |
47 namespace component_updater { | 51 namespace component_updater { |
48 | 52 |
49 class OnDemandUpdater; | 53 class OnDemandUpdater; |
(...skipping 20 matching lines...) Expand all Loading... |
70 // be downloaded, verified and unpacked. Then component-specific installer | 74 // be downloaded, verified and unpacked. Then component-specific installer |
71 // ComponentInstaller::Install (of CrxComponent::installer) will be called. | 75 // ComponentInstaller::Install (of CrxComponent::installer) will be called. |
72 // | 76 // |
73 // During the normal operation of the component updater some specific | 77 // During the normal operation of the component updater some specific |
74 // notifications are fired, like COMPONENT_UPDATER_STARTED and | 78 // notifications are fired, like COMPONENT_UPDATER_STARTED and |
75 // COMPONENT_UPDATE_FOUND. See notification_type.h for more details. | 79 // COMPONENT_UPDATE_FOUND. See notification_type.h for more details. |
76 // | 80 // |
77 // All methods are safe to call ONLY from the browser's main thread. | 81 // All methods are safe to call ONLY from the browser's main thread. |
78 class ComponentUpdateService { | 82 class ComponentUpdateService { |
79 public: | 83 public: |
| 84 using CompletionCallback = update_client::UpdateClient::CompletionCallback; |
80 using Observer = update_client::UpdateClient::Observer; | 85 using Observer = update_client::UpdateClient::Observer; |
81 | 86 |
82 // Adds an observer for this class. An observer should not be added more | 87 // Adds an observer for this class. An observer should not be added more |
83 // than once. The caller retains the ownership of the observer object. | 88 // than once. The caller retains the ownership of the observer object. |
84 virtual void AddObserver(Observer* observer) = 0; | 89 virtual void AddObserver(Observer* observer) = 0; |
85 | 90 |
86 // Removes an observer. It is safe for an observer to be removed while | 91 // Removes an observer. It is safe for an observer to be removed while |
87 // the observers are being notified. | 92 // the observers are being notified. |
88 virtual void RemoveObserver(Observer* observer) = 0; | 93 virtual void RemoveObserver(Observer* observer) = 0; |
89 | 94 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 }; | 152 }; |
148 | 153 |
149 using ServiceObserver = ComponentUpdateService::Observer; | 154 using ServiceObserver = ComponentUpdateService::Observer; |
150 | 155 |
151 class OnDemandUpdater { | 156 class OnDemandUpdater { |
152 public: | 157 public: |
153 virtual ~OnDemandUpdater() {} | 158 virtual ~OnDemandUpdater() {} |
154 | 159 |
155 private: | 160 private: |
156 friend class OnDemandTester; | 161 friend class OnDemandTester; |
| 162 friend class policy::ComponentUpdaterPolicyTest; |
157 friend class SupervisedUserWhitelistInstaller; | 163 friend class SupervisedUserWhitelistInstaller; |
158 friend class ::ComponentsUI; | 164 friend class ::ComponentsUI; |
159 friend class ::PluginObserver; | 165 friend class ::PluginObserver; |
160 | 166 |
161 // Triggers an update check for a component. |id| is a value | 167 // Triggers an update check for a component. |id| is a value |
162 // returned by GetCrxComponentID(). If an update for this component is already | 168 // returned by GetCrxComponentID(). If an update for this component is already |
163 // in progress, the function returns |kInProgress|. If an update is available, | 169 // in progress, the function returns |kInProgress|. If an update is available, |
164 // the update will be applied. The caller can subscribe to component update | 170 // the update will be applied. The caller can subscribe to component update |
165 // service notifications to get an indication about the outcome of the | 171 // service notifications and provide an optional callback to get the result |
166 // on-demand update. The function does not implement any cooldown interval. | 172 // of the call. The function does not implement any cooldown interval. |
167 // TODO(sorin): improve this API so that the result of this non-blocking | 173 virtual void OnDemandUpdate( |
168 // call is provided by a callback. | 174 const std::string& id, |
169 virtual bool OnDemandUpdate(const std::string& id) = 0; | 175 ComponentUpdateService::CompletionCallback callback) = 0; |
170 }; | 176 }; |
171 | 177 |
172 // Creates the component updater. | 178 // Creates the component updater. |
173 std::unique_ptr<ComponentUpdateService> ComponentUpdateServiceFactory( | 179 std::unique_ptr<ComponentUpdateService> ComponentUpdateServiceFactory( |
174 const scoped_refptr<Configurator>& config); | 180 const scoped_refptr<Configurator>& config); |
175 | 181 |
176 } // namespace component_updater | 182 } // namespace component_updater |
177 | 183 |
178 #endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 184 #endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
OLD | NEW |