blob: 35a992625fb3138c6132edfcab1d043b48baa861 [file] [log] [blame]
Tarun Bansal6bf54302017-10-02 07:39:141// Copyright 2017 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.
4
5#ifndef CHROME_BROWSER_CLIENT_HINTS_CLIENT_HINTS_H_
6#define CHROME_BROWSER_CLIENT_HINTS_CLIENT_HINTS_H_
7
8#include <memory>
9
Tarun Bansala61f0f62017-10-24 23:53:0510#include "base/memory/ref_counted.h"
Tarun Bansal509a8dd2018-04-10 17:19:1611#include "base/optional.h"
Tarun Bansala61f0f62017-10-24 23:53:0512
Tarun Bansal6bf54302017-10-02 07:39:1413class GURL;
14
15namespace content {
16class BrowserContext;
17}
18
Tarun Bansala61f0f62017-10-24 23:53:0519namespace content_settings {
20class CookieSettings;
21}
22
Tarun Bansal6bf54302017-10-02 07:39:1423namespace net {
24class HttpRequestHeaders;
Tarun Bansala61f0f62017-10-24 23:53:0525class URLRequest;
Tarun Bansal6bf54302017-10-02 07:39:1426}
27
28namespace client_hints {
29
Tarun Bansal509a8dd2018-04-10 17:19:1630namespace internal {
31
32// Returns |rtt| after adding host-specific random noise, and rounding it as
33// per the NetInfo spec to improve privacy.
34unsigned long RoundRtt(const std::string& host,
35 const base::Optional<base::TimeDelta>& rtt);
36
37// Returns |downlink_mbps| after adding host-specific random noise, and
38// rounding it as per the NetInfo spec and to improve privacy.
39double RoundMbps(const std::string& host,
40 const base::Optional<double>& downlink_mbps);
41
42} // namespace internal
43
Tarun Bansal6bf54302017-10-02 07:39:1444// Allow the embedder to return additional headers related to client hints that
45// should be sent when fetching |url|. May return a nullptr.
46std::unique_ptr<net::HttpRequestHeaders>
47GetAdditionalNavigationRequestClientHintsHeaders(
48 content::BrowserContext* context,
49 const GURL& url);
50
Tarun Bansala61f0f62017-10-24 23:53:0551// Called before |request| goes on the network.
52void RequestBeginning(
53 net::URLRequest* request,
54 scoped_refptr<content_settings::CookieSettings> cookie_settings);
55
Tarun Bansal6bf54302017-10-02 07:39:1456} // namespace client_hints
57
58#endif // CHROME_BROWSER_CLIENT_HINTS_CLIENT_HINTS_H_