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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_UTIL_H_
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_UTIL_H_
8 #include "base/basictypes.h"
10 #include "webkit/common/resource_type.h"
13 class HttpResponseHeaders;
19 // ID indicating that no experiment is active.
20 const uint8 kNoExperiment = 0;
22 // Extracts a urlencoded URL stored in a url= query parameter from a URL
23 // supplied, if available, and stores it in alias_url. Returns whether or not
24 // the operation succeeded (i.e. a valid URL was found).
25 bool MaybeGetQueryStringBasedAliasURL(const GURL& url, GURL* alias_url);
27 // Extracts an experiment stored in the query parameter
28 // lpe= from the URL supplied, and returns it.
29 // Returns kNoExperiment if no experiment ID is found, or if the ID
30 // is not an integer in the range 1 to 9.
31 uint8 GetQueryStringBasedExperiment(const GURL& url);
33 // Indicates whether the URL provided has a Google domain
34 bool IsGoogleDomain(const GURL& url);
36 // Indicates whether the URL provided could be a Google search result page.
37 bool IsGoogleSearchResultURL(const GURL& url);
39 // The prerender contents of some experiments should never be swapped in
40 // by pretending to never match on the URL. This function will return true
41 // iff this is the case for the experiment_id specified.
42 bool IsNoSwapInExperiment(uint8 experiment_id);
44 // The prerender contents of some experiments should behave identical to the
45 // control group, regardless of the field trial. This function will return true
46 // iff this is the case for the experiment_id specified.
47 bool IsControlGroupExperiment(uint8 experiment_id);
49 // Called by URLRequestResponseStarted to gather data about Pagespeed headers
50 // into the Prerender.PagespeedHeader histogram. Public so it can be accessed
52 void GatherPagespeedData(const ResourceType::Type resource_type,
53 const GURL& request_url,
54 const net::HttpResponseHeaders* response_headers);
56 // Static method gathering stats about a URLRequest for which a response has
58 void URLRequestResponseStarted(net::URLRequest* request);
60 } // namespace prerender
62 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_UTIL_H_