| Index: components/component_updater/configurator_impl.cc
|
| diff --git a/chrome/browser/component_updater/chrome_component_updater_configurator.cc b/components/component_updater/configurator_impl.cc
|
| similarity index 56%
|
| copy from chrome/browser/component_updater/chrome_component_updater_configurator.cc
|
| copy to components/component_updater/configurator_impl.cc
|
| index 7a83b82313cfdf95ee103c77f52e56bbf17696bc..c6b24a521c5a8b3a91672df558d3f1ee6e2bbb2a 100644
|
| --- a/chrome/browser/component_updater/chrome_component_updater_configurator.cc
|
| +++ b/components/component_updater/configurator_impl.cc
|
| @@ -2,11 +2,9 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/component_updater/chrome_component_updater_configurator.h"
|
| +#include "components/component_updater/configurator_impl.h"
|
|
|
| #include <algorithm>
|
| -#include <string>
|
| -#include <vector>
|
|
|
| #include "base/command_line.h"
|
| #include "base/compiler_specific.h"
|
| @@ -14,27 +12,17 @@
|
| #include "base/strings/string_util.h"
|
| #include "base/version.h"
|
| #include "build/build_config.h"
|
| -#include "chrome/browser/component_updater/component_patcher_operation_out_of_process.h"
|
| -#include "chrome/browser/component_updater/component_updater_url_constants.h"
|
| -#include "chrome/browser/update_client/chrome_update_query_params_delegate.h"
|
| #include "components/component_updater/component_updater_switches.h"
|
| #include "components/update_client/configurator.h"
|
| #include "components/version_info/version_info.h"
|
| -#include "content/public/browser/browser_thread.h"
|
| -#include "net/url_request/url_request_context_getter.h"
|
| -#include "url/gurl.h"
|
|
|
| #if defined(OS_WIN)
|
| #include "base/win/win_util.h"
|
| #endif // OS_WIN
|
|
|
| -using update_client::Configurator;
|
| -using update_client::OutOfProcessPatcher;
|
| -
|
| namespace component_updater {
|
|
|
| namespace {
|
| -
|
| // Default time constants.
|
| const int kDelayOneMinute = 60;
|
| const int kDelayOneHour = kDelayOneMinute * 60;
|
| @@ -56,6 +44,16 @@ const char kSwitchUrlSource[] = "url-source";
|
| // Disables differential updates.
|
| const char kSwitchDisableDeltaUpdates[] = "disable-delta-updates";
|
|
|
| +// The alternative URL for the v3 protocol service endpoint.
|
| +const char kUpdaterAltUrl[] = "http://clients2.google.com/service/update2";
|
| +
|
| +// The default URL for the v3 protocol service endpoint. In some cases, the
|
| +// component updater is allowed to fall back to and alternate URL source, if
|
| +// the request to the default URL source fails.
|
| +// The value of |kDefaultUrlSource| can be overridden with
|
| +// --component-updater=url-source=someurl.
|
| +const char kUpdaterDefaultUrl[] = "https://clients2.google.com/service/update2";
|
| +
|
| #if defined(OS_WIN)
|
| // Disables background downloads.
|
| const char kSwitchDisableBackgroundDownloads[] = "disable-background-downloads";
|
| @@ -90,8 +88,7 @@ std::string GetSwitchArgument(const std::vector<std::string>& vec,
|
| if (vec.empty())
|
| return std::string();
|
| for (std::vector<std::string>::const_iterator it = vec.begin();
|
| - it != vec.end();
|
| - ++it) {
|
| + it != vec.end(); ++it) {
|
| const std::size_t found = it->find("=");
|
| if (found != std::string::npos) {
|
| if (it->substr(0, found) == test) {
|
| @@ -102,48 +99,9 @@ std::string GetSwitchArgument(const std::vector<std::string>& vec,
|
| return std::string();
|
| }
|
|
|
| -class ChromeConfigurator : public Configurator {
|
| - public:
|
| - ChromeConfigurator(const base::CommandLine* cmdline,
|
| - net::URLRequestContextGetter* url_request_getter);
|
| -
|
| - int InitialDelay() const override;
|
| - int NextCheckDelay() const override;
|
| - int StepDelay() const override;
|
| - int OnDemandDelay() const override;
|
| - int UpdateDelay() const override;
|
| - std::vector<GURL> UpdateUrl() const override;
|
| - std::vector<GURL> PingUrl() const override;
|
| - base::Version GetBrowserVersion() const override;
|
| - std::string GetChannel() const override;
|
| - std::string GetLang() const override;
|
| - std::string GetOSLongName() const override;
|
| - std::string ExtraRequestParams() const override;
|
| - net::URLRequestContextGetter* RequestContext() const override;
|
| - scoped_refptr<OutOfProcessPatcher> CreateOutOfProcessPatcher() const override;
|
| - bool DeltasEnabled() const override;
|
| - bool UseBackgroundDownloader() const override;
|
| - scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner()
|
| - const override;
|
| - scoped_refptr<base::SingleThreadTaskRunner> GetSingleThreadTaskRunner()
|
| - const override;
|
| -
|
| - private:
|
| - friend class base::RefCountedThreadSafe<ChromeConfigurator>;
|
| -
|
| - ~ChromeConfigurator() override {}
|
| -
|
| - net::URLRequestContextGetter* url_request_getter_;
|
| - std::string extra_info_;
|
| - GURL url_source_override_;
|
| - bool fast_update_;
|
| - bool pings_enabled_;
|
| - bool deltas_enabled_;
|
| - bool background_downloads_enabled_;
|
| - bool fallback_to_alt_source_url_enabled_;
|
| -};
|
| -
|
| -ChromeConfigurator::ChromeConfigurator(
|
| +} // namespace
|
| +
|
| +ConfiguratorImpl::ConfiguratorImpl(
|
| const base::CommandLine* cmdline,
|
| net::URLRequestContextGetter* url_request_getter)
|
| : url_request_getter_(url_request_getter),
|
| @@ -154,8 +112,8 @@ ChromeConfigurator::ChromeConfigurator(
|
| fallback_to_alt_source_url_enabled_(false) {
|
| // Parse comma-delimited debug flags.
|
| std::vector<std::string> switch_values = base::SplitString(
|
| - cmdline->GetSwitchValueASCII(switches::kComponentUpdater),
|
| - ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
| + cmdline->GetSwitchValueASCII(switches::kComponentUpdater), ",",
|
| + base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
| fast_update_ = HasSwitchValue(switch_values, kSwitchFastUpdate);
|
| pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings);
|
| deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates);
|
| @@ -180,27 +138,29 @@ ChromeConfigurator::ChromeConfigurator(
|
| fallback_to_alt_source_url_enabled_ = CanUseAltUrlSource();
|
| }
|
|
|
| -int ChromeConfigurator::InitialDelay() const {
|
| +ConfiguratorImpl::~ConfiguratorImpl() {}
|
| +
|
| +int ConfiguratorImpl::InitialDelay() const {
|
| return fast_update_ ? 10 : (6 * kDelayOneMinute);
|
| }
|
|
|
| -int ChromeConfigurator::NextCheckDelay() const {
|
| +int ConfiguratorImpl::NextCheckDelay() const {
|
| return fast_update_ ? 60 : (6 * kDelayOneHour);
|
| }
|
|
|
| -int ChromeConfigurator::StepDelay() const {
|
| +int ConfiguratorImpl::StepDelay() const {
|
| return fast_update_ ? 1 : 1;
|
| }
|
|
|
| -int ChromeConfigurator::OnDemandDelay() const {
|
| +int ConfiguratorImpl::OnDemandDelay() const {
|
| return fast_update_ ? 2 : (30 * kDelayOneMinute);
|
| }
|
|
|
| -int ChromeConfigurator::UpdateDelay() const {
|
| +int ConfiguratorImpl::UpdateDelay() const {
|
| return fast_update_ ? 10 : (15 * kDelayOneMinute);
|
| }
|
|
|
| -std::vector<GURL> ChromeConfigurator::UpdateUrl() const {
|
| +std::vector<GURL> ConfiguratorImpl::UpdateUrl() const {
|
| std::vector<GURL> urls;
|
| if (url_source_override_.is_valid()) {
|
| urls.push_back(GURL(url_source_override_));
|
| @@ -213,68 +173,32 @@ std::vector<GURL> ChromeConfigurator::UpdateUrl() const {
|
| return urls;
|
| }
|
|
|
| -std::vector<GURL> ChromeConfigurator::PingUrl() const {
|
| +std::vector<GURL> ConfiguratorImpl::PingUrl() const {
|
| return pings_enabled_ ? UpdateUrl() : std::vector<GURL>();
|
| }
|
|
|
| -base::Version ChromeConfigurator::GetBrowserVersion() const {
|
| +base::Version ConfiguratorImpl::GetBrowserVersion() const {
|
| return base::Version(version_info::GetVersionNumber());
|
| }
|
|
|
| -std::string ChromeConfigurator::GetChannel() const {
|
| - return ChromeUpdateQueryParamsDelegate::GetChannelString();
|
| -}
|
| -
|
| -std::string ChromeConfigurator::GetLang() const {
|
| - return ChromeUpdateQueryParamsDelegate::GetLang();
|
| -}
|
| -
|
| -std::string ChromeConfigurator::GetOSLongName() const {
|
| +std::string ConfiguratorImpl::GetOSLongName() const {
|
| return version_info::GetOSType();
|
| }
|
|
|
| -std::string ChromeConfigurator::ExtraRequestParams() const {
|
| +std::string ConfiguratorImpl::ExtraRequestParams() const {
|
| return extra_info_;
|
| }
|
|
|
| -net::URLRequestContextGetter* ChromeConfigurator::RequestContext() const {
|
| +net::URLRequestContextGetter* ConfiguratorImpl::RequestContext() const {
|
| return url_request_getter_;
|
| }
|
|
|
| -scoped_refptr<OutOfProcessPatcher>
|
| -ChromeConfigurator::CreateOutOfProcessPatcher() const {
|
| - return make_scoped_refptr(new ChromeOutOfProcessPatcher);
|
| -}
|
| -
|
| -bool ChromeConfigurator::DeltasEnabled() const {
|
| +bool ConfiguratorImpl::DeltasEnabled() const {
|
| return deltas_enabled_;
|
| }
|
|
|
| -bool ChromeConfigurator::UseBackgroundDownloader() const {
|
| +bool ConfiguratorImpl::UseBackgroundDownloader() const {
|
| return background_downloads_enabled_;
|
| }
|
|
|
| -scoped_refptr<base::SequencedTaskRunner>
|
| -ChromeConfigurator::GetSequencedTaskRunner() const {
|
| - return content::BrowserThread::GetBlockingPool()
|
| - ->GetSequencedTaskRunnerWithShutdownBehavior(
|
| - content::BrowserThread::GetBlockingPool()->GetSequenceToken(),
|
| - base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
|
| -}
|
| -
|
| -scoped_refptr<base::SingleThreadTaskRunner>
|
| -ChromeConfigurator::GetSingleThreadTaskRunner() const {
|
| - return content::BrowserThread::GetMessageLoopProxyForThread(
|
| - content::BrowserThread::FILE);
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| -scoped_refptr<update_client::Configurator>
|
| -MakeChromeComponentUpdaterConfigurator(
|
| - const base::CommandLine* cmdline,
|
| - net::URLRequestContextGetter* context_getter) {
|
| - return new ChromeConfigurator(cmdline, context_getter);
|
| -}
|
| -
|
| } // namespace component_updater
|
|
|