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

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

Issue 6880285: SafeBrowsing Opt-in Malware Reports: Collect remote ip:port pairs for requests that were not fetc... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/malware_details_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Implementation of the MalwareDetails class. 5 // Implementation of the MalwareDetails class.
6 6
7 #include "chrome/browser/safe_browsing/malware_details.h" 7 #include "chrome/browser/safe_browsing/malware_details.h"
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/md5.h" 11 #include "base/md5.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "chrome/browser/net/chrome_url_request_context.h" 13 #include "chrome/browser/net/chrome_url_request_context.h"
14 #include "chrome/browser/safe_browsing/malware_details_cache.h" 14 #include "chrome/browser/safe_browsing/malware_details_cache.h"
15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 15 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
16 #include "chrome/browser/safe_browsing/report.pb.h" 16 #include "chrome/browser/safe_browsing/report.pb.h"
17 #include "content/browser/browser_thread.h" 17 #include "content/browser/browser_thread.h"
18 #include "net/base/host_port_pair.h"
18 #include "net/base/load_flags.h" 19 #include "net/base/load_flags.h"
19 #include "net/http/http_response_headers.h" 20 #include "net/http/http_response_headers.h"
20 #include "net/url_request/url_request_context_getter.h" 21 #include "net/url_request/url_request_context_getter.h"
21 #include "net/url_request/url_request_status.h" 22 #include "net/url_request/url_request_status.h"
22 23
23 using safe_browsing::ClientMalwareReportRequest; 24 using safe_browsing::ClientMalwareReportRequest;
24 25
25 // Only send small files for now, a better strategy would use the size 26 // Only send small files for now, a better strategy would use the size
26 // of the whole report and the user's bandwidth. 27 // of the whole report and the user's bandwidth.
27 static const uint32 kMaxBodySizeBytes = 1024; 28 static const uint32 kMaxBodySizeBytes = 1024;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 ClientMalwareReportRequest::HTTPHeader* pb_header = 159 ClientMalwareReportRequest::HTTPHeader* pb_header =
159 pb_response->add_headers(); 160 pb_response->add_headers();
160 pb_header->set_name(name); 161 pb_header->set_name(name);
161 // Strip any Set-Cookie headers. 162 // Strip any Set-Cookie headers.
162 if (LowerCaseEqualsASCII(name, "set-cookie")) { 163 if (LowerCaseEqualsASCII(name, "set-cookie")) {
163 pb_header->set_value(""); 164 pb_header->set_value("");
164 } else { 165 } else {
165 pb_header->set_value(value); 166 pb_header->set_value(value);
166 } 167 }
167 } 168 }
169
170 if (!source->was_fetched_via_proxy()) {
171 pb_response->set_remote_ip(source->socket_address().ToString());
172 }
168 } 173 }
169 174
170 void MalwareDetailsCacheCollector::ReadData( 175 void MalwareDetailsCacheCollector::ReadData(
171 ClientMalwareReportRequest::Resource* pb_resource, 176 ClientMalwareReportRequest::Resource* pb_resource,
172 const std::string& data) { 177 const std::string& data) {
173 DVLOG(1) << "ReadData"; 178 DVLOG(1) << "ReadData";
174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
175 ClientMalwareReportRequest::HTTPResponse* pb_response = 180 ClientMalwareReportRequest::HTTPResponse* pb_response =
176 pb_resource->mutable_response(); 181 pb_resource->mutable_response();
177 if (data.size() <= kMaxBodySizeBytes) { // Only send small bodies for now. 182 if (data.size() <= kMaxBodySizeBytes) { // Only send small bodies for now.
(...skipping 17 matching lines...) Expand all
195 BrowserThread::IO, FROM_HERE, 200 BrowserThread::IO, FROM_HERE,
196 NewRunnableMethod(this, &MalwareDetailsCacheCollector::OpenEntry)); 201 NewRunnableMethod(this, &MalwareDetailsCacheCollector::OpenEntry));
197 } 202 }
198 203
199 void MalwareDetailsCacheCollector::AllDone(bool success) { 204 void MalwareDetailsCacheCollector::AllDone(bool success) {
200 DVLOG(1) << "AllDone"; 205 DVLOG(1) << "AllDone";
201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
202 *result_ = success; 207 *result_ = success;
203 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback_); 208 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback_);
204 } 209 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/malware_details_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698