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 "base/debug/trace_event.h" | 5 #include "base/debug/trace_event.h" |
6 #include "base/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "ui/events/latency_info.h" | 9 #include "ui/events/latency_info.h" |
10 | 10 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 latency_components.clear(); | 228 latency_components.clear(); |
229 } | 229 } |
230 | 230 |
231 void LatencyInfo::TraceEventType(const char* event_type) { | 231 void LatencyInfo::TraceEventType(const char* event_type) { |
232 TRACE_EVENT_ASYNC_STEP_INTO0("benchmark", | 232 TRACE_EVENT_ASYNC_STEP_INTO0("benchmark", |
233 "InputLatency", | 233 "InputLatency", |
234 TRACE_ID_DONT_MANGLE(trace_id), | 234 TRACE_ID_DONT_MANGLE(trace_id), |
235 event_type); | 235 event_type); |
236 } | 236 } |
237 | 237 |
| 238 void LatencyInfo::AnnotateWithProcessId( |
| 239 std::vector<ui::LatencyInfo>& latency_info, |
| 240 base::ProcessId process_id) { |
| 241 for (size_t i = 0; i < latency_info.size(); i++) { |
| 242 latency_info[i].AnnotateComponentsWithProcessId(process_id); |
| 243 } |
| 244 } |
| 245 |
| 246 void LatencyInfo::AnnotateComponentsWithProcessId(base::ProcessId process_id) { |
| 247 LatencyMap::iterator lc = latency_components.begin(); |
| 248 while (lc != latency_components.end()) { |
| 249 LatencyComponentType component_type = lc->first.first; |
| 250 if (component_type == WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) { |
| 251 // If the component's process ID is kNullProcessId, patch it with the |
| 252 // correct value. |
| 253 int component_process_id = (lc->first.second >> 32) & 0xffffffff; |
| 254 if (component_process_id == base::kNullProcessId) { |
| 255 // Generate a new component entry |
| 256 int routing_id = lc->first.second & 0xffffffff; |
| 257 int64 id = routing_id | (static_cast<int64>(process_id) << 32); |
| 258 LatencyMap::key_type key = std::make_pair(component_type, id); |
| 259 latency_components[key] = lc->second; |
| 260 |
| 261 // Remove the old entry |
| 262 LatencyMap::iterator eraseIter = lc; |
| 263 ++lc; |
| 264 latency_components.erase(eraseIter); |
| 265 |
| 266 continue; |
| 267 } |
| 268 } |
| 269 |
| 270 ++lc; |
| 271 } |
| 272 } |
| 273 |
238 } // namespace ui | 274 } // namespace ui |
OLD | NEW |