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

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

Issue 2227723002: predictors: Also track "no-cache" and "must-revalidate" resources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // it to disk in the DB thread through the ResourcePrefetchPredictorTables. It 59 // it to disk in the DB thread through the ResourcePrefetchPredictorTables. It
60 // initiates resource prefetching using the ResourcePrefetcherManager. Owned 60 // initiates resource prefetching using the ResourcePrefetcherManager. Owned
61 // by profile. 61 // by profile.
62 // * ResourcePrefetcherManager - Manages the ResourcePrefetchers that do the 62 // * ResourcePrefetcherManager - Manages the ResourcePrefetchers that do the
63 // prefetching on the IO thread. The manager is owned by the 63 // prefetching on the IO thread. The manager is owned by the
64 // ResourcePrefetchPredictor and interfaces between the predictor on the UI 64 // ResourcePrefetchPredictor and interfaces between the predictor on the UI
65 // thread and the prefetchers on the IO thread. 65 // thread and the prefetchers on the IO thread.
66 // * ResourcePrefetcher - Lives entirely on the IO thread, owned by the 66 // * ResourcePrefetcher - Lives entirely on the IO thread, owned by the
67 // ResourcePrefetcherManager, and issues net::URLRequest to fetch resources. 67 // ResourcePrefetcherManager, and issues net::URLRequest to fetch resources.
68 // 68 //
69 // TODO(shishir): Do speculative prefetching for https resources and/or https
70 // main frame urls.
71 // TODO(zhenw): Currently only main frame requests/redirects/responses are 69 // TODO(zhenw): Currently only main frame requests/redirects/responses are
72 // recorded. Consider recording sub-frame responses independently or together 70 // recorded. Consider recording sub-frame responses independently or together
73 // with main frame. 71 // with main frame.
74 class ResourcePrefetchPredictor 72 class ResourcePrefetchPredictor
75 : public KeyedService, 73 : public KeyedService,
76 public history::HistoryServiceObserver, 74 public history::HistoryServiceObserver,
77 public base::SupportsWeakPtr<ResourcePrefetchPredictor> { 75 public base::SupportsWeakPtr<ResourcePrefetchPredictor> {
78 public: 76 public:
79 // Stores the data that we need to get from the URLRequest. 77 // Stores the data that we need to get from the URLRequest.
80 struct URLRequestSummary { 78 struct URLRequestSummary {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 static bool IsHandledMainPage(net::URLRequest* request); 178 static bool IsHandledMainPage(net::URLRequest* request);
181 179
182 // Returns true if the subresource request is supported for prediction. 180 // Returns true if the subresource request is supported for prediction.
183 static bool IsHandledSubresource(net::URLRequest* request, 181 static bool IsHandledSubresource(net::URLRequest* request,
184 content::ResourceType resource_type); 182 content::ResourceType resource_type);
185 183
186 // Returns true if the subresource has a supported type. 184 // Returns true if the subresource has a supported type.
187 static bool IsHandledResourceType(content::ResourceType resource_type, 185 static bool IsHandledResourceType(content::ResourceType resource_type,
188 const std::string& mime_type); 186 const std::string& mime_type);
189 187
190 // Returns true if the request (should have a response in it) is cacheable. 188 // Returns true if the request (should have a response in it) is "no-store".
191 static bool IsCacheable(const net::URLRequest* request); 189 static bool IsNoStore(const net::URLRequest* request);
192 190
193 // KeyedService methods override. 191 // KeyedService methods override.
194 void Shutdown() override; 192 void Shutdown() override;
195 193
196 // Functions called on different network events pertaining to the loading of 194 // Functions called on different network events pertaining to the loading of
197 // main frame resource or sub resources. 195 // main frame resource or sub resources.
198 void OnMainFrameRequest(const URLRequestSummary& request); 196 void OnMainFrameRequest(const URLRequestSummary& request);
199 void OnMainFrameResponse(const URLRequestSummary& response); 197 void OnMainFrameResponse(const URLRequestSummary& response);
200 void OnMainFrameRedirect(const URLRequestSummary& response); 198 void OnMainFrameRedirect(const URLRequestSummary& response);
201 void OnSubresourceResponse(const URLRequestSummary& response); 199 void OnSubresourceResponse(const URLRequestSummary& response);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 331
334 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> 332 ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
335 history_service_observer_; 333 history_service_observer_;
336 334
337 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); 335 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor);
338 }; 336 };
339 337
340 } // namespace predictors 338 } // namespace predictors
341 339
342 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ 340 #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