OLD | NEW |
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 #ifndef CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 // A class that gets malware details from the HTTP Cache. | 9 // A class that gets malware details from the HTTP Cache. |
10 // An instance of this class is generated by MalwareDetails. | 10 // An instance of this class is generated by MalwareDetails. |
(...skipping 20 matching lines...) Expand all Loading... |
31 std::string, | 31 std::string, |
32 linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource> > ResourceMap; | 32 linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource> > ResourceMap; |
33 } | 33 } |
34 | 34 |
35 class MalwareDetailsCacheCollector | 35 class MalwareDetailsCacheCollector |
36 : public base::RefCountedThreadSafe<MalwareDetailsCacheCollector>, | 36 : public base::RefCountedThreadSafe<MalwareDetailsCacheCollector>, |
37 public content::URLFetcherDelegate { | 37 public content::URLFetcherDelegate { |
38 | 38 |
39 public: | 39 public: |
40 MalwareDetailsCacheCollector(); | 40 MalwareDetailsCacheCollector(); |
41 virtual ~MalwareDetailsCacheCollector(); | |
42 | 41 |
43 // We use |request_context_getter|, we modify |resources| and | 42 // We use |request_context_getter|, we modify |resources| and |
44 // |result|, and we call |callback|, so they must all remain alive | 43 // |result|, and we call |callback|, so they must all remain alive |
45 // for the lifetime of this object. | 44 // for the lifetime of this object. |
46 void StartCacheCollection( | 45 void StartCacheCollection( |
47 net::URLRequestContextGetter* request_context_getter, | 46 net::URLRequestContextGetter* request_context_getter, |
48 safe_browsing::ResourceMap* resources, | 47 safe_browsing::ResourceMap* resources, |
49 bool* result, | 48 bool* result, |
50 const base::Closure& callback); | 49 const base::Closure& callback); |
51 | 50 |
52 // Returns whether or not StartCacheCollection has been called. | 51 // Returns whether or not StartCacheCollection has been called. |
53 bool HasStarted(); | 52 bool HasStarted(); |
54 | 53 |
55 protected: | 54 protected: |
56 // Implementation of URLFetcher::Delegate. Called after the request | 55 // Implementation of URLFetcher::Delegate. Called after the request |
57 // completes (either successfully or with failure). | 56 // completes (either successfully or with failure). |
58 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; | 57 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; |
59 | 58 |
60 private: | 59 private: |
| 60 friend class base::RefCountedThreadSafe<MalwareDetailsCacheCollector>; |
| 61 |
| 62 virtual ~MalwareDetailsCacheCollector(); |
| 63 |
61 // Points to the url for which we are fetching the HTTP cache entry or | 64 // Points to the url for which we are fetching the HTTP cache entry or |
62 // redirect chain. | 65 // redirect chain. |
63 safe_browsing::ResourceMap::iterator resources_it_; | 66 safe_browsing::ResourceMap::iterator resources_it_; |
64 | 67 |
65 // Points to the resources_ map in the MalwareDetails. | 68 // Points to the resources_ map in the MalwareDetails. |
66 safe_browsing::ResourceMap* resources_; | 69 safe_browsing::ResourceMap* resources_; |
67 | 70 |
68 // Points to the cache_result_ in the MalwareDetails. | 71 // Points to the cache_result_ in the MalwareDetails. |
69 bool* result_; | 72 bool* result_; |
70 | 73 |
(...skipping 28 matching lines...) Expand all Loading... |
99 const std::string& data); | 102 const std::string& data); |
100 | 103 |
101 // Called when we are done. | 104 // Called when we are done. |
102 void AllDone(bool success); | 105 void AllDone(bool success); |
103 | 106 |
104 // Advances to the next entry in resources_it_. | 107 // Advances to the next entry in resources_it_. |
105 void AdvanceEntry(); | 108 void AdvanceEntry(); |
106 }; | 109 }; |
107 | 110 |
108 #endif // CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_ | 111 #endif // CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_ |
OLD | NEW |