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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // be downloaded, verified and unpacked. Then component-specific installer | 70 // be downloaded, verified and unpacked. Then component-specific installer |
71 // ComponentInstaller::Install (of CrxComponent::installer) will be called. | 71 // ComponentInstaller::Install (of CrxComponent::installer) will be called. |
72 // | 72 // |
73 // During the normal operation of the component updater some specific | 73 // During the normal operation of the component updater some specific |
74 // notifications are fired, like COMPONENT_UPDATER_STARTED and | 74 // notifications are fired, like COMPONENT_UPDATER_STARTED and |
75 // COMPONENT_UPDATE_FOUND. See notification_type.h for more details. | 75 // COMPONENT_UPDATE_FOUND. See notification_type.h for more details. |
76 // | 76 // |
77 // All methods are safe to call ONLY from the browser's main thread. | 77 // All methods are safe to call ONLY from the browser's main thread. |
78 class ComponentUpdateService { | 78 class ComponentUpdateService { |
79 public: | 79 public: |
| 80 using CompletionCallback = update_client::UpdateClient::CompletionCallback; |
80 using Observer = update_client::UpdateClient::Observer; | 81 using Observer = update_client::UpdateClient::Observer; |
81 | 82 |
82 // Adds an observer for this class. An observer should not be added more | 83 // 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. | 84 // than once. The caller retains the ownership of the observer object. |
84 virtual void AddObserver(Observer* observer) = 0; | 85 virtual void AddObserver(Observer* observer) = 0; |
85 | 86 |
86 // Removes an observer. It is safe for an observer to be removed while | 87 // Removes an observer. It is safe for an observer to be removed while |
87 // the observers are being notified. | 88 // the observers are being notified. |
88 virtual void RemoveObserver(Observer* observer) = 0; | 89 virtual void RemoveObserver(Observer* observer) = 0; |
89 | 90 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 private: | 156 private: |
156 friend class OnDemandTester; | 157 friend class OnDemandTester; |
157 friend class SupervisedUserWhitelistInstaller; | 158 friend class SupervisedUserWhitelistInstaller; |
158 friend class ::ComponentsUI; | 159 friend class ::ComponentsUI; |
159 friend class ::PluginObserver; | 160 friend class ::PluginObserver; |
160 | 161 |
161 // Triggers an update check for a component. |id| is a value | 162 // Triggers an update check for a component. |id| is a value |
162 // returned by GetCrxComponentID(). If an update for this component is already | 163 // returned by GetCrxComponentID(). If an update for this component is already |
163 // in progress, the function returns |kInProgress|. If an update is available, | 164 // in progress, the function returns |kInProgress|. If an update is available, |
164 // the update will be applied. The caller can subscribe to component update | 165 // the update will be applied. The caller can subscribe to component update |
165 // service notifications to get an indication about the outcome of the | 166 // service notifications and provide an optional callback to get the result |
166 // on-demand update. The function does not implement any cooldown interval. | 167 // 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 | 168 virtual void OnDemandUpdate( |
168 // call is provided by a callback. | 169 const std::string& id, |
169 virtual bool OnDemandUpdate(const std::string& id) = 0; | 170 ComponentUpdateService::CompletionCallback callback) = 0; |
170 }; | 171 }; |
171 | 172 |
172 // Creates the component updater. | 173 // Creates the component updater. |
173 std::unique_ptr<ComponentUpdateService> ComponentUpdateServiceFactory( | 174 std::unique_ptr<ComponentUpdateService> ComponentUpdateServiceFactory( |
174 const scoped_refptr<Configurator>& config); | 175 const scoped_refptr<Configurator>& config); |
175 | 176 |
176 } // namespace component_updater | 177 } // namespace component_updater |
177 | 178 |
178 #endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 179 #endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
OLD | NEW |