OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/updater/extension_updater.h" | 5 #include "chrome/browser/extensions/updater/extension_updater.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | |
10 #include <set> | 9 #include <set> |
11 #include <vector> | 10 #include <vector> |
12 | 11 |
13 #include "base/bind.h" | 12 #include "base/bind.h" |
14 #include "base/logging.h" | 13 #include "base/logging.h" |
15 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
16 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
17 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
18 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 for (ExtensionSet::const_iterator extension_iter = extensions->begin(); | 311 for (ExtensionSet::const_iterator extension_iter = extensions->begin(); |
313 extension_iter != extensions->end(); ++extension_iter) { | 312 extension_iter != extensions->end(); ++extension_iter) { |
314 const Extension& extension = **extension_iter; | 313 const Extension& extension = **extension_iter; |
315 if (!Manifest::IsAutoUpdateableLocation(extension.location())) { | 314 if (!Manifest::IsAutoUpdateableLocation(extension.location())) { |
316 VLOG(2) << "Extension " << extension.id() << " is not auto updateable"; | 315 VLOG(2) << "Extension " << extension.id() << " is not auto updateable"; |
317 continue; | 316 continue; |
318 } | 317 } |
319 // An extension might be overwritten by policy, and have its update url | 318 // An extension might be overwritten by policy, and have its update url |
320 // changed. Make sure existing extensions aren't fetched again, if a | 319 // changed. Make sure existing extensions aren't fetched again, if a |
321 // pending fetch for an extension with the same id already exists. | 320 // pending fetch for an extension with the same id already exists. |
322 std::list<std::string>::const_iterator pending_id_iter = std::find( | 321 if (!base::ContainsValue(pending_ids, extension.id()) && |
323 pending_ids.begin(), pending_ids.end(), extension.id()); | 322 downloader_->AddExtension(extension, request_id, fetch_priority)) { |
324 if (pending_id_iter == pending_ids.end()) { | 323 request.in_progress_ids_.push_back(extension.id()); |
325 if (downloader_->AddExtension(extension, request_id, fetch_priority)) | |
326 request.in_progress_ids_.push_back(extension.id()); | |
327 } | 324 } |
328 } | 325 } |
329 } | 326 } |
330 | 327 |
331 void ExtensionUpdater::CheckNow(const CheckParams& params) { | 328 void ExtensionUpdater::CheckNow(const CheckParams& params) { |
332 int request_id = next_request_id_++; | 329 int request_id = next_request_id_++; |
333 | 330 |
334 VLOG(2) << "Starting update check " << request_id; | 331 VLOG(2) << "Starting update check " << request_id; |
335 if (params.ids.empty()) | 332 if (params.ids.empty()) |
336 NotifyStarted(); | 333 NotifyStarted(); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 const InProgressCheck& request = requests_in_progress_[request_id]; | 603 const InProgressCheck& request = requests_in_progress_[request_id]; |
607 if (request.in_progress_ids_.empty()) { | 604 if (request.in_progress_ids_.empty()) { |
608 VLOG(2) << "Finished update check " << request_id; | 605 VLOG(2) << "Finished update check " << request_id; |
609 if (!request.callback.is_null()) | 606 if (!request.callback.is_null()) |
610 request.callback.Run(); | 607 request.callback.Run(); |
611 requests_in_progress_.erase(request_id); | 608 requests_in_progress_.erase(request_id); |
612 } | 609 } |
613 } | 610 } |
614 | 611 |
615 } // namespace extensions | 612 } // namespace extensions |
OLD | NEW |