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

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

Issue 2800783002: predictors: Several improvements for redirects database. (Closed)
Patch Set: Don't keep a lot of redirect endpoints. Created 3 years, 8 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
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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 static bool IsHandledSubresource(net::URLRequest* request, 291 static bool IsHandledSubresource(net::URLRequest* request,
292 content::ResourceType resource_type); 292 content::ResourceType resource_type);
293 293
294 // Returns true if the subresource has a supported type. 294 // Returns true if the subresource has a supported type.
295 static bool IsHandledResourceType(content::ResourceType resource_type, 295 static bool IsHandledResourceType(content::ResourceType resource_type,
296 const std::string& mime_type); 296 const std::string& mime_type);
297 297
298 // Returns true if the request (should have a response in it) is "no-store". 298 // Returns true if the request (should have a response in it) is "no-store".
299 static bool IsNoStore(const net::URLRequest* request); 299 static bool IsNoStore(const net::URLRequest* request);
300 300
301 // Returns true iff |redirect_data_map| contains confident redirect endpoint
302 // for |entry_point| and assigns it to the |redirect_endpoint|.
303 static bool GetRedirectEndpoint(const std::string& entry_point,
304 const RedirectDataMap& redirect_data_map,
305 std::string* redirect_endpoint);
306
307 static void SetAllowPortInUrlsForTesting(bool state); 301 static void SetAllowPortInUrlsForTesting(bool state);
308 302
309 // KeyedService methods override. 303 // KeyedService methods override.
310 void Shutdown() override; 304 void Shutdown() override;
311 305
312 // Functions called on different network events pertaining to the loading of 306 // Functions called on different network events pertaining to the loading of
313 // main frame resource or sub resources. 307 // main frame resource or sub resources.
314 void OnMainFrameRequest(const URLRequestSummary& request); 308 void OnMainFrameRequest(const URLRequestSummary& request);
315 void OnMainFrameResponse(const URLRequestSummary& response); 309 void OnMainFrameResponse(const URLRequestSummary& response);
316 void OnMainFrameRedirect(const URLRequestSummary& response); 310 void OnMainFrameRedirect(const URLRequestSummary& response);
317 void OnSubresourceResponse(const URLRequestSummary& response); 311 void OnSubresourceResponse(const URLRequestSummary& response);
318 312
319 // Called when onload completes for a navigation. We treat this point as the 313 // Called when onload completes for a navigation. We treat this point as the
320 // "completion" of the navigation. The resources requested by the page up to 314 // "completion" of the navigation. The resources requested by the page up to
321 // this point are the only ones considered for prefetching. 315 // this point are the only ones considered for prefetching.
322 void OnNavigationComplete(const NavigationID& nav_id_without_timing_info); 316 void OnNavigationComplete(const NavigationID& nav_id_without_timing_info);
323 317
318 // Returns true iff one of the following conditions is true
319 // * |redirect_data_map| contains confident redirect endpoint for
320 // |entry_point| and assigns it to the |redirect_endpoint|
321 //
322 // * |redirect_data_map| doens't contain an entry for |entry_point| and
323 // assings |entry_point| to the |redirect_endpoint|.
324 bool GetRedirectEndpoint(const std::string& entry_point,
325 const RedirectDataMap& redirect_data_map,
326 std::string* redirect_endpoint) const;
327
324 // Returns true iff there is PrefetchData that can be used for a 328 // Returns true iff there is PrefetchData that can be used for a
325 // |main_frame_url| and fills |prediction| with resources that need to be 329 // |main_frame_url| and fills |prediction| with resources that need to be
326 // prefetched. |prediction| pointer may be equal nullptr to get return value 330 // prefetched. |prediction| pointer may be equal nullptr to get return value
327 // only. 331 // only.
328 bool GetPrefetchData(const GURL& main_frame_url, 332 bool GetPrefetchData(const GURL& main_frame_url,
329 Prediction* prediction) const; 333 Prediction* prediction) const;
330 334
331 // Returns true iff the |data_map| contains PrefetchData that can be used 335 // Returns true iff the |data_map| contains PrefetchData that can be used
332 // for a |main_frame_key| and fills |urls| with resources that need to be 336 // for a |main_frame_key| and fills |urls| with resources that need to be
333 // prefetched. |urls| pointer may be equal nullptr to get return value only. 337 // prefetched. |urls| pointer may be equal nullptr to get return value only.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 469
466 private: 470 private:
467 ResourcePrefetchPredictor* predictor_; 471 ResourcePrefetchPredictor* predictor_;
468 472
469 DISALLOW_COPY_AND_ASSIGN(TestObserver); 473 DISALLOW_COPY_AND_ASSIGN(TestObserver);
470 }; 474 };
471 475
472 } // namespace predictors 476 } // namespace predictors
473 477
474 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ 478 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698