| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/component_updater/component_updater_service.h" | 5 #include "components/component_updater/component_updater_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 257 |
| 258 return true; | 258 return true; |
| 259 } | 259 } |
| 260 | 260 |
| 261 bool CrxUpdateService::CheckForUpdates() { | 261 bool CrxUpdateService::CheckForUpdates() { |
| 262 DCHECK(thread_checker_.CalledOnValidThread()); | 262 DCHECK(thread_checker_.CalledOnValidThread()); |
| 263 | 263 |
| 264 UMA_HISTOGRAM_ENUMERATION("ComponentUpdater.Calls", UPDATE_TYPE_AUTOMATIC, | 264 UMA_HISTOGRAM_ENUMERATION("ComponentUpdater.Calls", UPDATE_TYPE_AUTOMATIC, |
| 265 UPDATE_TYPE_COUNT); | 265 UPDATE_TYPE_COUNT); |
| 266 | 266 |
| 267 std::vector<std::string> ids; | 267 std::vector<std::string> secure_ids; // Requires HTTPS for update checks. |
| 268 std::vector<std::string> unsecure_ids; // Can fallback to HTTP. |
| 268 for (const auto id : components_order_) { | 269 for (const auto id : components_order_) { |
| 269 DCHECK(components_.find(id) != components_.end()); | 270 DCHECK(components_.find(id) != components_.end()); |
| 270 ids.push_back(id); | 271 |
| 272 auto component(GetComponent(id)); |
| 273 if (!component || component->requires_network_encryption) |
| 274 secure_ids.push_back(id); |
| 275 else |
| 276 unsecure_ids.push_back(id); |
| 271 } | 277 } |
| 272 | 278 |
| 273 update_client_->Update( | 279 if (!unsecure_ids.empty()) { |
| 274 ids, base::Bind(&CrxUpdateService::OnUpdate, base::Unretained(this)), | 280 update_client_->Update( |
| 275 base::Bind(&CrxUpdateService::OnUpdateComplete, base::Unretained(this), | 281 unsecure_ids, |
| 276 base::TimeTicks::Now())); | 282 base::Bind(&CrxUpdateService::OnUpdate, base::Unretained(this)), |
| 283 base::Bind(&CrxUpdateService::OnUpdateComplete, base::Unretained(this), |
| 284 base::TimeTicks::Now())); |
| 285 } |
| 286 |
| 287 if (!secure_ids.empty()) { |
| 288 update_client_->Update( |
| 289 secure_ids, |
| 290 base::Bind(&CrxUpdateService::OnUpdate, base::Unretained(this)), |
| 291 base::Bind(&CrxUpdateService::OnUpdateComplete, base::Unretained(this), |
| 292 base::TimeTicks::Now())); |
| 293 } |
| 277 | 294 |
| 278 return true; | 295 return true; |
| 279 } | 296 } |
| 280 | 297 |
| 281 scoped_refptr<base::SequencedTaskRunner> | 298 scoped_refptr<base::SequencedTaskRunner> |
| 282 CrxUpdateService::GetSequencedTaskRunner() { | 299 CrxUpdateService::GetSequencedTaskRunner() { |
| 283 DCHECK(thread_checker_.CalledOnValidThread()); | 300 DCHECK(thread_checker_.CalledOnValidThread()); |
| 284 return blocking_task_runner_; | 301 return blocking_task_runner_; |
| 285 } | 302 } |
| 286 | 303 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 // TODO(sorin): consider making this a singleton. | 391 // TODO(sorin): consider making this a singleton. |
| 375 scoped_ptr<ComponentUpdateService> ComponentUpdateServiceFactory( | 392 scoped_ptr<ComponentUpdateService> ComponentUpdateServiceFactory( |
| 376 const scoped_refptr<Configurator>& config) { | 393 const scoped_refptr<Configurator>& config) { |
| 377 DCHECK(config); | 394 DCHECK(config); |
| 378 auto update_client = update_client::UpdateClientFactory(config); | 395 auto update_client = update_client::UpdateClientFactory(config); |
| 379 return scoped_ptr<ComponentUpdateService>( | 396 return scoped_ptr<ComponentUpdateService>( |
| 380 new CrxUpdateService(config, std::move(update_client))); | 397 new CrxUpdateService(config, std::move(update_client))); |
| 381 } | 398 } |
| 382 | 399 |
| 383 } // namespace component_updater | 400 } // namespace component_updater |
| OLD | NEW |