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 #ifndef CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_CACHE_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_BROWSER_THREAT_DETAILS_CACHE_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_CACHE_H_ | 6 #define COMPONENTS_SAFE_BROWSING_BROWSER_THREAT_DETAILS_CACHE_H_ |
7 | 7 |
8 // A class that gets threat details from the HTTP Cache. | 8 // A class that gets threat details from the HTTP Cache. |
9 // An instance of this class is generated by ThreatDetails. | 9 // An instance of this class is generated by ThreatDetails. |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/containers/hash_tables.h" | 15 #include "base/containers/hash_tables.h" |
16 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // Set to true as soon as StartCacheCollection is called. | 75 // Set to true as soon as StartCacheCollection is called. |
76 bool has_started_; | 76 bool has_started_; |
77 | 77 |
78 // Used to get a pointer to the current request context. | 78 // Used to get a pointer to the current request context. |
79 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 79 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
80 | 80 |
81 // The current URLFetcher. | 81 // The current URLFetcher. |
82 std::unique_ptr<net::URLFetcher> current_fetch_; | 82 std::unique_ptr<net::URLFetcher> current_fetch_; |
83 | 83 |
84 // Returns the resource from resources_ that corresponds to |url| | 84 // Returns the resource from resources_ that corresponds to |url| |
85 ClientSafeBrowsingReportRequest::Resource* GetResource( | 85 ClientSafeBrowsingReportRequest::Resource* GetResource(const GURL& url); |
86 const GURL& url); | |
87 | 86 |
88 // Creates a new URLFetcher and starts it. | 87 // Creates a new URLFetcher and starts it. |
89 void OpenEntry(); | 88 void OpenEntry(); |
90 | 89 |
91 // Read the HTTP response from |source| and add it to |pb_resource|. | 90 // Read the HTTP response from |source| and add it to |pb_resource|. |
92 void ReadResponse( | 91 void ReadResponse(ClientSafeBrowsingReportRequest::Resource* pb_resource, |
93 ClientSafeBrowsingReportRequest::Resource* pb_resource, | 92 const net::URLFetcher* source); |
94 const net::URLFetcher* source); | |
95 | 93 |
96 // Read the body |data| and add it to |pb_resource|. | 94 // Read the body |data| and add it to |pb_resource|. |
97 void ReadData( | 95 void ReadData(ClientSafeBrowsingReportRequest::Resource* pb_resource, |
98 ClientSafeBrowsingReportRequest::Resource* pb_resource, | 96 const std::string& data); |
99 const std::string& data); | |
100 | 97 |
101 // Called when we are done. | 98 // Called when we are done. |
102 void AllDone(bool success); | 99 void AllDone(bool success); |
103 | 100 |
104 // Advances to the next entry in resources_it_. | 101 // Advances to the next entry in resources_it_. |
105 void AdvanceEntry(); | 102 void AdvanceEntry(); |
106 }; | 103 }; |
107 | 104 |
108 } // namespace safe_browsing | 105 } // namespace safe_browsing |
109 | 106 |
110 #endif // CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_CACHE_H_ | 107 #endif // COMPONENTS_SAFE_BROWSING_BROWSER_THREAT_DETAILS_CACHE_H_ |
OLD | NEW |