OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/page_load_metrics/observers/data_reduction_proxy_metric
s_observer.h" | 5 #include "chrome/browser/page_load_metrics/observers/data_reduction_proxy_metric
s_observer.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
| 9 #include "base/optional.h" |
9 #include "base/time/time.h" | 10 #include "base/time/time.h" |
10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" | 12 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" |
12 #include "chrome/browser/renderer_host/chrome_navigation_data.h" | 13 #include "chrome/browser/renderer_host/chrome_navigation_data.h" |
13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data
.h" | 14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data
.h" |
14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_ping
back_client.h" | 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_ping
back_client.h" |
15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" | 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" |
16 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_page_
load_timing.h" | 17 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_page_
load_timing.h" |
17 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 18 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
18 #include "components/page_load_metrics/browser/page_load_metrics_observer.h" | 19 #include "components/page_load_metrics/browser/page_load_metrics_observer.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 if (!browser_context_) | 120 if (!browser_context_) |
120 return; | 121 return; |
121 if (!data_ || !data_->used_data_reduction_proxy()) | 122 if (!data_ || !data_->used_data_reduction_proxy()) |
122 return; | 123 return; |
123 if (data_reduction_proxy::params::IsIncludedInHoldbackFieldTrial() || | 124 if (data_reduction_proxy::params::IsIncludedInHoldbackFieldTrial() || |
124 data_reduction_proxy::params::IsIncludedInTamperDetectionExperiment()) { | 125 data_reduction_proxy::params::IsIncludedInTamperDetectionExperiment()) { |
125 return; | 126 return; |
126 } | 127 } |
127 // Only consider timing events that happened before the first background | 128 // Only consider timing events that happened before the first background |
128 // event. | 129 // event. |
129 base::TimeDelta response_start; | 130 base::Optional<base::TimeDelta> response_start; |
130 base::TimeDelta load_event_start; | 131 base::Optional<base::TimeDelta> load_event_start; |
131 base::TimeDelta first_image_paint; | 132 base::Optional<base::TimeDelta> first_image_paint; |
132 base::TimeDelta first_contentful_paint; | 133 base::Optional<base::TimeDelta> first_contentful_paint; |
133 if (WasStartedInForegroundOptionalEventInForeground(timing.response_start, | 134 if (WasStartedInForegroundOptionalEventInForeground(timing.response_start, |
134 info)) { | 135 info)) { |
135 response_start = timing.response_start.value(); | 136 response_start = timing.response_start; |
136 } | 137 } |
137 if (WasStartedInForegroundOptionalEventInForeground(timing.load_event_start, | 138 if (WasStartedInForegroundOptionalEventInForeground(timing.load_event_start, |
138 info)) { | 139 info)) { |
139 load_event_start = timing.load_event_start.value(); | 140 load_event_start = timing.load_event_start; |
140 } | 141 } |
141 if (WasStartedInForegroundOptionalEventInForeground(timing.first_image_paint, | 142 if (WasStartedInForegroundOptionalEventInForeground(timing.first_image_paint, |
142 info)) { | 143 info)) { |
143 first_image_paint = timing.first_image_paint.value(); | 144 first_image_paint = timing.first_image_paint; |
144 } | 145 } |
145 if (WasStartedInForegroundOptionalEventInForeground( | 146 if (WasStartedInForegroundOptionalEventInForeground( |
146 timing.first_contentful_paint, info)) { | 147 timing.first_contentful_paint, info)) { |
147 first_contentful_paint = timing.first_contentful_paint.value(); | 148 first_contentful_paint = timing.first_contentful_paint; |
148 } | 149 } |
149 // TODO(ryansturm): Change DataReductionProxyPageLoadTiming to take | |
150 // base::Optional<>s (see crbug.com/626040). | |
151 DataReductionProxyPageLoadTiming data_reduction_proxy_timing( | 150 DataReductionProxyPageLoadTiming data_reduction_proxy_timing( |
152 timing.navigation_start, response_start, load_event_start, | 151 timing.navigation_start, response_start, load_event_start, |
153 first_image_paint, first_contentful_paint); | 152 first_image_paint, first_contentful_paint); |
154 GetPingbackClient()->SendPingback(*data_, data_reduction_proxy_timing); | 153 GetPingbackClient()->SendPingback(*data_, data_reduction_proxy_timing); |
155 } | 154 } |
156 | 155 |
157 void DataReductionProxyMetricsObserver::OnDomContentLoadedEventStart( | 156 void DataReductionProxyMetricsObserver::OnDomContentLoadedEventStart( |
158 const page_load_metrics::PageLoadTiming& timing, | 157 const page_load_metrics::PageLoadTiming& timing, |
159 const page_load_metrics::PageLoadExtraInfo& info) { | 158 const page_load_metrics::PageLoadExtraInfo& info) { |
160 RECORD_HISTOGRAMS_FOR_SUFFIX( | 159 RECORD_HISTOGRAMS_FOR_SUFFIX( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 212 |
214 DataReductionProxyPingbackClient* | 213 DataReductionProxyPingbackClient* |
215 DataReductionProxyMetricsObserver::GetPingbackClient() const { | 214 DataReductionProxyMetricsObserver::GetPingbackClient() const { |
216 return DataReductionProxyChromeSettingsFactory::GetForBrowserContext( | 215 return DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
217 browser_context_) | 216 browser_context_) |
218 ->data_reduction_proxy_service() | 217 ->data_reduction_proxy_service() |
219 ->pingback_client(); | 218 ->pingback_client(); |
220 } | 219 } |
221 | 220 |
222 } // namespace data_reduction_proxy | 221 } // namespace data_reduction_proxy |
OLD | NEW |