1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- // 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 COMPONENTS_PAGE_LOAD_METRICS_COMMON_PAGE_LOAD_METRICS_UTIL_H_
- #define COMPONENTS_PAGE_LOAD_METRICS_COMMON_PAGE_LOAD_METRICS_UTIL_H_
- #include <string>
- #include "base/time/time.h"
- #include "third_party/abseil-cpp/absl/types/optional.h"
- #include "url/gurl.h"
- namespace page_load_metrics {
- // Returns the minimum value of the optional TimeDeltas, if both values are
- // set. Otherwise, if one value is set, returns that value. Otherwise, returns
- // an unset value.
- absl::optional<base::TimeDelta> OptionalMin(
- const absl::optional<base::TimeDelta>& a,
- const absl::optional<base::TimeDelta>& b);
- // Whether the given url has a google hostname.
- bool IsGoogleHostname(const GURL& url);
- // If the given hostname is a google hostname, returns the portion of the
- // hostname before the google hostname. Otherwise, returns an unset optional
- // value.
- //
- // For example:
- // https://example.com/foo => returns an unset optional value
- // https://google.com/foo => returns ''
- // https://www.google.com/foo => returns 'www'
- // https://news.google.com/foo => returns 'news'
- // https://a.b.c.google.com/foo => returns 'a.b.c'
- absl::optional<std::string> GetGoogleHostnamePrefix(const GURL& url);
- // Distinguishes the renderer-side timer from the browser-side timer.
- enum class TimerType { kRenderer = 0, kBrowser = 1 };
- // Returns the maximum amount of time to delay dispatch of metrics updates
- // from the renderer process.
- int GetBufferTimerDelayMillis(TimerType timer_type);
- } // namespace page_load_metrics
- #endif // COMPONENTS_PAGE_LOAD_METRICS_COMMON_PAGE_LOAD_METRICS_UTIL_H_
|