OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/latency/latency_info.h" | 5 #include "ui/latency/latency_info.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 19 matching lines...) Expand all Loading... |
30 CASE_TYPE(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); | 30 CASE_TYPE(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); |
31 CASE_TYPE(INPUT_EVENT_LATENCY_UI_COMPONENT); | 31 CASE_TYPE(INPUT_EVENT_LATENCY_UI_COMPONENT); |
32 CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT); | 32 CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT); |
33 CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT); | 33 CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT); |
34 CASE_TYPE(INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT); | 34 CASE_TYPE(INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT); |
35 CASE_TYPE(INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT); | 35 CASE_TYPE(INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT); |
36 CASE_TYPE(BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT); | 36 CASE_TYPE(BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT); |
37 CASE_TYPE(TAB_SHOW_COMPONENT); | 37 CASE_TYPE(TAB_SHOW_COMPONENT); |
38 CASE_TYPE(INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT); | 38 CASE_TYPE(INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT); |
39 CASE_TYPE(INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT); | 39 CASE_TYPE(INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT); |
40 CASE_TYPE(INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT); | 40 CASE_TYPE(DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT); |
41 CASE_TYPE(INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT); | 41 CASE_TYPE(INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT); |
42 CASE_TYPE(INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL); | 42 CASE_TYPE(INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL); |
43 CASE_TYPE(INPUT_EVENT_LATENCY_TERMINATED_NO_SWAP_COMPONENT); | 43 CASE_TYPE(INPUT_EVENT_LATENCY_TERMINATED_NO_SWAP_COMPONENT); |
44 CASE_TYPE(INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT); | 44 CASE_TYPE(INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT); |
45 CASE_TYPE(INPUT_EVENT_LATENCY_TERMINATED_COMMIT_FAILED_COMPONENT); | 45 CASE_TYPE(INPUT_EVENT_LATENCY_TERMINATED_COMMIT_FAILED_COMPONENT); |
46 CASE_TYPE(INPUT_EVENT_LATENCY_TERMINATED_COMMIT_NO_UPDATE_COMPONENT); | 46 CASE_TYPE(INPUT_EVENT_LATENCY_TERMINATED_COMMIT_NO_UPDATE_COMPONENT); |
47 CASE_TYPE(INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT); | 47 CASE_TYPE(INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT); |
48 default: | 48 default: |
49 DLOG(WARNING) << "Unhandled LatencyComponentType.\n"; | 49 DLOG(WARNING) << "Unhandled LatencyComponentType.\n"; |
50 break; | 50 break; |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 LatencyComponent* output) const { | 348 LatencyComponent* output) const { |
349 LatencyMap::const_iterator it = latency_components_.find( | 349 LatencyMap::const_iterator it = latency_components_.find( |
350 std::make_pair(type, id)); | 350 std::make_pair(type, id)); |
351 if (it == latency_components_.end()) | 351 if (it == latency_components_.end()) |
352 return false; | 352 return false; |
353 if (output) | 353 if (output) |
354 *output = it->second; | 354 *output = it->second; |
355 return true; | 355 return true; |
356 } | 356 } |
357 | 357 |
| 358 bool LatencyInfo::FindLatency(LatencyComponentType type, |
| 359 LatencyComponent* output) const { |
| 360 LatencyMap::const_iterator it = latency_components_.begin(); |
| 361 while (it != latency_components_.end()) { |
| 362 if (it->first.first == type) { |
| 363 if (output) |
| 364 *output = it->second; |
| 365 return true; |
| 366 } |
| 367 it++; |
| 368 } |
| 369 return false; |
| 370 } |
| 371 |
358 void LatencyInfo::RemoveLatency(LatencyComponentType type) { | 372 void LatencyInfo::RemoveLatency(LatencyComponentType type) { |
359 LatencyMap::iterator it = latency_components_.begin(); | 373 LatencyMap::iterator it = latency_components_.begin(); |
360 while (it != latency_components_.end()) { | 374 while (it != latency_components_.end()) { |
361 if (it->first.first == type) | 375 if (it->first.first == type) |
362 it = latency_components_.erase(it); | 376 it = latency_components_.erase(it); |
363 else | 377 else |
364 it++; | 378 it++; |
365 } | 379 } |
366 } | 380 } |
367 | 381 |
368 bool LatencyInfo::AddInputCoordinate(const gfx::PointF& input_coordinate) { | 382 bool LatencyInfo::AddInputCoordinate(const gfx::PointF& input_coordinate) { |
369 if (input_coordinates_size_ >= kMaxInputCoordinates) | 383 if (input_coordinates_size_ >= kMaxInputCoordinates) |
370 return false; | 384 return false; |
371 input_coordinates_[input_coordinates_size_++] = input_coordinate; | 385 input_coordinates_[input_coordinates_size_++] = input_coordinate; |
372 return true; | 386 return true; |
373 } | 387 } |
374 | 388 |
375 } // namespace ui | 389 } // namespace ui |
OLD | NEW |