droger | f8a8814 | 2015-08-19 07:48:36 | [diff] [blame] | 1 | // 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 | |
| 14 | namespace base { |
| 15 | class CommandLine; |
| 16 | class Version; |
| 17 | } |
| 18 | |
| 19 | namespace net { |
| 20 | class URLRequestContextGetter; |
| 21 | } |
| 22 | |
| 23 | namespace component_updater { |
| 24 | |
| 25 | // Helper class for the implementations of update_client::Configurator. |
| 26 | // Can be used both on iOS and other platforms. |
| 27 | class ConfiguratorImpl { |
| 28 | public: |
| 29 | ConfiguratorImpl(const base::CommandLine* cmdline, |
sorin | fccbf2d | 2016-04-04 20:34:34 | [diff] [blame] | 30 | net::URLRequestContextGetter* url_request_getter, |
| 31 | bool require_encryption); |
droger | f8a8814 | 2015-08-19 07:48:36 | [diff] [blame] | 32 | |
| 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 | |
sorin | 590586c | 2016-01-26 20:09:40 | [diff] [blame] | 71 | // Provides a hint for the server to control the order in which multiple |
| 72 | // download urls are returned. |
| 73 | std::string GetDownloadPreference() const; |
| 74 | |
droger | f8a8814 | 2015-08-19 07:48:36 | [diff] [blame] | 75 | // 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. |
sorin | cb4e5e9 | 2016-08-02 21:48:40 | [diff] [blame] | 79 | bool EnabledDeltas() const; |
| 80 | |
| 81 | // True is the component updates are enabled. |
| 82 | bool EnabledComponentUpdates() const; |
droger | f8a8814 | 2015-08-19 07:48:36 | [diff] [blame] | 83 | |
| 84 | // True means that the background downloader can be used for downloading |
| 85 | // non on-demand components. |
sorin | cb4e5e9 | 2016-08-02 21:48:40 | [diff] [blame] | 86 | bool EnabledBackgroundDownloader() const; |
droger | f8a8814 | 2015-08-19 07:48:36 | [diff] [blame] | 87 | |
sorin | 1bc5eff | 2016-02-17 18:45:17 | [diff] [blame] | 88 | // True if signing of update checks is enabled. |
sorin | cb4e5e9 | 2016-08-02 21:48:40 | [diff] [blame] | 89 | bool EnabledCupSigning() const; |
sorin | 1bc5eff | 2016-02-17 18:45:17 | [diff] [blame] | 90 | |
droger | f8a8814 | 2015-08-19 07:48:36 | [diff] [blame] | 91 | 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_; |
sorin | fccbf2d | 2016-04-04 20:34:34 | [diff] [blame] | 99 | bool require_encryption_; |
droger | f8a8814 | 2015-08-19 07:48:36 | [diff] [blame] | 100 | |
| 101 | DISALLOW_COPY_AND_ASSIGN(ConfiguratorImpl); |
| 102 | }; |
| 103 | |
| 104 | } // namespace component_updater |
| 105 | |
| 106 | #endif // COMPONENTS_COMPONENT_UPDATER_CONFIGURATOR_IMPL_H_ |