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 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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "net/url_request/url_request_status.h" | 24 #include "net/url_request/url_request_status.h" |
25 | 25 |
26 using content::BrowserThread; | 26 using content::BrowserThread; |
27 using safe_browsing::ClientMalwareReportRequest; | 27 using safe_browsing::ClientMalwareReportRequest; |
28 | 28 |
29 // 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 |
30 // of the whole report and the user's bandwidth. | 30 // of the whole report and the user's bandwidth. |
31 static const uint32 kMaxBodySizeBytes = 1024; | 31 static const uint32 kMaxBodySizeBytes = 1024; |
32 | 32 |
33 MalwareDetailsCacheCollector::MalwareDetailsCacheCollector() | 33 MalwareDetailsCacheCollector::MalwareDetailsCacheCollector() |
34 : resources_(NULL), | 34 : resources_(NULL), result_(NULL), has_started_(false) {} |
35 result_(NULL), | |
36 has_started_(false), | |
37 current_fetch_(NULL) { | |
38 } | |
39 | 35 |
40 void MalwareDetailsCacheCollector::StartCacheCollection( | 36 void MalwareDetailsCacheCollector::StartCacheCollection( |
41 net::URLRequestContextGetter* request_context_getter, | 37 net::URLRequestContextGetter* request_context_getter, |
42 safe_browsing::ResourceMap* resources, | 38 safe_browsing::ResourceMap* resources, |
43 bool* result, | 39 bool* result, |
44 const base::Closure& callback) { | 40 const base::Closure& callback) { |
45 // Start the data collection from the HTTP cache. We use a URLFetcher | 41 // Start the data collection from the HTTP cache. We use a URLFetcher |
46 // and set the right flags so we only hit the cache. | 42 // and set the right flags so we only hit the cache. |
47 DVLOG(1) << "Getting cache data for all urls..."; | 43 DVLOG(1) << "Getting cache data for all urls..."; |
48 request_context_getter_ = request_context_getter; | 44 request_context_getter_ = request_context_getter; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 base::Bind(&MalwareDetailsCacheCollector::OpenEntry, this)); | 197 base::Bind(&MalwareDetailsCacheCollector::OpenEntry, this)); |
202 } | 198 } |
203 | 199 |
204 void MalwareDetailsCacheCollector::AllDone(bool success) { | 200 void MalwareDetailsCacheCollector::AllDone(bool success) { |
205 DVLOG(1) << "AllDone"; | 201 DVLOG(1) << "AllDone"; |
206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
207 *result_ = success; | 203 *result_ = success; |
208 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback_); | 204 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback_); |
209 callback_.Reset(); | 205 callback_.Reset(); |
210 } | 206 } |
OLD | NEW |