Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: chrome/browser/metrics/metrics_log.cc

Issue 217483006: Normalizing source file names before calculating hash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/metrics/metrics_log_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/metrics_log.cc
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc
index 4fd74e7028c3038c4725d9fbbb4a07aace96d18b..1d8d56ec114595e4ee27357f8a96c70eb4b27751 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/chrome/browser/metrics/metrics_log.cc
@@ -273,6 +273,15 @@ std::string MapThreadName(const std::string& thread_name) {
return thread_name.substr(0, i) + '*';
}
+// Normalizes a source filename (which is platform- and build-method-dependent)
+// by extracting the last component of the full file name.
+// Example: "c:\b\build\slave\win\build\src\chrome\app\chrome_main.cc" =>
+// "chrome_main.cc".
+std::string NormalizeFileName(const std::string& file_name) {
+ const size_t offset = file_name.find_last_of("\\/");
+ return offset != std::string::npos ? file_name.substr(offset + 1) : file_name;
+}
+
void WriteProfilerData(const ProcessDataSnapshot& profiler_data,
int process_type,
ProfilerEventProto* performance_profile) {
@@ -287,7 +296,7 @@ void WriteProfilerData(const ProcessDataSnapshot& profiler_data,
tracked_object->set_exec_thread_name_hash(
MetricsLogBase::Hash(MapThreadName(it->death_thread_name)));
tracked_object->set_source_file_name_hash(
- MetricsLogBase::Hash(it->birth.location.file_name));
+ MetricsLogBase::Hash(NormalizeFileName(it->birth.location.file_name)));
tracked_object->set_source_function_name_hash(
MetricsLogBase::Hash(it->birth.location.function_name));
tracked_object->set_source_line_number(it->birth.location.line_number);
« no previous file with comments | « no previous file | chrome/browser/metrics/metrics_log_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698