| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 safe_browsing::ResourceMap* resources, | 50 safe_browsing::ResourceMap* resources, |
| 51 bool* result, | 51 bool* result, |
| 52 const base::Closure& callback); | 52 const base::Closure& callback); |
| 53 | 53 |
| 54 // Returns whether or not StartCacheCollection has been called. | 54 // Returns whether or not StartCacheCollection has been called. |
| 55 bool HasStarted(); | 55 bool HasStarted(); |
| 56 | 56 |
| 57 protected: | 57 protected: |
| 58 // Implementation of URLFetcher::Delegate. Called after the request | 58 // Implementation of URLFetcher::Delegate. Called after the request |
| 59 // completes (either successfully or with failure). | 59 // completes (either successfully or with failure). |
| 60 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; | 60 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 // Points to the url for which we are fetching the HTTP cache entry or | 63 // Points to the url for which we are fetching the HTTP cache entry or |
| 64 // redirect chain. | 64 // redirect chain. |
| 65 safe_browsing::ResourceMap::iterator resources_it_; | 65 safe_browsing::ResourceMap::iterator resources_it_; |
| 66 | 66 |
| 67 // Points to the resources_ map in the MalwareDetails. | 67 // Points to the resources_ map in the MalwareDetails. |
| 68 safe_browsing::ResourceMap* resources_; | 68 safe_browsing::ResourceMap* resources_; |
| 69 | 69 |
| 70 // Points to the cache_result_ in the MalwareDetails. | 70 // Points to the cache_result_ in the MalwareDetails. |
| 71 bool* result_; | 71 bool* result_; |
| 72 | 72 |
| 73 // Method we call when we are done. The caller must be alive for the | 73 // Method we call when we are done. The caller must be alive for the |
| 74 // whole time, we are modifying its state (see above). | 74 // whole time, we are modifying its state (see above). |
| 75 base::Closure callback_; | 75 base::Closure callback_; |
| 76 | 76 |
| 77 // Set to true as soon as StartCacheCollection is called. | 77 // Set to true as soon as StartCacheCollection is called. |
| 78 bool has_started_; | 78 bool has_started_; |
| 79 | 79 |
| 80 // Used to get a pointer to the current request context. | 80 // Used to get a pointer to the current request context. |
| 81 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 81 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 82 | 82 |
| 83 // The current URLFetcher. | 83 // The current URLFetcher. |
| 84 scoped_ptr<URLFetcher> current_fetch_; | 84 scoped_ptr<content::URLFetcher> current_fetch_; |
| 85 | 85 |
| 86 // Returns the resource from resources_ that corresponds to |url| | 86 // Returns the resource from resources_ that corresponds to |url| |
| 87 safe_browsing::ClientMalwareReportRequest::Resource* GetResource( | 87 safe_browsing::ClientMalwareReportRequest::Resource* GetResource( |
| 88 const GURL& url); | 88 const GURL& url); |
| 89 | 89 |
| 90 // Creates a new URLFetcher and starts it. | 90 // Creates a new URLFetcher and starts it. |
| 91 void OpenEntry(); | 91 void OpenEntry(); |
| 92 | 92 |
| 93 // Read the HTTP response from |source| and add it to |pb_resource|. | 93 // Read the HTTP response from |source| and add it to |pb_resource|. |
| 94 void ReadResponse( | 94 void ReadResponse( |
| 95 safe_browsing::ClientMalwareReportRequest::Resource* pb_resource, | 95 safe_browsing::ClientMalwareReportRequest::Resource* pb_resource, |
| 96 const URLFetcher* source); | 96 const content::URLFetcher* source); |
| 97 | 97 |
| 98 // Read the body |data| and add it to |pb_resource|. | 98 // Read the body |data| and add it to |pb_resource|. |
| 99 void ReadData( | 99 void ReadData( |
| 100 safe_browsing::ClientMalwareReportRequest::Resource* pb_resource, | 100 safe_browsing::ClientMalwareReportRequest::Resource* pb_resource, |
| 101 const std::string& data); | 101 const std::string& data); |
| 102 | 102 |
| 103 // Called when we are done. | 103 // Called when we are done. |
| 104 void AllDone(bool success); | 104 void AllDone(bool success); |
| 105 | 105 |
| 106 // Advances to the next entry in resources_it_. | 106 // Advances to the next entry in resources_it_. |
| 107 void AdvanceEntry(); | 107 void AdvanceEntry(); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 #endif // CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_ | 110 #endif // CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_ |
| OLD | NEW |