| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 5 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| 6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 content::ResourceType resource_type; | 88 content::ResourceType resource_type; |
| 89 | 89 |
| 90 // Only for responses. | 90 // Only for responses. |
| 91 std::string mime_type; | 91 std::string mime_type; |
| 92 bool was_cached; | 92 bool was_cached; |
| 93 GURL redirect_url; // Empty unless request was redirected to a valid url. | 93 GURL redirect_url; // Empty unless request was redirected to a valid url. |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 ResourcePrefetchPredictor(const ResourcePrefetchPredictorConfig& config, | 96 ResourcePrefetchPredictor(const ResourcePrefetchPredictorConfig& config, |
| 97 Profile* profile); | 97 Profile* profile); |
| 98 virtual ~ResourcePrefetchPredictor(); | 98 ~ResourcePrefetchPredictor() override; |
| 99 | 99 |
| 100 // Thread safe. | 100 // Thread safe. |
| 101 static bool ShouldRecordRequest(net::URLRequest* request, | 101 static bool ShouldRecordRequest(net::URLRequest* request, |
| 102 content::ResourceType resource_type); | 102 content::ResourceType resource_type); |
| 103 static bool ShouldRecordResponse(net::URLRequest* response); | 103 static bool ShouldRecordResponse(net::URLRequest* response); |
| 104 static bool ShouldRecordRedirect(net::URLRequest* response); | 104 static bool ShouldRecordRedirect(net::URLRequest* response); |
| 105 | 105 |
| 106 // Determines the ResourceType from the mime type, defaulting to the | 106 // Determines the ResourceType from the mime type, defaulting to the |
| 107 // |fallback| if the ResourceType could not be determined. | 107 // |fallback| if the ResourceType could not be determined. |
| 108 static content::ResourceType GetResourceTypeFromMimeType( | 108 static content::ResourceType GetResourceTypeFromMimeType( |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // Returns true if the main page request is supported for prediction. | 177 // Returns true if the main page request is supported for prediction. |
| 178 static bool IsHandledMainPage(net::URLRequest* request); | 178 static bool IsHandledMainPage(net::URLRequest* request); |
| 179 | 179 |
| 180 // Returns true if the subresource request is supported for prediction. | 180 // Returns true if the subresource request is supported for prediction. |
| 181 static bool IsHandledSubresource(net::URLRequest* request); | 181 static bool IsHandledSubresource(net::URLRequest* request); |
| 182 | 182 |
| 183 // Returns true if the request (should have a response in it) is cacheable. | 183 // Returns true if the request (should have a response in it) is cacheable. |
| 184 static bool IsCacheable(const net::URLRequest* request); | 184 static bool IsCacheable(const net::URLRequest* request); |
| 185 | 185 |
| 186 // content::NotificationObserver methods override. | 186 // content::NotificationObserver methods override. |
| 187 virtual void Observe(int type, | 187 void Observe(int type, |
| 188 const content::NotificationSource& source, | 188 const content::NotificationSource& source, |
| 189 const content::NotificationDetails& details) override; | 189 const content::NotificationDetails& details) override; |
| 190 | 190 |
| 191 // KeyedService methods override. | 191 // KeyedService methods override. |
| 192 virtual void Shutdown() override; | 192 void Shutdown() override; |
| 193 | 193 |
| 194 // Functions called on different network events pertaining to the loading of | 194 // Functions called on different network events pertaining to the loading of |
| 195 // main frame resource or sub resources. | 195 // main frame resource or sub resources. |
| 196 void OnMainFrameRequest(const URLRequestSummary& request); | 196 void OnMainFrameRequest(const URLRequestSummary& request); |
| 197 void OnMainFrameResponse(const URLRequestSummary& response); | 197 void OnMainFrameResponse(const URLRequestSummary& response); |
| 198 void OnMainFrameRedirect(const URLRequestSummary& response); | 198 void OnMainFrameRedirect(const URLRequestSummary& response); |
| 199 void OnSubresourceResponse(const URLRequestSummary& response); | 199 void OnSubresourceResponse(const URLRequestSummary& response); |
| 200 | 200 |
| 201 // Called when onload completes for a navigation. We treat this point as the | 201 // Called when onload completes for a navigation. We treat this point as the |
| 202 // "completion" of the navigation. The resources requested by the page upto | 202 // "completion" of the navigation. The resources requested by the page upto |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 | 305 |
| 306 ResultsMap results_map_; | 306 ResultsMap results_map_; |
| 307 STLValueDeleter<ResultsMap> results_map_deleter_; | 307 STLValueDeleter<ResultsMap> results_map_deleter_; |
| 308 | 308 |
| 309 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); | 309 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); |
| 310 }; | 310 }; |
| 311 | 311 |
| 312 } // namespace predictors | 312 } // namespace predictors |
| 313 | 313 |
| 314 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 314 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| OLD | NEW |