| OLD | NEW |
| 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 // Implementation of the ThreatDetails class. | 5 // Implementation of the ThreatDetails class. |
| 6 | 6 |
| 7 #include "chrome/browser/safe_browsing/threat_details.h" | 7 #include "chrome/browser/safe_browsing/threat_details.h" |
| 8 | 8 |
| 9 #include <stdint.h> |
| 10 |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 11 #include "base/md5.h" | 13 #include "base/md5.h" |
| 12 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 13 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 14 #include "chrome/browser/safe_browsing/threat_details_cache.h" | 16 #include "chrome/browser/safe_browsing/threat_details_cache.h" |
| 15 #include "chrome/common/safe_browsing/csd.pb.h" | 17 #include "chrome/common/safe_browsing/csd.pb.h" |
| 16 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 17 #include "net/base/host_port_pair.h" | 19 #include "net/base/host_port_pair.h" |
| 18 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.h" |
| 19 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 20 #include "net/http/http_response_headers.h" | 22 #include "net/http/http_response_headers.h" |
| 21 #include "net/url_request/url_fetcher.h" | 23 #include "net/url_request/url_fetcher.h" |
| 22 #include "net/url_request/url_request_context_getter.h" | 24 #include "net/url_request/url_request_context_getter.h" |
| 23 #include "net/url_request/url_request_status.h" | 25 #include "net/url_request/url_request_status.h" |
| 24 | 26 |
| 25 using content::BrowserThread; | 27 using content::BrowserThread; |
| 26 | 28 |
| 27 // Only send small files for now, a better strategy would use the size | 29 // Only send small files for now, a better strategy would use the size |
| 28 // of the whole report and the user's bandwidth. | 30 // of the whole report and the user's bandwidth. |
| 29 static const uint32 kMaxBodySizeBytes = 1024; | 31 static const uint32_t kMaxBodySizeBytes = 1024; |
| 30 | 32 |
| 31 namespace safe_browsing { | 33 namespace safe_browsing { |
| 32 | 34 |
| 33 ThreatDetailsCacheCollector::ThreatDetailsCacheCollector() | 35 ThreatDetailsCacheCollector::ThreatDetailsCacheCollector() |
| 34 : resources_(NULL), result_(NULL), has_started_(false) {} | 36 : resources_(NULL), result_(NULL), has_started_(false) {} |
| 35 | 37 |
| 36 void ThreatDetailsCacheCollector::StartCacheCollection( | 38 void ThreatDetailsCacheCollector::StartCacheCollection( |
| 37 net::URLRequestContextGetter* request_context_getter, | 39 net::URLRequestContextGetter* request_context_getter, |
| 38 ResourceMap* resources, | 40 ResourceMap* resources, |
| 39 bool* result, | 41 bool* result, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 199 |
| 198 void ThreatDetailsCacheCollector::AllDone(bool success) { | 200 void ThreatDetailsCacheCollector::AllDone(bool success) { |
| 199 DVLOG(1) << "AllDone"; | 201 DVLOG(1) << "AllDone"; |
| 200 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 202 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 201 *result_ = success; | 203 *result_ = success; |
| 202 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback_); | 204 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback_); |
| 203 callback_.Reset(); | 205 callback_.Reset(); |
| 204 } | 206 } |
| 205 | 207 |
| 206 } // namespace safe_browsing | 208 } // namespace safe_browsing |
| OLD | NEW |