Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1107)

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor.h

Issue 2260573002: predictors: Track whether resources have validators, and require validation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make Visual Studio happy. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/predictors/resource_prefetch_predictor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 NavigationID navigation_id; 83 NavigationID navigation_id;
84 GURL resource_url; 84 GURL resource_url;
85 content::ResourceType resource_type; 85 content::ResourceType resource_type;
86 net::RequestPriority priority; 86 net::RequestPriority priority;
87 87
88 // Only for responses. 88 // Only for responses.
89 std::string mime_type; 89 std::string mime_type;
90 bool was_cached; 90 bool was_cached;
91 GURL redirect_url; // Empty unless request was redirected to a valid url. 91 GURL redirect_url; // Empty unless request was redirected to a valid url.
92 92
93 bool has_validators;
94 bool always_revalidate;
95
93 // Initializes a |URLRequestSummary| from a |URLRequest| response. 96 // Initializes a |URLRequestSummary| from a |URLRequest| response.
94 // Returns true for success. 97 // Returns true for success.
95 static bool SummarizeResponse(const net::URLRequest& request, 98 static bool SummarizeResponse(const net::URLRequest& request,
96 URLRequestSummary* summary); 99 URLRequestSummary* summary);
97 }; 100 };
98 101
99 ResourcePrefetchPredictor(const ResourcePrefetchPredictorConfig& config, 102 ResourcePrefetchPredictor(const ResourcePrefetchPredictorConfig& config,
100 Profile* profile); 103 Profile* profile);
101 ~ResourcePrefetchPredictor() override; 104 ~ResourcePrefetchPredictor() override;
102 105
103 // Thread safe. 106 // Thread safe.
104 static bool ShouldRecordRequest(net::URLRequest* request, 107 static bool ShouldRecordRequest(net::URLRequest* request,
105 content::ResourceType resource_type); 108 content::ResourceType resource_type);
106 static bool ShouldRecordResponse(net::URLRequest* response); 109 static bool ShouldRecordResponse(net::URLRequest* response);
107 static bool ShouldRecordRedirect(net::URLRequest* response); 110 static bool ShouldRecordRedirect(net::URLRequest* response);
108 111
112 // Determines the resource type from the declared one, falling back to MIME
113 // type detection when it is not explicit.
114 static content::ResourceType GetResourceType(
115 content::ResourceType resource_type,
116 const std::string& mime_type);
117
109 // Determines the ResourceType from the mime type, defaulting to the 118 // Determines the ResourceType from the mime type, defaulting to the
110 // |fallback| if the ResourceType could not be determined. 119 // |fallback| if the ResourceType could not be determined.
111 static content::ResourceType GetResourceTypeFromMimeType( 120 static content::ResourceType GetResourceTypeFromMimeType(
112 const std::string& mime_type, 121 const std::string& mime_type,
113 content::ResourceType fallback); 122 content::ResourceType fallback);
114 123
115 // 'ResourcePrefetchPredictorObserver' calls the below functions to inform the 124 // 'ResourcePrefetchPredictorObserver' calls the below functions to inform the
116 // predictor of main frame and resource requests. Should only be called if the 125 // predictor of main frame and resource requests. Should only be called if the
117 // corresponding Should* functions return true. 126 // corresponding Should* functions return true.
118 void RecordURLRequest(const URLRequestSummary& request); 127 void RecordURLRequest(const URLRequestSummary& request);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 345
337 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> 346 ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
338 history_service_observer_; 347 history_service_observer_;
339 348
340 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); 349 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor);
341 }; 350 };
342 351
343 } // namespace predictors 352 } // namespace predictors
344 353
345 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ 354 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/predictors/resource_prefetch_predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698