Record executable version details to stability file
BUG=620813
Review-Url: https://codereview.chromium.org/2556813002
Cr-Commit-Position: refs/heads/master@{#437719}
diff --git a/base/debug/activity_tracker.h b/base/debug/activity_tracker.h
index 20d3547..789905e 100644
--- a/base/debug/activity_tracker.h
+++ b/base/debug/activity_tracker.h
@@ -26,6 +26,7 @@
#include "base/gtest_prod_util.h"
#include "base/location.h"
#include "base/metrics/persistent_memory_allocator.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_checker.h"
#include "base/threading/thread_local_storage.h"
@@ -361,6 +362,9 @@
void SetString(StringPiece name, StringPiece value) {
Set(name, STRING_VALUE, value.data(), value.length());
}
+ void SetString(StringPiece name, StringPiece16 value) {
+ SetString(name, UTF16ToUTF8(value));
+ }
void SetBool(StringPiece name, bool value) {
char cvalue = value ? 1 : 0;
Set(name, BOOL_VALUE, &cvalue, sizeof(cvalue));
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 4e14096f7..a879ebd3 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -3496,6 +3496,7 @@
"//chrome_elf:dll_hash",
"//components/browser_watcher",
"//components/browser_watcher:browser_watcher_client",
+ "//components/browser_watcher:stability_data",
"//google_update",
"//third_party/crashpad/crashpad/client:client",
"//third_party/iaccessible2",
diff --git a/chrome/browser/chrome_browser_field_trials_desktop.cc b/chrome/browser/chrome_browser_field_trials_desktop.cc
index 6b562d5..3634168 100644
--- a/chrome/browser/chrome_browser_field_trials_desktop.cc
+++ b/chrome/browser/chrome_browser_field_trials_desktop.cc
@@ -4,6 +4,10 @@
#include "chrome/browser/chrome_browser_field_trials_desktop.h"
+#if defined(OS_WIN)
+#include <windows.h>
+#endif
+
#include <map>
#include <string>
@@ -24,6 +28,8 @@
#include "media/media_features.h"
#if defined(OS_WIN)
+#include "chrome/install_static/install_util.h"
+#include "components/browser_watcher/stability_data_names.h"
#include "components/browser_watcher/stability_debugging_win.h"
#endif
@@ -102,6 +108,35 @@
base::debug::GlobalActivityTracker::CreateWithFile(
stability_file, kMemorySize, kAllocatorId,
browser_watcher::kStabilityDebuggingFeature.name, kStackDepth);
+
+ // Record basic information: product, version, channel, special build and
+ // platform.
+ base::debug::GlobalActivityTracker* global_tracker =
+ base::debug::GlobalActivityTracker::Get();
+ if (global_tracker) {
+ wchar_t exe_file[MAX_PATH] = {};
+ CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file)));
+
+ base::string16 product_name;
+ base::string16 version_number;
+ base::string16 channel_name;
+ base::string16 special_build;
+ install_static::GetExecutableVersionDetails(exe_file, &product_name,
+ &version_number, &special_build,
+ &channel_name);
+
+ base::debug::ActivityUserData& global_data = global_tracker->user_data();
+ global_data.SetString(browser_watcher::kStabilityProduct, product_name);
+ global_data.SetString(browser_watcher::kStabilityVersion, version_number);
+ global_data.SetString(browser_watcher::kStabilityChannel, channel_name);
+ global_data.SetString(browser_watcher::kStabilitySpecialBuild,
+ special_build);
+#if defined(ARCH_CPU_X86)
+ global_data.SetString(browser_watcher::kStabilityPlatform, "Win32");
+#elif defined(ARCH_CPU_X86_64)
+ global_data.SetString(browser_watcher::kStabilityPlatform, "Win64");
+#endif
+ }
}
#endif // defined(OS_WIN)
diff --git a/components/browser_watcher/BUILD.gn b/components/browser_watcher/BUILD.gn
index fede06b9..5d64eed 100644
--- a/components/browser_watcher/BUILD.gn
+++ b/components/browser_watcher/BUILD.gn
@@ -83,6 +83,13 @@
]
}
+static_library("stability_data") {
+ sources = [
+ "stability_data_names.cc",
+ "stability_data_names.h",
+ ]
+}
+
source_set("unit_tests") {
testonly = true
sources = [
diff --git a/components/browser_watcher/stability_data_names.cc b/components/browser_watcher/stability_data_names.cc
new file mode 100644
index 0000000..b227065
--- /dev/null
+++ b/components/browser_watcher/stability_data_names.cc
@@ -0,0 +1,15 @@
+// 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 "components/browser_watcher/stability_data_names.h"
+
+namespace browser_watcher {
+
+const char kStabilityChannel[] = "channel";
+const char kStabilityPlatform[] = "platform";
+const char kStabilityProduct[] = "product";
+const char kStabilitySpecialBuild[] = "special-build";
+const char kStabilityVersion[] = "version";
+
+} // namespace browser_watcher
diff --git a/components/browser_watcher/stability_data_names.h b/components/browser_watcher/stability_data_names.h
new file mode 100644
index 0000000..9c7cfc15
--- /dev/null
+++ b/components/browser_watcher/stability_data_names.h
@@ -0,0 +1,19 @@
+// 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.
+
+#ifndef COMPONENTS_BROWSER_WATCHER_STABILITY_DATA_NAMES_H_
+#define COMPONENTS_BROWSER_WATCHER_STABILITY_DATA_NAMES_H_
+
+namespace browser_watcher {
+
+// Alphabetical list of stability data names.
+extern const char kStabilityChannel[];
+extern const char kStabilityPlatform[];
+extern const char kStabilityProduct[];
+extern const char kStabilitySpecialBuild[];
+extern const char kStabilityVersion[];
+
+} // namespace browser_watcher
+
+#endif // COMPONENTS_BROWSER_WATCHER_STABILITY_DATA_NAMES_H_