| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } | 301 } |
| 302 // LatencyComponents generated in the renderer must have component IDs | 302 // LatencyComponents generated in the renderer must have component IDs |
| 303 // provided to them by the browser process. This function adds the correct | 303 // provided to them by the browser process. This function adds the correct |
| 304 // component ID where necessary. | 304 // component ID where necessary. |
| 305 void AddLatencyInfoComponentIds(LatencyInfo* latency, | 305 void AddLatencyInfoComponentIds(LatencyInfo* latency, |
| 306 int64_t latency_component_id) { | 306 int64_t latency_component_id) { |
| 307 std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key; | 307 std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key; |
| 308 std::vector<LatencyInfo::LatencyComponent> new_components_value; | 308 std::vector<LatencyInfo::LatencyComponent> new_components_value; |
| 309 for (const auto& lc : latency->latency_components()) { | 309 for (const auto& lc : latency->latency_components()) { |
| 310 ui::LatencyComponentType component_type = lc.first.first; | 310 ui::LatencyComponentType component_type = lc.first.first; |
| 311 if (component_type == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) { | 311 if (component_type == ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT) { |
| 312 // Generate a new component entry with the correct component ID | 312 // Generate a new component entry with the correct component ID |
| 313 new_components_key.push_back(std::make_pair(component_type, | 313 new_components_key.push_back(std::make_pair(component_type, |
| 314 latency_component_id)); | 314 latency_component_id)); |
| 315 new_components_value.push_back(lc.second); | 315 new_components_value.push_back(lc.second); |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 | 318 |
| 319 // Remove the entries with invalid component IDs. | 319 // Remove the entries with invalid component IDs. |
| 320 latency->RemoveLatency(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT); | 320 latency->RemoveLatency(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT); |
| 321 | 321 |
| 322 // Add newly generated components into the latency info | 322 // Add newly generated components into the latency info |
| 323 for (size_t i = 0; i < new_components_key.size(); i++) { | 323 for (size_t i = 0; i < new_components_key.size(); i++) { |
| 324 latency->AddLatencyNumberWithTimestamp( | 324 latency->AddLatencyNumberWithTimestamp( |
| 325 new_components_key[i].first, | 325 new_components_key[i].first, |
| 326 new_components_key[i].second, | 326 new_components_key[i].second, |
| 327 new_components_value[i].sequence_number, | 327 new_components_value[i].sequence_number, |
| 328 new_components_value[i].event_time, | 328 new_components_value[i].event_time, |
| 329 new_components_value[i].event_count); | 329 new_components_value[i].event_count); |
| 330 } | 330 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 void RenderWidgetHostLatencyTracker::OnSwapCompositorFrame( | 528 void RenderWidgetHostLatencyTracker::OnSwapCompositorFrame( |
| 529 std::vector<LatencyInfo>* latencies) { | 529 std::vector<LatencyInfo>* latencies) { |
| 530 DCHECK(latencies); | 530 DCHECK(latencies); |
| 531 for (LatencyInfo& latency : *latencies) { | 531 for (LatencyInfo& latency : *latencies) { |
| 532 AddLatencyInfoComponentIds(&latency, latency_component_id_); | 532 AddLatencyInfoComponentIds(&latency, latency_component_id_); |
| 533 latency.AddLatencyNumber( | 533 latency.AddLatencyNumber( |
| 534 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); | 534 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); |
| 535 } | 535 } |
| 536 } | 536 } |
| 537 | 537 |
| 538 void RenderWidgetHostLatencyTracker::OnFrameSwapped( | 538 void RenderWidgetHostLatencyTracker::OnGpuSwapBufersCompleted( |
| 539 const LatencyInfo& latency) { | 539 const LatencyInfo& latency) { |
| 540 LatencyInfo::LatencyComponent gpu_swap_end_component; | 540 LatencyInfo::LatencyComponent gpu_swap_end_component; |
| 541 if (!latency.FindLatency( | 541 if (!latency.FindLatency( |
| 542 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, | 542 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, |
| 543 &gpu_swap_end_component)) { | 543 &gpu_swap_end_component)) { |
| 544 return; | 544 return; |
| 545 } | 545 } |
| 546 | 546 |
| 547 LatencyInfo::LatencyComponent gpu_swap_begin_component; | 547 LatencyInfo::LatencyComponent gpu_swap_begin_component; |
| 548 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, | 548 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 latency_component_id_, latency); | 585 latency_component_id_, latency); |
| 586 } | 586 } |
| 587 } | 587 } |
| 588 | 588 |
| 589 void RenderWidgetHostLatencyTracker::SetDelegate( | 589 void RenderWidgetHostLatencyTracker::SetDelegate( |
| 590 RenderWidgetHostDelegate* delegate) { | 590 RenderWidgetHostDelegate* delegate) { |
| 591 render_widget_host_delegate_ = delegate; | 591 render_widget_host_delegate_ = delegate; |
| 592 } | 592 } |
| 593 | 593 |
| 594 } // namespace content | 594 } // namespace content |
| OLD | NEW |