| 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/base/latency_info.h" | 5 #include "ui/base/latency_info.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 namespace ui { | 9 namespace ui { |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 if (event_count > 0 && new_count != 0) { | 51 if (event_count > 0 && new_count != 0) { |
| 52 // Do a weighted average, so that the new event_time is the average of | 52 // Do a weighted average, so that the new event_time is the average of |
| 53 // the times of events currently in this structure with the time passed | 53 // the times of events currently in this structure with the time passed |
| 54 // into this method. | 54 // into this method. |
| 55 it->second.event_time += (time - it->second.event_time) * event_count / | 55 it->second.event_time += (time - it->second.event_time) * event_count / |
| 56 new_count; | 56 new_count; |
| 57 it->second.event_count = new_count; | 57 it->second.event_count = new_count; |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool LatencyInfo::HasLatencyComponent(LatencyComponentType type, | 61 bool LatencyInfo::FindLatency(LatencyComponentType type, |
| 62 int64 id) const { | 62 int64 id, |
| 63 return latency_components.find(std::make_pair(type, id)) != | 63 LatencyComponent* output) const { |
| 64 latency_components.end(); | 64 LatencyMap::const_iterator it = latency_components.find( |
| 65 std::make_pair(type, id)); |
| 66 if (it == latency_components.end()) |
| 67 return false; |
| 68 if (output) |
| 69 *output = it->second; |
| 70 return true; |
| 65 } | 71 } |
| 66 | 72 |
| 67 void LatencyInfo::Clear() { | 73 void LatencyInfo::Clear() { |
| 68 latency_components.clear(); | 74 latency_components.clear(); |
| 69 } | 75 } |
| 70 | 76 |
| 71 } // namespace ui | 77 } // namespace ui |
| OLD | NEW |