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) { | |
jar (doing other things)
2014/03/29 00:32:25
nit: The argument is actually a const char* (befor
vadimt
2014/03/29 00:45:50
In fact, the parameter std::string.
https://code.g
jar (doing other things)
2014/03/29 00:52:23
Ah... quite correct. SGTM.
| |
281 size_t i = file_name.length(); | |
282 | |
283 while (i > 0) { | |
284 const char current_character = file_name[i - 1]; | |
285 if (current_character == '/' || current_character == '\\') | |
286 break; | |
287 --i; | |
288 } | |
289 | |
290 return file_name.substr(i); | |
Ilya Sherman
2014/03/29 01:06:49
IMO this method would be clearer if written using
vadimt
2014/03/31 18:10:14
Yeah, but that is much less efficient, since we bu
Ilya Sherman
2014/03/31 23:44:48
I'm not convinced that this is a place where such
vadimt
2014/04/01 18:24:10
Done, but using find_last_of. Looks OK?
| |
291 } | |
292 | |
276 void WriteProfilerData(const ProcessDataSnapshot& profiler_data, | 293 void WriteProfilerData(const ProcessDataSnapshot& profiler_data, |
277 int process_type, | 294 int process_type, |
278 ProfilerEventProto* performance_profile) { | 295 ProfilerEventProto* performance_profile) { |
279 for (std::vector<tracked_objects::TaskSnapshot>::const_iterator it = | 296 for (std::vector<tracked_objects::TaskSnapshot>::const_iterator it = |
280 profiler_data.tasks.begin(); | 297 profiler_data.tasks.begin(); |
281 it != profiler_data.tasks.end(); ++it) { | 298 it != profiler_data.tasks.end(); ++it) { |
282 const tracked_objects::DeathDataSnapshot& death_data = it->death_data; | 299 const tracked_objects::DeathDataSnapshot& death_data = it->death_data; |
283 ProfilerEventProto::TrackedObject* tracked_object = | 300 ProfilerEventProto::TrackedObject* tracked_object = |
284 performance_profile->add_tracked_object(); | 301 performance_profile->add_tracked_object(); |
285 tracked_object->set_birth_thread_name_hash( | 302 tracked_object->set_birth_thread_name_hash( |
286 MetricsLogBase::Hash(MapThreadName(it->birth.thread_name))); | 303 MetricsLogBase::Hash(MapThreadName(it->birth.thread_name))); |
287 tracked_object->set_exec_thread_name_hash( | 304 tracked_object->set_exec_thread_name_hash( |
288 MetricsLogBase::Hash(MapThreadName(it->death_thread_name))); | 305 MetricsLogBase::Hash(MapThreadName(it->death_thread_name))); |
289 tracked_object->set_source_file_name_hash( | 306 tracked_object->set_source_file_name_hash( |
290 MetricsLogBase::Hash(it->birth.location.file_name)); | 307 MetricsLogBase::Hash(NormalizeFileName(it->birth.location.file_name))); |
jar (doing other things)
2014/03/29 00:32:25
Should we consider expanding the protobuf, and put
vadimt
2014/03/29 00:45:50
Given uselessness of the existing full filename ha
jar (doing other things)
2014/03/29 00:52:23
OK. The old one disambiguates... but I guess if w
| |
291 tracked_object->set_source_function_name_hash( | 308 tracked_object->set_source_function_name_hash( |
292 MetricsLogBase::Hash(it->birth.location.function_name)); | 309 MetricsLogBase::Hash(it->birth.location.function_name)); |
293 tracked_object->set_source_line_number(it->birth.location.line_number); | 310 tracked_object->set_source_line_number(it->birth.location.line_number); |
294 tracked_object->set_exec_count(death_data.count); | 311 tracked_object->set_exec_count(death_data.count); |
295 tracked_object->set_exec_time_total(death_data.run_duration_sum); | 312 tracked_object->set_exec_time_total(death_data.run_duration_sum); |
296 tracked_object->set_exec_time_sampled(death_data.run_duration_sample); | 313 tracked_object->set_exec_time_sampled(death_data.run_duration_sample); |
297 tracked_object->set_queue_time_total(death_data.queue_duration_sum); | 314 tracked_object->set_queue_time_total(death_data.queue_duration_sum); |
298 tracked_object->set_queue_time_sampled(death_data.queue_duration_sample); | 315 tracked_object->set_queue_time_sampled(death_data.queue_duration_sample); |
299 tracked_object->set_process_type(AsProtobufProcessType(process_type)); | 316 tracked_object->set_process_type(AsProtobufProcessType(process_type)); |
300 tracked_object->set_process_id(profiler_data.process_id); | 317 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, | 909 ProductDataToProto(google_update_metrics.google_update_data, |
893 google_update->mutable_google_update_status()); | 910 google_update->mutable_google_update_status()); |
894 } | 911 } |
895 | 912 |
896 if (!google_update_metrics.product_data.version.empty()) { | 913 if (!google_update_metrics.product_data.version.empty()) { |
897 ProductDataToProto(google_update_metrics.product_data, | 914 ProductDataToProto(google_update_metrics.product_data, |
898 google_update->mutable_client_status()); | 915 google_update->mutable_client_status()); |
899 } | 916 } |
900 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) | 917 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) |
901 } | 918 } |
OLD | NEW |