| Index: chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer.cc
|
| diff --git a/chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer.cc
|
| index 56cbe9bc3aacbc37533ef46ebc75171ea1ef103e..e5f88cd3f634ff075c77a6dc50601efe6244c70d 100644
|
| --- a/chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer.cc
|
| +++ b/chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer.cc
|
| @@ -1,18 +1,19 @@
|
| // Copyright 2016 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 "chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer.h"
|
|
|
| #include <string>
|
|
|
| +#include "base/optional.h"
|
| #include "base/time/time.h"
|
| #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
|
| #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_factory.h"
|
| #include "chrome/browser/renderer_host/chrome_navigation_data.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_page_load_timing.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
|
| #include "components/page_load_metrics/browser/page_load_metrics_observer.h"
|
| @@ -119,42 +120,40 @@ void DataReductionProxyMetricsObserver::OnComplete(
|
| if (!browser_context_)
|
| return;
|
| if (!data_ || !data_->used_data_reduction_proxy())
|
| return;
|
| if (data_reduction_proxy::params::IsIncludedInHoldbackFieldTrial() ||
|
| data_reduction_proxy::params::IsIncludedInTamperDetectionExperiment()) {
|
| return;
|
| }
|
| // Only consider timing events that happened before the first background
|
| // event.
|
| - base::TimeDelta response_start;
|
| - base::TimeDelta load_event_start;
|
| - base::TimeDelta first_image_paint;
|
| - base::TimeDelta first_contentful_paint;
|
| + base::Optional<base::TimeDelta> response_start;
|
| + base::Optional<base::TimeDelta> load_event_start;
|
| + base::Optional<base::TimeDelta> first_image_paint;
|
| + base::Optional<base::TimeDelta> first_contentful_paint;
|
| if (WasStartedInForegroundOptionalEventInForeground(timing.response_start,
|
| info)) {
|
| - response_start = timing.response_start.value();
|
| + response_start = timing.response_start;
|
| }
|
| if (WasStartedInForegroundOptionalEventInForeground(timing.load_event_start,
|
| info)) {
|
| - load_event_start = timing.load_event_start.value();
|
| + load_event_start = timing.load_event_start;
|
| }
|
| if (WasStartedInForegroundOptionalEventInForeground(timing.first_image_paint,
|
| info)) {
|
| - first_image_paint = timing.first_image_paint.value();
|
| + first_image_paint = timing.first_image_paint;
|
| }
|
| if (WasStartedInForegroundOptionalEventInForeground(
|
| timing.first_contentful_paint, info)) {
|
| - first_contentful_paint = timing.first_contentful_paint.value();
|
| + first_contentful_paint = timing.first_contentful_paint;
|
| }
|
| - // TODO(ryansturm): Change DataReductionProxyPageLoadTiming to take
|
| - // base::Optional<>s (see crbug.com/626040).
|
| DataReductionProxyPageLoadTiming data_reduction_proxy_timing(
|
| timing.navigation_start, response_start, load_event_start,
|
| first_image_paint, first_contentful_paint);
|
| GetPingbackClient()->SendPingback(*data_, data_reduction_proxy_timing);
|
| }
|
|
|
| void DataReductionProxyMetricsObserver::OnDomContentLoadedEventStart(
|
| const page_load_metrics::PageLoadTiming& timing,
|
| const page_load_metrics::PageLoadExtraInfo& info) {
|
| RECORD_HISTOGRAMS_FOR_SUFFIX(
|
|
|