Chromium Code Reviews| Index: chrome/browser/component_updater/component_updater_service.cc |
| diff --git a/chrome/browser/component_updater/component_updater_service.cc b/chrome/browser/component_updater/component_updater_service.cc |
| index 94ae2b3aa6fd08983099171a80734c19ed357ef9..6dbeb305aa5f1dd92c870709ecac139b64a647f8 100644 |
| --- a/chrome/browser/component_updater/component_updater_service.cc |
| +++ b/chrome/browser/component_updater/component_updater_service.cc |
| @@ -28,7 +28,6 @@ |
| #include "chrome/browser/component_updater/crx_update_item.h" |
| #include "chrome/browser/component_updater/update_checker.h" |
| #include "chrome/browser/component_updater/update_response.h" |
| -#include "chrome/common/chrome_version_info.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/resource_controller.h" |
| #include "content/public/browser/resource_throttle.h" |
| @@ -44,8 +43,8 @@ namespace component_updater { |
| namespace { |
| // Returns true if the |proposed| version is newer than |current| version. |
| -bool IsVersionNewer(const Version& current, const std::string& proposed) { |
| - Version proposed_ver(proposed); |
| +bool IsVersionNewer(const base::Version& current, const std::string& proposed) { |
| + base::Version proposed_ver(proposed); |
| return proposed_ver.IsValid() && current.CompareTo(proposed_ver) < 0; |
| } |
| @@ -144,7 +143,9 @@ void UnblockandReapAllThrottles(CUResourceThrottle::WeakPtrVector* throttles) { |
| // thread. |
| class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater { |
| public: |
| - explicit CrxUpdateService(ComponentUpdateService::Configurator* config); |
| + explicit CrxUpdateService(ComponentUpdateService::Configurator* config, |
| + const std::string& application_version, |
|
Sorin Jianu
2014/06/19 00:48:22
same Configurator deal.
|
| + const std::string& platform_name); |
| virtual ~CrxUpdateService(); |
| // Overrides for ComponentUpdateService. |
| @@ -262,7 +263,8 @@ class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater { |
| scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
| - const Version chrome_version_; |
| + const base::Version application_version_; |
| + const std::string platform_name_; |
| bool running_; |
| @@ -273,16 +275,21 @@ class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater { |
| ////////////////////////////////////////////////////////////////////////////// |
| -CrxUpdateService::CrxUpdateService(ComponentUpdateService::Configurator* config) |
| +CrxUpdateService::CrxUpdateService(ComponentUpdateService::Configurator* config, |
| + const std::string& application_version, |
| + const std::string& platform_name) |
| : config_(config), |
| - ping_manager_( |
| - new PingManager(config->PingUrl(), config->RequestContext())), |
| + ping_manager_(new PingManager(application_version, |
|
Sorin Jianu
2014/06/19 00:48:22
Seems ok to introduce a dependency on Configurator
|
| + platform_name, |
| + config->PingUrl(), |
| + config->RequestContext())), |
| blocking_task_runner_( |
| - BrowserThread::GetBlockingPool()-> |
| - GetSequencedTaskRunnerWithShutdownBehavior( |
| + BrowserThread::GetBlockingPool() |
| + ->GetSequencedTaskRunnerWithShutdownBehavior( |
| BrowserThread::GetBlockingPool()->GetSequenceToken(), |
| base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), |
| - chrome_version_(chrome::VersionInfo().Version()), |
| + application_version_(application_version), |
| + platform_name_(platform_name), |
| running_(false) { |
| } |
| @@ -609,7 +616,7 @@ bool CrxUpdateService::CheckForUpdates() { |
| item->crx_urls.clear(); |
| item->crx_diffurls.clear(); |
| item->previous_version = item->component.version; |
| - item->next_version = Version(); |
| + item->next_version = base::Version(); |
| item->previous_fp = item->component.fingerprint; |
| item->next_fp.clear(); |
| item->diff_update_failed = false; |
| @@ -632,7 +639,9 @@ bool CrxUpdateService::CheckForUpdates() { |
| config_->RequestContext(), |
| base::Bind(&CrxUpdateService::UpdateCheckComplete, |
| base::Unretained(this))).Pass(); |
| - return update_checker_->CheckForUpdates(items_to_check, |
| + return update_checker_->CheckForUpdates(application_version_.GetString(), |
| + platform_name_, |
| + items_to_check, |
| config_->ExtraRequestParams()); |
| } |
| @@ -721,7 +730,8 @@ void CrxUpdateService::OnUpdateCheckSucceeded( |
| } |
| if (!it->manifest.browser_min_version.empty()) { |
| - if (IsVersionNewer(chrome_version_, it->manifest.browser_min_version)) { |
| + if (IsVersionNewer(application_version_, |
| + it->manifest.browser_min_version)) { |
| // The component is not compatible with this Chrome version. |
| VLOG(1) << "Ignoring incompatible component: " << crx->id; |
| ChangeItemState(crx, CrxUpdateItem::kNoUpdate); |
| @@ -737,7 +747,7 @@ void CrxUpdateService::OnUpdateCheckSucceeded( |
| } |
| // Parse the members of the result and queue an upgrade for this component. |
| - crx->next_version = Version(it->manifest.version); |
| + crx->next_version = base::Version(it->manifest.version); |
| VLOG(1) << "Update found for component: " << crx->id; |
| @@ -1089,9 +1099,11 @@ void CUResourceThrottle::Unblock() { |
| // The component update factory. Using the component updater as a singleton |
| // is the job of the browser process. |
| ComponentUpdateService* ComponentUpdateServiceFactory( |
| - ComponentUpdateService::Configurator* config) { |
| + ComponentUpdateService::Configurator* config, |
| + const std::string& application_version, |
| + const std::string& platform_name) { |
| DCHECK(config); |
| - return new CrxUpdateService(config); |
| + return new CrxUpdateService(config, application_version, platform_name); |
| } |
| } // namespace component_updater |