Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / component_updater / component_updater_configurator.h
1 // Copyright (c) 2011 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 CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_CONFIGURATOR_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_CONFIGURATOR_H_
7
8 #include <string>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12
13 class GURL;
14
15 namespace base {
16 class CommandLine;
17 class SingleThreadTaskRunner;
18 class SequencedTaskRunner;
19 class Version;
20 }
21
22 namespace net {
23 class URLRequestContextGetter;
24 }
25
26 namespace component_updater {
27
28 class OutOfProcessPatcher;
29
30 // Controls the component updater behavior.
31 class Configurator {
32  public:
33   virtual ~Configurator() {}
34
35   // Delay in seconds from calling Start() to the first update check.
36   virtual int InitialDelay() const = 0;
37
38   // Delay in seconds to every subsequent update check. 0 means don't check.
39   // This function is a mutator for testing purposes.
40   virtual int NextCheckDelay() = 0;
41
42   // Delay in seconds from each task step. Used to smooth out CPU/IO usage.
43   virtual int StepDelay() const = 0;
44
45   // Delay in seconds between applying updates for different components, if
46   // several updates are available at a given time. This function is a mutator
47   // for testing purposes.
48   virtual int StepDelayMedium() = 0;
49
50   // Minimum delta time in seconds before checking again the same component.
51   virtual int MinimumReCheckWait() const = 0;
52
53   // Minimum delta time in seconds before an on-demand check is allowed
54   // for the same component.
55   virtual int OnDemandDelay() const = 0;
56
57   // The url that is going to be used update checks over Omaha protocol.
58   virtual GURL UpdateUrl() const = 0;
59
60   // The url where the completion pings are sent. Invalid if and only if
61   // pings are disabled.
62   virtual GURL PingUrl() const = 0;
63
64   // Version of the application. Used to compare the component manifests.
65   virtual base::Version GetBrowserVersion() const = 0;
66
67   // Returns the value we use for the "updaterchannel=" and "prodchannel="
68   // parameters. Possible return values include: "canary", "dev", "beta", and
69   // "stable".
70   virtual std::string GetChannel() const = 0;
71
72   // Returns the language for the present locale. Possible return values are
73   // standard tags for languages, such as "en", "en-US", "de", "fr", "af", etc.
74   virtual std::string GetLang() const = 0;
75
76   // Returns the OS's long name like "Windows", "Mac OS X", etc.
77   virtual std::string GetOSLongName() const = 0;
78
79   // Parameters added to each url request. It can be empty if none are needed.
80   // The return string must be safe for insertion as an attribute in an
81   // XML element.
82   virtual std::string ExtraRequestParams() const = 0;
83
84   // How big each update request can be. Don't go above 2000.
85   virtual size_t UrlSizeLimit() const = 0;
86
87   // The source of contexts for all the url requests.
88   virtual net::URLRequestContextGetter* RequestContext() const = 0;
89
90   // Returns a new out of process patcher. May be NULL for implementations
91   // that patch in-process.
92   virtual scoped_refptr<OutOfProcessPatcher> CreateOutOfProcessPatcher()
93       const = 0;
94
95   // True means that this client can handle delta updates.
96   virtual bool DeltasEnabled() const = 0;
97
98   // True means that the background downloader can be used for downloading
99   // non on-demand components.
100   virtual bool UseBackgroundDownloader() const = 0;
101
102   // Gets a task runner to a blocking pool of threads suitable for worker jobs.
103   virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner()
104       const = 0;
105
106   // Gets a task runner for worker jobs guaranteed to run on a single thread.
107   // This thread must be capable of IO. On Windows, this thread must be
108   // initialized for use of COM objects.
109   virtual scoped_refptr<base::SingleThreadTaskRunner>
110       GetSingleThreadTaskRunner() const = 0;
111 };
112
113 Configurator* MakeChromeComponentUpdaterConfigurator(
114     const base::CommandLine* cmdline,
115     net::URLRequestContextGetter* context_getter);
116
117 }  // namespace component_updater
118
119 #endif  // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_CONFIGURATOR_H_