summaryrefslogtreecommitdiff
path: root/chromium/chrome/common/prerender_util.h
blob: 4fa1436ccb642defbceaaca0b0d20584247014b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_COMMON_PRERENDER_UTIL_H_
#define CHROME_COMMON_PRERENDER_UTIL_H_

#include <string>

#include "chrome/common/prerender_types.h"

class GURL;

namespace prerender {
extern const char kFollowOnlyWhenPrerenderShown[];

// Returns true iff the scheme of the URL given is valid for prerendering.
bool DoesURLHaveValidScheme(const GURL& url);

// Returns true iff the scheme of the subresource URL given is valid for
// prerendering.
bool DoesSubresourceURLHaveValidScheme(const GURL& url);

// Returns true iff the method given is valid for prerendering.
bool IsValidHttpMethod(PrerenderMode prerender_mode, const std::string& method);

std::string ComposeHistogramName(const std::string& prefix_type,
                                 const std::string& name);

// Called when a NoStatePrefetch request has received a response (including
// redirects). May be called several times per resource, in case of redirects.
void RecordPrefetchResponseReceived(const std::string& histogram_prefix,
                                    bool is_main_resource,
                                    bool is_redirect,
                                    bool is_no_store);

// Called when a NoStatePrefetch resource has been loaded. This is called only
// once per resource, when all redirects have been resolved.
void RecordPrefetchRedirectCount(const std::string& histogram_prefix,
                                 bool is_main_resource,
                                 int redirect_count);

}  // namespace prerender

#endif  // CHROME_COMMON_PRERENDER_UTIL_H_