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

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: Updated as per latest code Created 4 years, 10 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 std::vector<SBPrefix>* prefix_hits) { 312 std::vector<SBPrefix>* prefix_hits) {
313 bool hit = false; 313 bool hit = false;
314 for (const GURL& url : urls) { 314 for (const GURL& url : urls) {
315 base::hash_map<std::string, Hits>::const_iterator badurls_it = 315 base::hash_map<std::string, Hits>::const_iterator badurls_it =
316 badurls_.find(url.spec()); 316 badurls_.find(url.spec());
317 317
318 if (badurls_it == badurls_.end()) 318 if (badurls_it == badurls_.end())
319 continue; 319 continue;
320 320
321 std::vector<int> list_ids_for_url = badurls_it->second.list_ids; 321 std::vector<int> list_ids_for_url = badurls_it->second.list_ids;
322 if (std::find(list_ids_for_url.begin(), list_ids_for_url.end(), list_id0) 322 if (ContainsValue(list_ids_for_url, list_id0) ||
323 != list_ids_for_url.end() || 323 ContainsValue(list_ids_for_url, list_id1)) {
324 std::find(list_ids_for_url.begin(), list_ids_for_url.end(), list_id1)
325 != list_ids_for_url.end()) {
326 prefix_hits->insert(prefix_hits->end(), 324 prefix_hits->insert(prefix_hits->end(),
327 badurls_it->second.prefix_hits.begin(), 325 badurls_it->second.prefix_hits.begin(),
328 badurls_it->second.prefix_hits.end()); 326 badurls_it->second.prefix_hits.end());
329 hit = true; 327 hit = true;
330 } 328 }
331 } 329 }
332 return hit; 330 return hit;
333 } 331 }
334 332
335 std::vector<GURL> UrlsForHashes(const std::vector<SBFullHash>& full_hashes) { 333 std::vector<GURL> UrlsForHashes(const std::vector<SBFullHash>& full_hashes) {
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, 1669 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE,
1672 content::Source<SafeBrowsingDatabaseManager>( 1670 content::Source<SafeBrowsingDatabaseManager>(
1673 sb_service_->database_manager().get())); 1671 sb_service_->database_manager().get()));
1674 BrowserThread::PostTask( 1672 BrowserThread::PostTask(
1675 BrowserThread::IO, FROM_HERE, 1673 BrowserThread::IO, FROM_HERE,
1676 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); 1674 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this));
1677 observer.Wait(); 1675 observer.Wait();
1678 } 1676 }
1679 1677
1680 } // namespace safe_browsing 1678 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698