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

Unified Diff: chrome/browser/safe_browsing/client_side_detection_host.cc

Issue 21170004: Store and return urls instead of hosts for the malware IP matching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: some nit fix on int type Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/client_side_detection_host.cc
diff --git a/chrome/browser/safe_browsing/client_side_detection_host.cc b/chrome/browser/safe_browsing/client_side_detection_host.cc
index 1f67d5c38363d005c062809c59e2860fe47ff831..b87a87d9f256824f9992ff1742b59220022f480b 100644
--- a/chrome/browser/safe_browsing/client_side_detection_host.cc
+++ b/chrome/browser/safe_browsing/client_side_detection_host.cc
@@ -44,7 +44,7 @@ using content::WebContents;
namespace safe_browsing {
-const int ClientSideDetectionHost::kMaxHostsPerIP = 20;
+const int ClientSideDetectionHost::kMaxUrlsPerIP = 20;
const int ClientSideDetectionHost::kMaxIPsPerBrowse = 200;
namespace {
@@ -493,20 +493,20 @@ void ClientSideDetectionHost::MalwareFeatureExtractionDone(
}
}
-void ClientSideDetectionHost::UpdateIPHostMap(const std::string& ip,
- const std::string& host) {
- if (ip.empty() || host.empty())
+void ClientSideDetectionHost::UpdateIPUrlMap(const std::string& ip,
+ const std::string& url) {
+ if (ip.empty() || url.empty())
return;
- IPHostMap::iterator it = browse_info_->ips.find(ip);
+ IPUrlMap::iterator it = browse_info_->ips.find(ip);
if (it == browse_info_->ips.end()) {
if (int(browse_info_->ips.size()) < kMaxIPsPerBrowse) {
- std::set<std::string> hosts;
- hosts.insert(host);
- browse_info_->ips.insert(make_pair(ip, hosts));
+ std::set<std::string> urls;
+ urls.insert(url);
+ browse_info_->ips.insert(make_pair(ip, urls));
}
- } else if (int(it->second.size()) < kMaxHostsPerIP) {
- it->second.insert(host);
+ } else if (int(it->second.size()) < kMaxUrlsPerIP) {
+ it->second.insert(url);
}
}
@@ -520,8 +520,10 @@ void ClientSideDetectionHost::Observe(
details).ptr();
if (req && browse_info_.get() && malware_report_enabled_ &&
!MalwareKillSwitchIsOn()) {
- UpdateIPHostMap(req->socket_address.host() /* ip */,
- req->url.host() /* url host */);
+ if (req->url.is_valid()) {
+ UpdateIPUrlMap(req->socket_address.host() /* ip */,
+ req->url.spec() /* url */);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698