Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / update_client / test_configurator.cc
bloba5cbd445e8b33c91461ef313591f36b0bea14910
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
3 // found in the LICENSE file.
5 #include "components/update_client/test_configurator.h"
7 #include "base/version.h"
8 #include "components/update_client/component_patcher_operation.h"
9 #include "url/gurl.h"
11 namespace update_client {
13 namespace {
15 std::vector<GURL> MakeDefaultUrls() {
16 std::vector<GURL> urls;
17 urls.push_back(GURL(POST_INTERCEPT_SCHEME
18 "://" POST_INTERCEPT_HOSTNAME POST_INTERCEPT_PATH));
19 return urls;
22 } // namespace
24 TestConfigurator::TestConfigurator(
25 const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner,
26 const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner)
27 : worker_task_runner_(worker_task_runner),
28 initial_time_(0),
29 ondemand_time_(0),
30 context_(new net::TestURLRequestContextGetter(network_task_runner)) {
33 TestConfigurator::~TestConfigurator() {
36 int TestConfigurator::InitialDelay() const {
37 return initial_time_;
40 int TestConfigurator::NextCheckDelay() const {
41 return 1;
44 int TestConfigurator::StepDelay() const {
45 return 0;
48 int TestConfigurator::OnDemandDelay() const {
49 return ondemand_time_;
52 int TestConfigurator::UpdateDelay() const {
53 return 1;
56 std::vector<GURL> TestConfigurator::UpdateUrl() const {
57 return MakeDefaultUrls();
60 std::vector<GURL> TestConfigurator::PingUrl() const {
61 return UpdateUrl();
64 base::Version TestConfigurator::GetBrowserVersion() const {
65 // Needs to be larger than the required version in tested component manifests.
66 return base::Version("30.0");
69 std::string TestConfigurator::GetChannel() const {
70 return "fake_channel_string";
73 std::string TestConfigurator::GetLang() const {
74 return "fake_lang";
77 std::string TestConfigurator::GetOSLongName() const {
78 return "Fake Operating System";
81 std::string TestConfigurator::ExtraRequestParams() const {
82 return "extra=\"foo\"";
85 net::URLRequestContextGetter* TestConfigurator::RequestContext() const {
86 return context_.get();
89 scoped_refptr<OutOfProcessPatcher> TestConfigurator::CreateOutOfProcessPatcher()
90 const {
91 return NULL;
94 bool TestConfigurator::DeltasEnabled() const {
95 return true;
98 bool TestConfigurator::UseBackgroundDownloader() const {
99 return false;
102 void TestConfigurator::SetOnDemandTime(int seconds) {
103 ondemand_time_ = seconds;
106 void TestConfigurator::SetInitialDelay(int seconds) {
107 initial_time_ = seconds;
110 scoped_refptr<base::SequencedTaskRunner>
111 TestConfigurator::GetSequencedTaskRunner() const {
112 DCHECK(worker_task_runner_.get());
113 return worker_task_runner_;
116 scoped_refptr<base::SingleThreadTaskRunner>
117 TestConfigurator::GetSingleThreadTaskRunner() const {
118 // This is NULL because tests do not use the background downloader.
119 return NULL;
122 } // namespace update_client