Tarun Bansal | 6bf5430 | 2017-10-02 07:39:14 | [diff] [blame] | 1 | // 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 Bansal | a61f0f6 | 2017-10-24 23:53:05 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
Tarun Bansal | 509a8dd | 2018-04-10 17:19:16 | [diff] [blame^] | 11 | #include "base/optional.h" |
Tarun Bansal | a61f0f6 | 2017-10-24 23:53:05 | [diff] [blame] | 12 | |
Tarun Bansal | 6bf5430 | 2017-10-02 07:39:14 | [diff] [blame] | 13 | class GURL; |
| 14 | |
| 15 | namespace content { |
| 16 | class BrowserContext; |
| 17 | } |
| 18 | |
Tarun Bansal | a61f0f6 | 2017-10-24 23:53:05 | [diff] [blame] | 19 | namespace content_settings { |
| 20 | class CookieSettings; |
| 21 | } |
| 22 | |
Tarun Bansal | 6bf5430 | 2017-10-02 07:39:14 | [diff] [blame] | 23 | namespace net { |
| 24 | class HttpRequestHeaders; |
Tarun Bansal | a61f0f6 | 2017-10-24 23:53:05 | [diff] [blame] | 25 | class URLRequest; |
Tarun Bansal | 6bf5430 | 2017-10-02 07:39:14 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | namespace client_hints { |
| 29 | |
Tarun Bansal | 509a8dd | 2018-04-10 17:19:16 | [diff] [blame^] | 30 | namespace internal { |
| 31 | |
| 32 | // Returns |rtt| after adding host-specific random noise, and rounding it as |
| 33 | // per the NetInfo spec to improve privacy. |
| 34 | unsigned 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. |
| 39 | double RoundMbps(const std::string& host, |
| 40 | const base::Optional<double>& downlink_mbps); |
| 41 | |
| 42 | } // namespace internal |
| 43 | |
Tarun Bansal | 6bf5430 | 2017-10-02 07:39:14 | [diff] [blame] | 44 | // Allow the embedder to return additional headers related to client hints that |
| 45 | // should be sent when fetching |url|. May return a nullptr. |
| 46 | std::unique_ptr<net::HttpRequestHeaders> |
| 47 | GetAdditionalNavigationRequestClientHintsHeaders( |
| 48 | content::BrowserContext* context, |
| 49 | const GURL& url); |
| 50 | |
Tarun Bansal | a61f0f6 | 2017-10-24 23:53:05 | [diff] [blame] | 51 | // Called before |request| goes on the network. |
| 52 | void RequestBeginning( |
| 53 | net::URLRequest* request, |
| 54 | scoped_refptr<content_settings::CookieSettings> cookie_settings); |
| 55 | |
Tarun Bansal | 6bf5430 | 2017-10-02 07:39:14 | [diff] [blame] | 56 | } // namespace client_hints |
| 57 | |
| 58 | #endif // CHROME_BROWSER_CLIENT_HINTS_CLIENT_HINTS_H_ |