blob: be4f70211ba8a73867795020b96e034203aa0cce [file] [log] [blame]
sorin52ac0882015-01-24 01:15:001// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_
6#define COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_
7
8#include <stdint.h>
dchengd0fc6aa92016-04-22 18:03:129
sorin2adb2ca2016-06-29 01:44:3510#include <map>
Sorin Jianu9d64af672020-02-05 19:14:3411#include <memory>
sorin52ac0882015-01-24 01:15:0012#include <string>
13#include <vector>
14
sorin9797aba2015-04-17 17:15:0315#include "base/callback_forward.h"
bauerb810e60f42015-02-05 01:09:1016#include "base/memory/ref_counted.h"
Sorin Jianu73900242018-08-17 01:11:5317#include "base/optional.h"
sorin52ac0882015-01-24 01:15:0018#include "base/version.h"
sorin2892f7212016-11-07 18:59:4319#include "components/update_client/update_client_errors.h"
sorin52ac0882015-01-24 01:15:0020
sorin9797aba2015-04-17 17:15:0321// The UpdateClient class is a facade with a simple interface. The interface
22// exposes a few APIs to install a CRX or update a group of CRXs.
23//
24// The difference between a CRX install and a CRX update is relatively minor.
25// The terminology going forward will use the word "update" to cover both
26// install and update scenarios, except where details regarding the install
27// case are relevant.
28//
29// Handling an update consists of a series of actions such as sending an update
30// check to the server, followed by parsing the server response, identifying
31// the CRXs that require an update, downloading the differential update if
32// it is available, unpacking and patching the differential update, then
33// falling back to trying a similar set of actions using the full update.
34// At the end of this process, completion pings are sent to the server,
35// as needed, for the CRXs which had updates.
36//
37// As a general idea, this code handles the action steps needed to update
38// a group of components serially, one step at a time. However, concurrent
39// execution of calls to UpdateClient::Update is possible, therefore,
40// queuing of updates could happen in some cases. More below.
41//
42// The UpdateClient class features a subject-observer interface to observe
43// the CRX state changes during an update.
44//
45// The threading model for this code assumes that most of the code in the
46// public interface runs on a SingleThreadTaskRunner.
47// This task runner corresponds to the browser UI thread in many cases. There
48// are parts of the installer interface that run on blocking task runners, which
49// are usually threads in a thread pool.
50//
51// Using the UpdateClient is relatively easy. This assumes that the client
52// of this code has already implemented the observer interface as needed, and
53// can provide an installer, as described below.
54//
dchengd0fc6aa92016-04-22 18:03:1255// std::unique_ptr<UpdateClient> update_client(UpdateClientFactory(...));
sorin9797aba2015-04-17 17:15:0356// update_client->AddObserver(&observer);
57// std::vector<std::string> ids;
58// ids.push_back(...));
Sorin Jianua8ef73d2017-11-02 16:55:1759// update_client->Update(ids, base::BindOnce(...), base::BindOnce(...));
sorin9797aba2015-04-17 17:15:0360//
61// UpdateClient::Update takes two callbacks as parameters. First callback
62// allows the client of this code to provide an instance of CrxComponent
63// data structure that specifies additional parameters of the update.
64// CrxComponent has a CrxInstaller data member, which must be provided by the
65// callers of this class. The second callback indicates that this non-blocking
66// call has completed.
67//
68// There could be several ways of triggering updates for a CRX, user-initiated,
69// or timer-based. Since the execution of updates is concurrent, the parameters
70// for the update must be provided right before the update is handled.
71// Otherwise, the version of the CRX set in the CrxComponent may not be correct.
72//
73// The UpdateClient public interface includes two functions: Install and
74// Update. These functions correspond to installing one CRX immediately as a
75// foreground activity (Install), and updating a group of CRXs silently in the
76// background (Update). This distinction is important. Background updates are
77// queued up and their actions run serially, one at a time, for the purpose of
78// conserving local resources such as CPU, network, and I/O.
79// On the other hand, installs are never queued up but run concurrently, as
80// requested by the user.
81//
82// The update client introduces a runtime constraint regarding interleaving
83// updates and installs. If installs or updates for a given CRX are in progress,
84// then installs for the same CRX will fail with a specific error.
85//
86// Implementation details.
87//
88// The implementation details below are not relevant to callers of this
89// code. However, these design notes are relevant to the owners and maintainers
90// of this module.
91//
92// The design for the update client consists of a number of abstractions
93// such as: task, update engine, update context, and action.
94// The execution model for these abstractions is simple. They usually expose
95// a public, non-blocking Run function, and they invoke a callback when
96// the Run function has completed.
97//
98// A task is the unit of work for the UpdateClient. A task is associated
99// with a single call of the Update function. A task represents a group
100// of CRXs that are updated together.
101//
102// The UpdateClient is responsible for the queuing of tasks, if queuing is
103// needed.
104//
105// When the task runs, it calls the update engine to handle the updates for
106// the CRXs associated with the task. The UpdateEngine is the abstraction
107// responsible for breaking down the update in a set of discrete steps, which
108// are implemented as actions, and running the actions.
109//
110// The UpdateEngine maintains a set of UpdateContext instances. Each of
111// these instances maintains the update state for all the CRXs belonging to
112// a given task. The UpdateContext contains a queue of CRX ids.
113// The UpdateEngine will handle updates for the CRXs in the order they appear
114// in the queue, until the queue is empty.
115//
116// The update state for each CRX is maintained in a container of CrxUpdateItem*.
117// As actions run, each action updates the CRX state, represented by one of
118// these CrxUpdateItem* instances.
119//
120// Although the UpdateEngine can and will run update tasks concurrently, the
121// actions of a task are run sequentially.
122//
123// The Action is a polymorphic type. There is some code reuse for convenience,
124// implemented as a mixin. The polymorphic behavior of some of the actions
125// is achieved using a template method.
126//
127// State changes of a CRX could generate events, which are observed using a
128// subject-observer interface.
129//
130// The actions chain up. In some sense, the actions implement a state machine,
131// as the CRX undergoes a series of state transitions in the process of
132// being checked for updates and applying the update.
133
wafflesd2d9a332016-04-09 01:59:57134class PrefRegistrySimple;
sorin9797aba2015-04-17 17:15:03135
sorin52ac0882015-01-24 01:15:00136namespace base {
sorin52ac0882015-01-24 01:15:00137class FilePath;
138}
139
Joshua Pawlickif4b33f382018-08-17 17:36:51140namespace crx_file {
141enum class VerifierFormat;
142}
143
sorin52ac0882015-01-24 01:15:00144namespace update_client {
145
sorin9797aba2015-04-17 17:15:03146class Configurator;
sorin7b8650522016-11-02 18:23:41147enum class Error;
sorin9797aba2015-04-17 17:15:03148struct CrxUpdateItem;
149
sorin30474f02017-04-27 00:45:48150enum class ComponentState {
151 kNew,
152 kChecking,
153 kCanUpdate,
154 kDownloadingDiff,
155 kDownloading,
156 kDownloaded,
157 kUpdatingDiff,
158 kUpdating,
159 kUpdated,
160 kUpToDate,
161 kUpdateError,
162 kUninstalled,
Sam Sappenfield4a065262020-07-29 19:28:18163 kRegistration,
Sorin Jianu4ab7c292017-06-15 18:40:21164 kRun,
sorin30474f02017-04-27 00:45:48165 kLastStatus
166};
167
sorin9797aba2015-04-17 17:15:03168// Defines an interface for a generic CRX installer.
169class CrxInstaller : public base::RefCountedThreadSafe<CrxInstaller> {
sorin52ac0882015-01-24 01:15:00170 public:
sorin2892f7212016-11-07 18:59:43171 // Contains the result of the Install operation.
172 struct Result {
173 explicit Result(int error, int extended_error = 0)
174 : error(error), extended_error(extended_error) {}
175 explicit Result(InstallError error, int extended_error = 0)
176 : error(static_cast<int>(error)), extended_error(extended_error) {}
177 int error = 0; // 0 indicates that install has been successful.
178 int extended_error = 0;
179 };
180
Sorin Jianu9d64af672020-02-05 19:14:34181 struct InstallParams {
182 InstallParams(const std::string& run, const std::string& arguments);
183 std::string run;
184 std::string arguments;
185 };
186
Sorin Jianuc9d32b2f2020-05-08 23:07:26187 using ProgressCallback = base::RepeatingCallback<void(int progress)>;
Sorin Jianua8ef73d2017-11-02 16:55:17188 using Callback = base::OnceCallback<void(const Result& result)>;
Sorin Jianuf40ab4b32017-10-06 22:53:41189
sorin9797aba2015-04-17 17:15:03190 // Called on the main thread when there was a problem unpacking or
191 // verifying the CRX. |error| is a non-zero value which is only meaningful
192 // to the caller.
sorin52ac0882015-01-24 01:15:00193 virtual void OnUpdateError(int error) = 0;
194
sorin9797aba2015-04-17 17:15:03195 // Called by the update service when a CRX has been unpacked
Sorin Jianuc9d32b2f2020-05-08 23:07:26196 // and it is ready to be installed. This method may be called from a
197 // sequence other than the main sequence.
198 // |unpack_path| contains the temporary directory with all the unpacked CRX
199 // files.
200 // |pubkey| contains the public key of the CRX in the PEM format, without the
201 // header and the footer.
202 // |install_params| is an optional parameter which provides the name and the
203 // arguments for a binary program which is invoked as part of the install or
204 // update flows.
205 // |progress_callback| reports installer progress. This callback must be run
206 // directly instead of posting it.
207 // |callback| must be the last callback invoked and it indicates that the
208 // install flow has completed.
Sorin Jianu7aa6d1f2017-10-13 20:29:29209 virtual void Install(const base::FilePath& unpack_path,
Sorin Jianuea5534e92017-10-27 01:40:28210 const std::string& public_key,
Sorin Jianu9d64af672020-02-05 19:14:34211 std::unique_ptr<InstallParams> install_params,
Sorin Jianuc9d32b2f2020-05-08 23:07:26212 ProgressCallback progress_callback,
Sorin Jianua8ef73d2017-11-02 16:55:17213 Callback callback) = 0;
sorin52ac0882015-01-24 01:15:00214
sorin9797aba2015-04-17 17:15:03215 // Sets |installed_file| to the full path to the installed |file|. |file| is
216 // the filename of the file in this CRX. Returns false if this is
sorin52ac0882015-01-24 01:15:00217 // not possible (the file has been removed or modified, or its current
sorin9797aba2015-04-17 17:15:03218 // location is unknown). Otherwise, it returns true.
sorin52ac0882015-01-24 01:15:00219 virtual bool GetInstalledFile(const std::string& file,
220 base::FilePath* installed_file) = 0;
221
sorin9797aba2015-04-17 17:15:03222 // Called when a CRX has been unregistered and all versions should
223 // be uninstalled from disk. Returns true if uninstallation is supported,
224 // and false otherwise.
bauerb1f6657e72015-02-09 00:00:27225 virtual bool Uninstall() = 0;
226
bauerb810e60f42015-02-05 01:09:10227 protected:
sorin9797aba2015-04-17 17:15:03228 friend class base::RefCountedThreadSafe<CrxInstaller>;
bauerb810e60f42015-02-05 01:09:10229
Sorin Jianu30881152020-03-16 14:31:19230 virtual ~CrxInstaller() = default;
sorin52ac0882015-01-24 01:15:00231};
232
Sorin Jianu2fe49a02019-11-25 19:15:56233// Defines an interface to handle |action| elements in the update response.
234// The current implementation only handles run actions bound to a CRX, meaning
235// that such CRX is unpacked and an executable file, contained inside the CRX,
236// is run, then the results of the invocation are collected by the callback.
237class ActionHandler : public base::RefCountedThreadSafe<ActionHandler> {
238 public:
239 using Callback =
240 base::OnceCallback<void(bool succeeded, int error_code, int extra_code1)>;
241
242 virtual void Handle(const base::FilePath& action,
243 const std::string& session_id,
244 Callback callback) = 0;
245
246 protected:
247 friend class base::RefCountedThreadSafe<ActionHandler>;
248
249 virtual ~ActionHandler() = default;
250};
251
sorin2adb2ca2016-06-29 01:44:35252// A dictionary of installer-specific, arbitrary name-value pairs, which
253// may be used in the update checks requests.
254using InstallerAttributes = std::map<std::string, std::string>;
255
sorin52ac0882015-01-24 01:15:00256struct CrxComponent {
sorin52ac0882015-01-24 01:15:00257 CrxComponent();
vmpstrb6449d512016-02-25 23:55:40258 CrxComponent(const CrxComponent& other);
sorin52ac0882015-01-24 01:15:00259 ~CrxComponent();
sorin9797aba2015-04-17 17:15:03260
Joshua Pawlicki9656e3922019-09-16 16:34:51261 // Optional SHA256 hash of the CRX's public key. If not supplied, the
262 // unpacker can accept any CRX for this app, provided that the CRX meets the
263 // VerifierFormat requirements specified by the service's configurator.
264 // Callers that know or need a specific developer signature on acceptable CRX
265 // files must provide this.
sorin9797aba2015-04-17 17:15:03266 std::vector<uint8_t> pk_hash;
Joshua Pawlicki9656e3922019-09-16 16:34:51267
sorin9797aba2015-04-17 17:15:03268 scoped_refptr<CrxInstaller> installer;
Sorin Jianu2fe49a02019-11-25 19:15:56269 scoped_refptr<ActionHandler> action_handler;
270
Joshua Pawlicki9656e3922019-09-16 16:34:51271 std::string app_id;
sorin9797aba2015-04-17 17:15:03272
273 // The current version if the CRX is updated. Otherwise, "0" or "0.0" if
274 // the CRX is installed.
pwnalldb0b72412016-08-19 21:39:12275 base::Version version;
sorin9797aba2015-04-17 17:15:03276
277 std::string fingerprint; // Optional.
278 std::string name; // Optional.
waffles77255cc2016-08-02 17:25:12279 std::vector<std::string> handled_mime_types;
sorin2adb2ca2016-06-29 01:44:35280
281 // Optional.
282 // Valid values for the name part of an attribute match
283 // ^[-_a-zA-Z0-9]{1,256}$ and valid values the value part of an attribute
Joshua Pawlickiaabed6d2019-12-02 17:10:09284 // match ^[-.,;+_=$a-zA-Z0-9]{0,256}$ .
sorin2adb2ca2016-06-29 01:44:35285 InstallerAttributes installer_attributes;
sorin9797aba2015-04-17 17:15:03286
287 // Specifies that the CRX can be background-downloaded in some cases.
sorinfccbf2d2016-04-04 20:34:34288 // The default for this value is |true|.
289 bool allows_background_download;
290
291 // Specifies that the update checks and pings associated with this component
292 // require confidentiality. The default for this value is |true|. As a side
293 // note, the confidentiality of the downloads is enforced by the server,
294 // which only returns secure download URLs in this case.
295 bool requires_network_encryption;
sorincb4e5e92016-08-02 21:48:40296
Joshua Pawlickif4b33f382018-08-17 17:36:51297 // Specifies the strength of package validation required for the item.
298 crx_file::VerifierFormat crx_format_requirement;
299
sorincb4e5e92016-08-02 21:48:40300 // True if the component allows enabling or disabling updates by group policy.
301 // This member should be set to |false| for data, non-binary components, such
302 // as CRLSet, Supervised User Whitelists, STH Set, Origin Trials, and File
303 // Type Policies.
304 bool supports_group_policy_enable_component_updates;
Minh X. Nguyenca599fb2017-09-14 21:10:39305
306 // Reasons why this component/extension is disabled.
307 std::vector<int> disabled_reasons;
Minh X. Nguyenf8c530aa2017-12-13 23:54:17308
309 // Information about where the component/extension was installed from.
310 // For extension, this information is set from the update service, which
311 // gets the install source from the update URL.
312 std::string install_source;
Minh X. Nguyenfc16497e2018-04-24 16:05:35313
314 // Information about where the component/extension was loaded from.
315 // For extensions, this information is inferred from the extension
316 // registry.
317 std::string install_location;
Yann Dago84505252020-08-27 22:20:51318
319 // Information about the channel to send to the update server when updating
320 // the component. This optional field is typically populated by policy and is
321 // only populated on managed devices.
322 std::string channel;
sorin52ac0882015-01-24 01:15:00323};
324
Sorin Jianuf40ab4b32017-10-06 22:53:41325// Called when a non-blocking call of UpdateClient completes.
Vladislav Kuzkokov12eca792017-10-20 12:45:38326using Callback = base::OnceCallback<void(Error error)>;
Sorin Jianuf40ab4b32017-10-06 22:53:41327
sorin7c717622015-05-26 19:59:09328// All methods are safe to call only from the browser's main thread. Once an
329// instance of this class is created, the reference to it must be released
330// only after the thread pools of the browser process have been destroyed and
331// the browser process has gone single-threaded.
Sorin Jianu569aa7192020-07-23 16:09:54332class UpdateClient : public base::RefCountedThreadSafe<UpdateClient> {
sorin9797aba2015-04-17 17:15:03333 public:
334 using CrxDataCallback =
Sorin Jianu73900242018-08-17 01:11:53335 base::OnceCallback<std::vector<base::Optional<CrxComponent>>(
Sorin Jianu7c22795b2018-04-26 22:16:52336 const std::vector<std::string>& ids)>;
sorin9797aba2015-04-17 17:15:03337
Sorin Jianudfb12a42020-03-10 04:12:03338 // Called when state changes occur during an Install or Update call.
339 using CrxStateChangeCallback =
340 base::RepeatingCallback<void(CrxUpdateItem item)>;
341
sorin9797aba2015-04-17 17:15:03342 // Defines an interface to observe the UpdateClient. It provides
343 // notifications when state changes occur for the service itself or for the
344 // registered CRXs.
345 class Observer {
346 public:
347 enum class Events {
348 // Sent before the update client does an update check.
sorin30474f02017-04-27 00:45:48349 COMPONENT_CHECKING_FOR_UPDATES = 1,
sorin9797aba2015-04-17 17:15:03350
Sorin Jianud0298dd32019-10-25 16:47:10351 // Sent when there is a new version of a registered CRX. The CRX will be
352 // downloaded after the notification unless the update client inserts
353 // a wait because of a throttling policy.
sorin9797aba2015-04-17 17:15:03354 COMPONENT_UPDATE_FOUND,
355
356 // Sent when a CRX is in the update queue but it can't be acted on
357 // right away, because the update client spaces out CRX updates due to a
358 // throttling policy.
359 COMPONENT_WAIT,
360
361 // Sent after the new CRX has been downloaded but before the install
362 // or the upgrade is attempted.
363 COMPONENT_UPDATE_READY,
364
365 // Sent when a CRX has been successfully updated.
366 COMPONENT_UPDATED,
367
Sorin Jianucbb10e12018-01-23 18:01:44368 // Sent when a CRX has not been updated because there was no update
369 // available for this component.
sorin9797aba2015-04-17 17:15:03370 COMPONENT_NOT_UPDATED,
371
Sorin Jianucbb10e12018-01-23 18:01:44372 // Sent when an error ocurred during an update for any reason, including
373 // the update check itself failed, or the download of the update payload
374 // failed, or applying the update failed.
375 COMPONENT_UPDATE_ERROR,
376
sorin9797aba2015-04-17 17:15:03377 // Sent when CRX bytes are being downloaded.
378 COMPONENT_UPDATE_DOWNLOADING,
Sorin Jianuc9d32b2f2020-05-08 23:07:26379
380 // Sent when install progress is received from the CRX installer.
381 COMPONENT_UPDATE_UPDATING,
sorin9797aba2015-04-17 17:15:03382 };
383
Sorin Jianu30881152020-03-16 14:31:19384 virtual ~Observer() = default;
sorin9797aba2015-04-17 17:15:03385
386 // Called by the update client when a state change happens.
387 // If an |id| is specified, then the event is fired on behalf of the
388 // specific CRX. The implementors of this interface are
389 // expected to filter the relevant events based on the id of the CRX.
390 virtual void OnEvent(Events event, const std::string& id) = 0;
391 };
392
393 // Adds an observer for this class. An observer should not be added more
394 // than once. The caller retains the ownership of the observer object.
395 virtual void AddObserver(Observer* observer) = 0;
396
397 // Removes an observer. It is safe for an observer to be removed while
398 // the observers are being notified.
399 virtual void RemoveObserver(Observer* observer) = 0;
400
sorin842703b2016-11-02 23:59:23401 // Installs the specified CRX. Calls back on |callback| after the
Sorin Jianudfb12a42020-03-10 04:12:03402 // update has been handled. Provides state change notifications through
403 // invocations of the optional |crx_state_change_callback| callback.
404 // The |error| parameter of the |callback| contains an error code in the case
405 // of a run-time error, or 0 if the install has been handled successfully.
406 // Overlapping calls of this function are executed concurrently, as long as
407 // the id parameter is different, meaning that installs of different
408 // components are parallelized.
sorin08d153c2015-10-30 00:04:20409 // The |Install| function is intended to be used for foreground installs of
410 // one CRX. These cases are usually associated with on-demand install
411 // scenarios, which are triggered by user actions. Installs are never
412 // queued up.
sorin9797aba2015-04-17 17:15:03413 virtual void Install(const std::string& id,
Sorin Jianua8ef73d2017-11-02 16:55:17414 CrxDataCallback crx_data_callback,
Sorin Jianudfb12a42020-03-10 04:12:03415 CrxStateChangeCallback crx_state_change_callback,
Vladislav Kuzkokov12eca792017-10-20 12:45:38416 Callback callback) = 0;
sorin9797aba2015-04-17 17:15:03417
418 // Updates the specified CRXs. Calls back on |crx_data_callback| before the
419 // update is attempted to give the caller the opportunity to provide the
Sorin Jianudfb12a42020-03-10 04:12:03420 // instances of CrxComponent to be used for this update. Provides state change
421 // notifications through invocations of the optional
422 // |crx_state_change_callback| callback.
423 // The |Update| function is intended to be used for background updates of
424 // several CRXs. Overlapping calls to this function result in a queuing
425 // behavior, and the execution of each call is serialized. In addition,
426 // updates are always queued up when installs are running. The |is_foreground|
427 // parameter must be set to true if the invocation of this function is a
428 // result of a user initiated update.
sorin9797aba2015-04-17 17:15:03429 virtual void Update(const std::vector<std::string>& ids,
Sorin Jianua8ef73d2017-11-02 16:55:17430 CrxDataCallback crx_data_callback,
Sorin Jianudfb12a42020-03-10 04:12:03431 CrxStateChangeCallback crx_state_change_callback,
Sorin Jianub41a592a2018-03-02 16:30:27432 bool is_foreground,
Vladislav Kuzkokov12eca792017-10-20 12:45:38433 Callback callback) = 0;
sorin9797aba2015-04-17 17:15:03434
sorin805aa03112016-01-14 23:01:31435 // Sends an uninstall ping for the CRX identified by |id| and |version|. The
436 // |reason| parameter is defined by the caller. The current implementation of
437 // this function only sends a best-effort, fire-and-forget ping. It has no
438 // other side effects regarding installs or updates done through an instance
439 // of this class.
440 virtual void SendUninstallPing(const std::string& id,
pwnalldb0b72412016-08-19 21:39:12441 const base::Version& version,
sorin8037ac8c2017-04-19 16:28:00442 int reason,
Vladislav Kuzkokov12eca792017-10-20 12:45:38443 Callback callback) = 0;
sorin805aa03112016-01-14 23:01:31444
Sam Sappenfield4a065262020-07-29 19:28:18445 // Sends a registration ping for the CRX identified by |id| and |version|.
446 // The current implementation of this function only sends a best-effort,
447 // fire-and-forget ping. It has no other side effects regarding installs or
448 // updates done through an instance of this class.
449 virtual void SendRegistrationPing(const std::string& id,
450 const base::Version& version,
451 Callback callback) = 0;
452
sorin9797aba2015-04-17 17:15:03453 // Returns status details about a CRX update. The function returns true in
454 // case of success and false in case of errors, such as |id| was
455 // invalid or not known.
456 virtual bool GetCrxUpdateState(const std::string& id,
457 CrxUpdateItem* update_item) const = 0;
458
sorin08d153c2015-10-30 00:04:20459 // Returns true if the |id| is found in any running task.
sorin9797aba2015-04-17 17:15:03460 virtual bool IsUpdating(const std::string& id) const = 0;
461
sorinecaad3e2015-11-13 19:15:52462 // Cancels the queued updates and makes a best effort to stop updates in
463 // progress as soon as possible. Some updates may not be stopped, in which
464 // case, the updates will run to completion. Calling this function has no
465 // effect if updates are not currently executed or queued up.
466 virtual void Stop() = 0;
467
sorin7c717622015-05-26 19:59:09468 protected:
Sorin Jianu569aa7192020-07-23 16:09:54469 friend class base::RefCountedThreadSafe<UpdateClient>;
sorin7c717622015-05-26 19:59:09470
Sorin Jianu30881152020-03-16 14:31:19471 virtual ~UpdateClient() = default;
sorin9797aba2015-04-17 17:15:03472};
473
474// Creates an instance of the update client.
sorin7c717622015-05-26 19:59:09475scoped_refptr<UpdateClient> UpdateClientFactory(
Sorin Jianu49126332018-02-13 17:07:42476 scoped_refptr<Configurator> config);
sorin9797aba2015-04-17 17:15:03477
wafflesd2d9a332016-04-09 01:59:57478// This must be called prior to the construction of any Configurator that
479// contains a PrefService.
480void RegisterPrefs(PrefRegistrySimple* registry);
481
Minh X. Nguyen3aa40692018-03-28 01:15:59482// This must be called prior to the construction of any Configurator that
483// needs access to local user profiles.
484// This function is mostly used for ExtensionUpdater, which requires update
485// info from user profiles.
486void RegisterProfilePrefs(PrefRegistrySimple* registry);
487
sorin52ac0882015-01-24 01:15:00488} // namespace update_client
489
490#endif // COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_H_