Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.cc |
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.cc |
index ece37b2f7babf4b55a5d08754cfd369b2ee51216..00cca9f3bbd6524dc214107acc00b772a5405eb4 100644 |
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.cc |
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.cc |
@@ -1,17 +1,18 @@ |
// 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 "components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.h" |
#include "base/metrics/histogram.h" |
+#include "base/optional.h" |
#include "base/rand_util.h" |
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.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/data_reduction_proxy/core/common/data_reduction_proxy_util.h" |
#include "components/data_reduction_proxy/proto/client_config.pb.h" |
#include "components/data_reduction_proxy/proto/pageload_metrics.pb.h" |
#include "net/base/load_flags.h" |
#include "net/url_request/url_fetcher.h" |
#include "net/url_request/url_request_context_getter.h" |
@@ -34,39 +35,42 @@ std::string SerializeData(const DataReductionProxyData& request_data, |
RecordPageloadMetricsRequest batched_request; |
PageloadMetrics* request = batched_request.add_pageloads(); |
request->set_session_key(request_data.session_key()); |
// For the timing events, any of them could be zero. Fill the message as a |
// best effort. |
request->set_allocated_first_request_time( |
protobuf_parser::CreateTimestampFromTime(timing.navigation_start) |
.release()); |
if (request_data.original_request_url().is_valid()) |
request->set_first_request_url(request_data.original_request_url().spec()); |
- if (!timing.first_contentful_paint.is_zero()) { |
+ if (timing.first_contentful_paint) { |
request->set_allocated_time_to_first_contentful_paint( |
protobuf_parser::CreateDurationFromTimeDelta( |
- timing.first_contentful_paint) |
+ timing.first_contentful_paint.value()) |
.release()); |
} |
- if (!timing.first_image_paint.is_zero()) { |
+ if (timing.first_image_paint) { |
request->set_allocated_time_to_first_image_paint( |
- protobuf_parser::CreateDurationFromTimeDelta(timing.first_image_paint) |
+ protobuf_parser::CreateDurationFromTimeDelta( |
+ timing.first_image_paint.value()) |
.release()); |
} |
- if (!timing.response_start.is_zero()) { |
+ if (timing.response_start) { |
request->set_allocated_time_to_first_byte( |
- protobuf_parser::CreateDurationFromTimeDelta(timing.response_start) |
+ protobuf_parser::CreateDurationFromTimeDelta( |
+ timing.response_start.value()) |
.release()); |
} |
- if (!timing.load_event_start.is_zero()) { |
+ if (timing.load_event_start) { |
request->set_allocated_page_load_time( |
- protobuf_parser::CreateDurationFromTimeDelta(timing.load_event_start) |
+ protobuf_parser::CreateDurationFromTimeDelta( |
+ timing.load_event_start.value()) |
.release()); |
} |
std::string serialized_request; |
batched_request.SerializeToString(&serialized_request); |
return serialized_request; |
} |
} // namespace |
DataReductionProxyPingbackClient::DataReductionProxyPingbackClient( |