Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: chrome/browser/extensions/updater/extension_updater.cc

Issue 2961033002: Use ContainsValue() instead of std::find() in chrome/browser/extensions (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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());
324 if (pending_id_iter == pending_ids.end()) {
325 if (downloader_->AddExtension(extension, request_id, fetch_priority)) 322 if (downloader_->AddExtension(extension, request_id, fetch_priority))
Devlin 2017/06/30 01:52:00 nit: not this patch, but maybe combine this with t
Tripta 2017/07/03 05:34:44 Done.
326 request.in_progress_ids_.push_back(extension.id()); 323 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())
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698