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

Unified Diff: chrome/chrome_watcher/chrome_postmortem_report_collector.cc

Issue 2372633002: Use the correct product/version for postmortem reports (Closed)
Patch Set: Direct access to GetExecutableVersionDetails via ChromePostmortemReportCollector Created 4 years, 3 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
Index: chrome/chrome_watcher/chrome_postmortem_report_collector.cc
diff --git a/chrome/chrome_watcher/chrome_postmortem_report_collector.cc b/chrome/chrome_watcher/chrome_postmortem_report_collector.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dd83f45c59136306b51aca662b4c034d6c6dcb22
--- /dev/null
+++ b/chrome/chrome_watcher/chrome_postmortem_report_collector.cc
@@ -0,0 +1,51 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/chrome_watcher/chrome_postmortem_report_collector.h"
+
+#include <windows.h>
+
+#include "base/strings/string16.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/install_static/install_util.h"
+
+namespace chrome_watcher {
+
+ChromePostmortemReportCollector::ChromePostmortemReportCollector()
+ : PostmortemReportCollector(), version_details_initialized_(false) {}
+
+const std::string& ChromePostmortemReportCollector::GetProductName() {
+ if (!version_details_initialized_)
+ InitializeVersionDetails();
+ return product_name_;
+}
+
+const std::string& ChromePostmortemReportCollector::GetProductVersion() {
+ if (!version_details_initialized_)
+ InitializeVersionDetails();
+ return version_number_;
+}
+
+const std::string& ChromePostmortemReportCollector::GetProductChannel() {
+ if (!version_details_initialized_)
+ InitializeVersionDetails();
+ return channel_name_;
+}
+
+void ChromePostmortemReportCollector::InitializeVersionDetails() {
+ DCHECK(!version_details_initialized_);
+
+ wchar_t exe_file[MAX_PATH] = {};
+ CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file)));
+
+ base::string16 product_name, version_number, special_build, channel_name;
+ install_static::GetExecutableVersionDetails(
+ exe_file, &product_name, &version_number, &special_build, &channel_name);
+
+ product_name_ = base::UTF16ToUTF8(product_name);
+ version_number_ = base::UTF16ToUTF8(version_number);
+ channel_name_ = base::UTF16ToUTF8(channel_name);
+}
+
+} // namespace chrome_watcher

Powered by Google App Engine
This is Rietveld 408576698