blob: 870dc860f1667da774ba9a774d2d9677d283bd0f [file] [log] [blame]
drogerf8a88142015-08-19 07:48:361// 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_COMPONENT_UPDATER_CONFIGURATOR_IMPL_H_
6#define COMPONENTS_COMPONENT_UPDATER_CONFIGURATOR_IMPL_H_
7
8#include <string>
9#include <vector>
10
11#include "base/macros.h"
12#include "url/gurl.h"
13
14namespace base {
15class CommandLine;
16class Version;
17}
18
19namespace net {
20class URLRequestContextGetter;
21}
22
23namespace component_updater {
24
25// Helper class for the implementations of update_client::Configurator.
26// Can be used both on iOS and other platforms.
27class ConfiguratorImpl {
28 public:
29 ConfiguratorImpl(const base::CommandLine* cmdline,
sorinfccbf2d2016-04-04 20:34:3430 net::URLRequestContextGetter* url_request_getter,
31 bool require_encryption);
drogerf8a88142015-08-19 07:48:3632
33 ~ConfiguratorImpl();
34
35 // Delay in seconds from calling Start() to the first update check.
36 int InitialDelay() const;
37
38 // Delay in seconds to every subsequent update check. 0 means don't check.
39 int NextCheckDelay() const;
40
41 // Delay in seconds from each task step. Used to smooth out CPU/IO usage.
42 int StepDelay() const;
43
44 // Minimum delta time in seconds before an on-demand check is allowed for the
45 // same component.
46 int OnDemandDelay() const;
47
48 // The time delay in seconds between applying updates for different
49 // components.
50 int UpdateDelay() const;
51
52 // The URLs for the update checks. The URLs are tried in order, the first one
53 // that succeeds wins.
54 std::vector<GURL> UpdateUrl() const;
55
56 // The URLs for pings. Returns an empty vector if and only if pings are
57 // disabled. Similarly, these URLs have a fall back behavior too.
58 std::vector<GURL> PingUrl() const;
59
60 // Version of the application. Used to compare the component manifests.
61 base::Version GetBrowserVersion() const;
62
63 // Returns the OS's long name like "Windows", "Mac OS X", etc.
64 std::string GetOSLongName() const;
65
66 // Parameters added to each url request. It can be empty if none are needed.
67 // The return string must be safe for insertion as an attribute in an
68 // XML element.
69 std::string ExtraRequestParams() const;
70
sorin590586c2016-01-26 20:09:4071 // Provides a hint for the server to control the order in which multiple
72 // download urls are returned.
73 std::string GetDownloadPreference() const;
74
drogerf8a88142015-08-19 07:48:3675 // The source of contexts for all the url requests.
76 net::URLRequestContextGetter* RequestContext() const;
77
78 // True means that this client can handle delta updates.
sorincb4e5e92016-08-02 21:48:4079 bool EnabledDeltas() const;
80
81 // True is the component updates are enabled.
82 bool EnabledComponentUpdates() const;
drogerf8a88142015-08-19 07:48:3683
84 // True means that the background downloader can be used for downloading
85 // non on-demand components.
sorincb4e5e92016-08-02 21:48:4086 bool EnabledBackgroundDownloader() const;
drogerf8a88142015-08-19 07:48:3687
sorin1bc5eff2016-02-17 18:45:1788 // True if signing of update checks is enabled.
sorincb4e5e92016-08-02 21:48:4089 bool EnabledCupSigning() const;
sorin1bc5eff2016-02-17 18:45:1790
drogerf8a88142015-08-19 07:48:3691 private:
92 net::URLRequestContextGetter* url_request_getter_;
93 std::string extra_info_;
94 GURL url_source_override_;
95 bool fast_update_;
96 bool pings_enabled_;
97 bool deltas_enabled_;
98 bool background_downloads_enabled_;
sorinfccbf2d2016-04-04 20:34:3499 bool require_encryption_;
drogerf8a88142015-08-19 07:48:36100
101 DISALLOW_COPY_AND_ASSIGN(ConfiguratorImpl);
102};
103
104} // namespace component_updater
105
106#endif // COMPONENTS_COMPONENT_UPDATER_CONFIGURATOR_IMPL_H_