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 return file_name.substr(file_name.find_last_of("\\/") + 1); | |
jar (doing other things)
2014/04/01 18:46:12
I think the code works... but it probably shouldn'
vadimt
2014/04/01 18:59:01
It's not a problem for me to change the code, but
jar (doing other things)
2014/04/01 19:16:17
OK... I can live with that. I hadn't seen it.
Th
Ilya Sherman
2014/04/02 06:56:15
I agree with Jim that relying on (string::npos + 1
vadimt
2014/04/02 17:50:25
Done.
| |
282 } | |
283 | |
276 void WriteProfilerData(const ProcessDataSnapshot& profiler_data, | 284 void WriteProfilerData(const ProcessDataSnapshot& profiler_data, |
277 int process_type, | 285 int process_type, |
278 ProfilerEventProto* performance_profile) { | 286 ProfilerEventProto* performance_profile) { |
279 for (std::vector<tracked_objects::TaskSnapshot>::const_iterator it = | 287 for (std::vector<tracked_objects::TaskSnapshot>::const_iterator it = |
280 profiler_data.tasks.begin(); | 288 profiler_data.tasks.begin(); |
281 it != profiler_data.tasks.end(); ++it) { | 289 it != profiler_data.tasks.end(); ++it) { |
282 const tracked_objects::DeathDataSnapshot& death_data = it->death_data; | 290 const tracked_objects::DeathDataSnapshot& death_data = it->death_data; |
283 ProfilerEventProto::TrackedObject* tracked_object = | 291 ProfilerEventProto::TrackedObject* tracked_object = |
284 performance_profile->add_tracked_object(); | 292 performance_profile->add_tracked_object(); |
285 tracked_object->set_birth_thread_name_hash( | 293 tracked_object->set_birth_thread_name_hash( |
286 MetricsLogBase::Hash(MapThreadName(it->birth.thread_name))); | 294 MetricsLogBase::Hash(MapThreadName(it->birth.thread_name))); |
287 tracked_object->set_exec_thread_name_hash( | 295 tracked_object->set_exec_thread_name_hash( |
288 MetricsLogBase::Hash(MapThreadName(it->death_thread_name))); | 296 MetricsLogBase::Hash(MapThreadName(it->death_thread_name))); |
289 tracked_object->set_source_file_name_hash( | 297 tracked_object->set_source_file_name_hash( |
290 MetricsLogBase::Hash(it->birth.location.file_name)); | 298 MetricsLogBase::Hash(NormalizeFileName(it->birth.location.file_name))); |
291 tracked_object->set_source_function_name_hash( | 299 tracked_object->set_source_function_name_hash( |
292 MetricsLogBase::Hash(it->birth.location.function_name)); | 300 MetricsLogBase::Hash(it->birth.location.function_name)); |
293 tracked_object->set_source_line_number(it->birth.location.line_number); | 301 tracked_object->set_source_line_number(it->birth.location.line_number); |
294 tracked_object->set_exec_count(death_data.count); | 302 tracked_object->set_exec_count(death_data.count); |
295 tracked_object->set_exec_time_total(death_data.run_duration_sum); | 303 tracked_object->set_exec_time_total(death_data.run_duration_sum); |
296 tracked_object->set_exec_time_sampled(death_data.run_duration_sample); | 304 tracked_object->set_exec_time_sampled(death_data.run_duration_sample); |
297 tracked_object->set_queue_time_total(death_data.queue_duration_sum); | 305 tracked_object->set_queue_time_total(death_data.queue_duration_sum); |
298 tracked_object->set_queue_time_sampled(death_data.queue_duration_sample); | 306 tracked_object->set_queue_time_sampled(death_data.queue_duration_sample); |
299 tracked_object->set_process_type(AsProtobufProcessType(process_type)); | 307 tracked_object->set_process_type(AsProtobufProcessType(process_type)); |
300 tracked_object->set_process_id(profiler_data.process_id); | 308 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, | 900 ProductDataToProto(google_update_metrics.google_update_data, |
893 google_update->mutable_google_update_status()); | 901 google_update->mutable_google_update_status()); |
894 } | 902 } |
895 | 903 |
896 if (!google_update_metrics.product_data.version.empty()) { | 904 if (!google_update_metrics.product_data.version.empty()) { |
897 ProductDataToProto(google_update_metrics.product_data, | 905 ProductDataToProto(google_update_metrics.product_data, |
898 google_update->mutable_client_status()); | 906 google_update->mutable_client_status()); |
899 } | 907 } |
900 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) | 908 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) |
901 } | 909 } |
OLD | NEW |