OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/renderer_host/input/render_widget_host_latency_tracker
.h" | 5 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker
.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram_functions.h" | 10 #include "base/metrics/histogram_functions.h" |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 274 |
275 ComputeInputLatencyHistograms(event.GetType(), latency_component_id_, | 275 ComputeInputLatencyHistograms(event.GetType(), latency_component_id_, |
276 *latency, ack_result); | 276 *latency, ack_result); |
277 } | 277 } |
278 | 278 |
279 void RenderWidgetHostLatencyTracker::OnSwapCompositorFrame( | 279 void RenderWidgetHostLatencyTracker::OnSwapCompositorFrame( |
280 std::vector<LatencyInfo>* latencies) { | 280 std::vector<LatencyInfo>* latencies) { |
281 DCHECK(latencies); | 281 DCHECK(latencies); |
282 for (LatencyInfo& latency : *latencies) { | 282 for (LatencyInfo& latency : *latencies) { |
283 AddLatencyInfoComponentIds(&latency, latency_component_id_); | 283 AddLatencyInfoComponentIds(&latency, latency_component_id_); |
284 latency.AddLatencyNumber(ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, 0, | |
285 0); | |
286 } | 284 } |
287 } | 285 } |
288 | 286 |
289 void RenderWidgetHostLatencyTracker::SetDelegate( | 287 void RenderWidgetHostLatencyTracker::SetDelegate( |
290 RenderWidgetHostDelegate* delegate) { | 288 RenderWidgetHostDelegate* delegate) { |
291 render_widget_host_delegate_ = delegate; | 289 render_widget_host_delegate_ = delegate; |
292 } | 290 } |
293 | 291 |
294 void RenderWidgetHostLatencyTracker::ReportRapporScrollLatency( | 292 void RenderWidgetHostLatencyTracker::ReportRapporScrollLatency( |
295 const std::string& name, | 293 const std::string& name, |
296 const LatencyInfo::LatencyComponent& start_component, | 294 const LatencyInfo::LatencyComponent& start_component, |
297 const LatencyInfo::LatencyComponent& end_component) { | 295 const LatencyInfo::LatencyComponent& end_component) { |
298 CONFIRM_VALID_TIMING(start_component, end_component) | 296 CONFIRM_VALID_TIMING(start_component, end_component) |
299 rappor::RapporService* rappor_service = | 297 rappor::RapporService* rappor_service = |
300 GetContentClient()->browser()->GetRapporService(); | 298 GetContentClient()->browser()->GetRapporService(); |
301 if (rappor_service && render_widget_host_delegate_) { | 299 if (rappor_service && render_widget_host_delegate_) { |
302 std::unique_ptr<rappor::Sample> sample = | 300 std::unique_ptr<rappor::Sample> sample = |
303 rappor_service->CreateSample(rappor::UMA_RAPPOR_TYPE); | 301 rappor_service->CreateSample(rappor::UMA_RAPPOR_TYPE); |
304 render_widget_host_delegate_->AddDomainInfoToRapporSample(sample.get()); | 302 render_widget_host_delegate_->AddDomainInfoToRapporSample(sample.get()); |
305 sample->SetUInt64Field( | 303 sample->SetUInt64Field( |
306 "Latency", | 304 "Latency", |
307 (end_component.last_event_time - start_component.first_event_time) | 305 (end_component.last_event_time - start_component.first_event_time) |
308 .InMicroseconds(), | 306 .InMicroseconds(), |
309 rappor::NO_NOISE); | 307 rappor::NO_NOISE); |
310 rappor_service->RecordSample(name, std::move(sample)); | 308 rappor_service->RecordSample(name, std::move(sample)); |
311 } | 309 } |
312 } | 310 } |
313 | 311 |
314 } // namespace content | 312 } // namespace content |
OLD | NEW |