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

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

Issue 2950803002: Use ContainsValue() instead of std::find() in chrome/browser/ and chrome/test/ (Closed)
Patch Set: Reverted code for file thumbnail_cache.cc Created 3 years, 6 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/safe_browsing/local_database_manager.h" 5 #include "chrome/browser/safe_browsing/local_database_manager.h"
6 6
7 #include <algorithm>
8 #include <limits> 7 #include <limits>
9 8
10 #include "base/bind.h" 9 #include "base/bind.h"
11 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
12 #include "base/callback.h" 11 #include "base/callback.h"
13 #include "base/command_line.h" 12 #include "base/command_line.h"
14 #include "base/debug/leak_tracker.h" 13 #include "base/debug/leak_tracker.h"
15 #include "base/location.h" 14 #include "base/location.h"
16 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
17 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
18 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/stl_util.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/task_scheduler/post_task.h" 20 #include "base/task_scheduler/post_task.h"
21 #include "base/threading/thread_task_runner_handle.h" 21 #include "base/threading/thread_task_runner_handle.h"
22 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/chrome_notification_types.h" 23 #include "chrome/browser/chrome_notification_types.h"
24 #include "chrome/browser/prerender/prerender_field_trial.h" 24 #include "chrome/browser/prerender/prerender_field_trial.h"
25 #include "chrome/browser/profiles/profile_manager.h" 25 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 26 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
27 #include "chrome/browser/safe_browsing/download_protection_service.h" 27 #include "chrome/browser/safe_browsing/download_protection_service.h"
28 #include "chrome/browser/safe_browsing/protocol_manager.h" 28 #include "chrome/browser/safe_browsing/protocol_manager.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 result = SafeBrowsingProtocolManager::GET_HASH_FULL_HASH_HIT; 64 result = SafeBrowsingProtocolManager::GET_HASH_FULL_HASH_HIT;
65 } else { 65 } else {
66 result = SafeBrowsingProtocolManager::GET_HASH_FULL_HASH_MISS; 66 result = SafeBrowsingProtocolManager::GET_HASH_FULL_HASH_MISS;
67 } 67 }
68 bool is_download = check_type == BINURL; 68 bool is_download = check_type == BINURL;
69 SafeBrowsingProtocolManager::RecordGetHashResult(is_download, result); 69 SafeBrowsingProtocolManager::RecordGetHashResult(is_download, result);
70 } 70 }
71 71
72 bool IsExpectedThreat(const SBThreatType threat_type, 72 bool IsExpectedThreat(const SBThreatType threat_type,
73 const std::vector<SBThreatType>& expected_threats) { 73 const std::vector<SBThreatType>& expected_threats) {
74 return expected_threats.end() != std::find(expected_threats.begin(), 74 return base::ContainsValue(expected_threats, threat_type);
75 expected_threats.end(),
76 threat_type);
77 } 75 }
78 76
79 // Returns threat level of the list. Lists with lower threat levels are more 77 // Returns threat level of the list. Lists with lower threat levels are more
80 // severe than lists with higher threat levels. Zero is the severest threat 78 // severe than lists with higher threat levels. Zero is the severest threat
81 // level possible. 79 // level possible.
82 int GetThreatSeverity(ListType threat) { 80 int GetThreatSeverity(ListType threat) {
83 switch (threat) { 81 switch (threat) {
84 case MALWARE: // Falls through. 82 case MALWARE: // Falls through.
85 case PHISH: // Falls through. 83 case PHISH: // Falls through.
86 case BINURL: // Falls through. 84 case BINURL: // Falls through.
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 base::BindOnce(&LocalSafeBrowsingDatabaseManager::TimeoutCallback, 1260 base::BindOnce(&LocalSafeBrowsingDatabaseManager::TimeoutCallback,
1263 check_ptr->weak_ptr_factory_->GetWeakPtr(), check_ptr), 1261 check_ptr->weak_ptr_factory_->GetWeakPtr(), check_ptr),
1264 check_timeout_); 1262 check_timeout_);
1265 } 1263 }
1266 1264
1267 bool LocalSafeBrowsingDatabaseManager::IsDownloadProtectionEnabled() const { 1265 bool LocalSafeBrowsingDatabaseManager::IsDownloadProtectionEnabled() const {
1268 return enable_download_protection_; 1266 return enable_download_protection_;
1269 } 1267 }
1270 1268
1271 } // namespace safe_browsing 1269 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698