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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc

Issue 1715683002: chrome: Use base's ContainsValue helper function instead of std::find (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing non ContainsValue changes Created 4 years, 9 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 // This test creates a safebrowsing service using test safebrowsing database 5 // This test creates a safebrowsing service using test safebrowsing database
6 // and a test protocol manager. It is used to test logics in safebrowsing 6 // and a test protocol manager. It is used to test logics in safebrowsing
7 // service. 7 // service.
8 8
9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 9 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
10 10
11 #include <algorithm>
12 #include <utility> 11 #include <utility>
13 12
14 #include "base/bind.h" 13 #include "base/bind.h"
15 #include "base/command_line.h" 14 #include "base/command_line.h"
16 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
17 #include "base/files/scoped_temp_dir.h" 16 #include "base/files/scoped_temp_dir.h"
18 #include "base/macros.h" 17 #include "base/macros.h"
19 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
20 #include "base/metrics/field_trial.h" 19 #include "base/metrics/field_trial.h"
21 #include "base/path_service.h" 20 #include "base/path_service.h"
21 #include "base/stl_util.h"
22 #include "base/strings/string_split.h" 22 #include "base/strings/string_split.h"
23 #include "base/strings/string_util.h" 23 #include "base/strings/string_util.h"
24 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
25 #include "base/test/thread_test_helper.h" 25 #include "base/test/thread_test_helper.h"
26 #include "base/time/time.h" 26 #include "base/time/time.h"
27 #include "build/build_config.h" 27 #include "build/build_config.h"
28 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h" 28 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h"
29 #include "chrome/browser/browser_process.h" 29 #include "chrome/browser/browser_process.h"
30 #include "chrome/browser/chrome_notification_types.h" 30 #include "chrome/browser/chrome_notification_types.h"
31 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 31 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 std::vector<SBPrefix>* prefix_hits) { 319 std::vector<SBPrefix>* prefix_hits) {
320 bool hit = false; 320 bool hit = false;
321 for (const GURL& url : urls) { 321 for (const GURL& url : urls) {
322 base::hash_map<std::string, Hits>::const_iterator badurls_it = 322 base::hash_map<std::string, Hits>::const_iterator badurls_it =
323 badurls_.find(url.spec()); 323 badurls_.find(url.spec());
324 324
325 if (badurls_it == badurls_.end()) 325 if (badurls_it == badurls_.end())
326 continue; 326 continue;
327 327
328 std::vector<int> list_ids_for_url = badurls_it->second.list_ids; 328 std::vector<int> list_ids_for_url = badurls_it->second.list_ids;
329 if (std::find(list_ids_for_url.begin(), list_ids_for_url.end(), list_id0) 329 if (ContainsValue(list_ids_for_url, list_id0) ||
330 != list_ids_for_url.end() || 330 ContainsValue(list_ids_for_url, list_id1)) {
331 std::find(list_ids_for_url.begin(), list_ids_for_url.end(), list_id1)
332 != list_ids_for_url.end()) {
333 prefix_hits->insert(prefix_hits->end(), 331 prefix_hits->insert(prefix_hits->end(),
334 badurls_it->second.prefix_hits.begin(), 332 badurls_it->second.prefix_hits.begin(),
335 badurls_it->second.prefix_hits.end()); 333 badurls_it->second.prefix_hits.end());
336 hit = true; 334 hit = true;
337 } 335 }
338 } 336 }
339 return hit; 337 return hit;
340 } 338 }
341 339
342 std::vector<GURL> UrlsForHashes(const std::vector<SBFullHash>& full_hashes) { 340 std::vector<GURL> UrlsForHashes(const std::vector<SBFullHash>& full_hashes) {
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, 1726 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE,
1729 content::Source<SafeBrowsingDatabaseManager>( 1727 content::Source<SafeBrowsingDatabaseManager>(
1730 sb_service_->database_manager().get())); 1728 sb_service_->database_manager().get()));
1731 BrowserThread::PostTask( 1729 BrowserThread::PostTask(
1732 BrowserThread::IO, FROM_HERE, 1730 BrowserThread::IO, FROM_HERE,
1733 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); 1731 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this));
1734 observer.Wait(); 1732 observer.Wait();
1735 } 1733 }
1736 1734
1737 } // namespace safe_browsing 1735 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698