OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/metrics/metrics_log.h" | 5 #include "chrome/browser/metrics/metrics_log.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 while (i > 0 && isdigit(thread_name[i - 1])) { | 266 while (i > 0 && isdigit(thread_name[i - 1])) { |
267 --i; | 267 --i; |
268 } | 268 } |
269 | 269 |
270 if (i == thread_name.length()) | 270 if (i == thread_name.length()) |
271 return thread_name; | 271 return thread_name; |
272 | 272 |
273 return thread_name.substr(0, i) + '*'; | 273 return thread_name.substr(0, i) + '*'; |
274 } | 274 } |
275 | 275 |
| 276 // Normalizes a source filename (which is platform- and build-method-dependent) |
| 277 // by extracting the last component of the full file name. |
| 278 // Example: "c:\b\build\slave\win\build\src\chrome\app\chrome_main.cc" => |
| 279 // "chrome_main.cc". |
| 280 std::string NormalizeFileName(const std::string& file_name) { |
| 281 const size_t offset = file_name.find_last_of("\\/"); |
| 282 return offset != std::string::npos ? file_name.substr(offset + 1) : file_name; |
| 283 } |
| 284 |
276 void WriteProfilerData(const ProcessDataSnapshot& profiler_data, | 285 void WriteProfilerData(const ProcessDataSnapshot& profiler_data, |
277 int process_type, | 286 int process_type, |
278 ProfilerEventProto* performance_profile) { | 287 ProfilerEventProto* performance_profile) { |
279 for (std::vector<tracked_objects::TaskSnapshot>::const_iterator it = | 288 for (std::vector<tracked_objects::TaskSnapshot>::const_iterator it = |
280 profiler_data.tasks.begin(); | 289 profiler_data.tasks.begin(); |
281 it != profiler_data.tasks.end(); ++it) { | 290 it != profiler_data.tasks.end(); ++it) { |
282 const tracked_objects::DeathDataSnapshot& death_data = it->death_data; | 291 const tracked_objects::DeathDataSnapshot& death_data = it->death_data; |
283 ProfilerEventProto::TrackedObject* tracked_object = | 292 ProfilerEventProto::TrackedObject* tracked_object = |
284 performance_profile->add_tracked_object(); | 293 performance_profile->add_tracked_object(); |
285 tracked_object->set_birth_thread_name_hash( | 294 tracked_object->set_birth_thread_name_hash( |
286 MetricsLogBase::Hash(MapThreadName(it->birth.thread_name))); | 295 MetricsLogBase::Hash(MapThreadName(it->birth.thread_name))); |
287 tracked_object->set_exec_thread_name_hash( | 296 tracked_object->set_exec_thread_name_hash( |
288 MetricsLogBase::Hash(MapThreadName(it->death_thread_name))); | 297 MetricsLogBase::Hash(MapThreadName(it->death_thread_name))); |
289 tracked_object->set_source_file_name_hash( | 298 tracked_object->set_source_file_name_hash( |
290 MetricsLogBase::Hash(it->birth.location.file_name)); | 299 MetricsLogBase::Hash(NormalizeFileName(it->birth.location.file_name))); |
291 tracked_object->set_source_function_name_hash( | 300 tracked_object->set_source_function_name_hash( |
292 MetricsLogBase::Hash(it->birth.location.function_name)); | 301 MetricsLogBase::Hash(it->birth.location.function_name)); |
293 tracked_object->set_source_line_number(it->birth.location.line_number); | 302 tracked_object->set_source_line_number(it->birth.location.line_number); |
294 tracked_object->set_exec_count(death_data.count); | 303 tracked_object->set_exec_count(death_data.count); |
295 tracked_object->set_exec_time_total(death_data.run_duration_sum); | 304 tracked_object->set_exec_time_total(death_data.run_duration_sum); |
296 tracked_object->set_exec_time_sampled(death_data.run_duration_sample); | 305 tracked_object->set_exec_time_sampled(death_data.run_duration_sample); |
297 tracked_object->set_queue_time_total(death_data.queue_duration_sum); | 306 tracked_object->set_queue_time_total(death_data.queue_duration_sum); |
298 tracked_object->set_queue_time_sampled(death_data.queue_duration_sample); | 307 tracked_object->set_queue_time_sampled(death_data.queue_duration_sample); |
299 tracked_object->set_process_type(AsProtobufProcessType(process_type)); | 308 tracked_object->set_process_type(AsProtobufProcessType(process_type)); |
300 tracked_object->set_process_id(profiler_data.process_id); | 309 tracked_object->set_process_id(profiler_data.process_id); |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 ProductDataToProto(google_update_metrics.google_update_data, | 901 ProductDataToProto(google_update_metrics.google_update_data, |
893 google_update->mutable_google_update_status()); | 902 google_update->mutable_google_update_status()); |
894 } | 903 } |
895 | 904 |
896 if (!google_update_metrics.product_data.version.empty()) { | 905 if (!google_update_metrics.product_data.version.empty()) { |
897 ProductDataToProto(google_update_metrics.product_data, | 906 ProductDataToProto(google_update_metrics.product_data, |
898 google_update->mutable_client_status()); | 907 google_update->mutable_client_status()); |
899 } | 908 } |
900 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) | 909 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) |
901 } | 910 } |
OLD | NEW |