blob: 60910ccc26a9b88fc55a6559f7bbcd99ba1518a6 [file] [log] [blame]
// 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.
#include <memory>
#include "base/memory/ref_counted.h"
#include "base/optional.h"
#include "components/keyed_service/core/keyed_service.h"
#include "content/public/browser/client_hints_controller_delegate.h"
class GURL;
namespace content {
class BrowserContext;
namespace net {
class HttpRequestHeaders;
namespace client_hints {
namespace internal {
// Returns |rtt| after adding host-specific random noise, and rounding it as
// per the NetInfo spec to improve privacy.
unsigned long RoundRtt(const std::string& host,
const base::Optional<base::TimeDelta>& rtt);
// Returns downlink (in Mbps) after adding host-specific random noise to
// |downlink_kbps| (which is in Kbps), and rounding it as per the NetInfo spec
// to improve privacy.
double RoundKbpsToMbps(const std::string& host,
const base::Optional<int32_t>& downlink_kbps);
} // namespace internal
class ClientHints : public KeyedService,
public content::ClientHintsControllerDelegate {
explicit ClientHints(content::BrowserContext* context);
~ClientHints() override;
// content::ClientHintsControllerDelegate:
void GetAdditionalNavigationRequestClientHintsHeaders(
const GURL& url,
net::HttpRequestHeaders* additional_headers) override;
content::BrowserContext* context_;
} // namespace client_hints