Commit 6d149915 authored by manzagop's avatar manzagop Committed by Commit bot

Record MetricsService's execution phase to the stability file

Also:
- upstream some "ifdef(OS_WIN)" by moving stability_debugging_win.{h,cc} to stability_debugging.{h,cc}.
- enclose components/browser_watcher/BUILD.gn targets in "if (is_win) {}" as the dependency from components/metrics started causing win only targets to be built on other platforms.

BUG=620813

Review-Url: https://codereview.chromium.org/2531123002
Cr-Commit-Position: refs/heads/master@{#439536}
parent 3eb8769e
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "components/browser_watcher/features.h" #include "components/browser_watcher/features.h"
#include "components/browser_watcher/stability_debugging.h"
#include "components/variations/variations_associated_data.h" #include "components/variations/variations_associated_data.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "media/media_features.h" #include "media/media_features.h"
...@@ -30,7 +31,6 @@ ...@@ -30,7 +31,6 @@
#if defined(OS_WIN) #if defined(OS_WIN)
#include "chrome/install_static/install_util.h" #include "chrome/install_static/install_util.h"
#include "components/browser_watcher/stability_data_names.h" #include "components/browser_watcher/stability_data_names.h"
#include "components/browser_watcher/stability_debugging_win.h"
#endif #endif
namespace chrome { namespace chrome {
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "chrome/common/features.h" #include "chrome/common/features.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/installer/util/util_constants.h" #include "chrome/installer/util/util_constants.h"
#include "components/browser_watcher/stability_debugging.h"
#include "components/metrics/call_stack_profile_metrics_provider.h" #include "components/metrics/call_stack_profile_metrics_provider.h"
#include "components/metrics/drive_metrics_provider.h" #include "components/metrics/drive_metrics_provider.h"
#include "components/metrics/file_metrics_provider.h" #include "components/metrics/file_metrics_provider.h"
...@@ -105,7 +106,6 @@ ...@@ -105,7 +106,6 @@
#include "chrome/common/metrics_constants_util_win.h" #include "chrome/common/metrics_constants_util_win.h"
#include "chrome/install_static/install_util.h" #include "chrome/install_static/install_util.h"
#include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/browser_distribution.h"
#include "components/browser_watcher/stability_debugging_win.h"
#include "components/browser_watcher/watcher_metrics_provider_win.h" #include "components/browser_watcher/watcher_metrics_provider_win.h"
#endif #endif
......
...@@ -4,13 +4,14 @@ ...@@ -4,13 +4,14 @@
import("//third_party/protobuf/proto_library.gni") import("//third_party/protobuf/proto_library.gni")
proto_library("stability_report_proto") { if (is_win) {
proto_library("stability_report_proto") {
sources = [ sources = [
"stability_report.proto", "stability_report.proto",
] ]
} }
static_library("browser_watcher") { static_library("browser_watcher") {
# This is a separate lib to minimize the dependencies for its # This is a separate lib to minimize the dependencies for its
# hosting binary "chrome_watcher.dll". # hosting binary "chrome_watcher.dll".
sources = [ sources = [
...@@ -24,9 +25,9 @@ static_library("browser_watcher") { ...@@ -24,9 +25,9 @@ static_library("browser_watcher") {
deps = [ deps = [
"//base", "//base",
] ]
} }
static_library("browser_watcher_client") { static_library("browser_watcher_client") {
sources = [ sources = [
"watcher_client_win.cc", "watcher_client_win.cc",
"watcher_client_win.h", "watcher_client_win.h",
...@@ -40,9 +41,9 @@ static_library("browser_watcher_client") { ...@@ -40,9 +41,9 @@ static_library("browser_watcher_client") {
"//components/metrics", "//components/metrics",
"//third_party/crashpad/crashpad/client", "//third_party/crashpad/crashpad/client",
] ]
} }
static_library("postmortem_minidump_writer") { static_library("postmortem_minidump_writer") {
# TODO(manzagop): remove this lib once Crashpad writes the minidumps. # TODO(manzagop): remove this lib once Crashpad writes the minidumps.
sources = [ sources = [
"postmortem_minidump_writer.h", "postmortem_minidump_writer.h",
...@@ -55,9 +56,9 @@ static_library("postmortem_minidump_writer") { ...@@ -55,9 +56,9 @@ static_library("postmortem_minidump_writer") {
"//third_party/crashpad/crashpad/minidump", "//third_party/crashpad/crashpad/minidump",
"//third_party/crashpad/crashpad/util", "//third_party/crashpad/crashpad/util",
] ]
} }
static_library("postmortem_report_collector") { static_library("postmortem_report_collector") {
sources = [ sources = [
"postmortem_report_collector.cc", "postmortem_report_collector.cc",
"postmortem_report_collector.h", "postmortem_report_collector.h",
...@@ -69,14 +70,15 @@ static_library("postmortem_report_collector") { ...@@ -69,14 +70,15 @@ static_library("postmortem_report_collector") {
"//third_party/crashpad/crashpad/client", "//third_party/crashpad/crashpad/client",
"//third_party/crashpad/crashpad/util", "//third_party/crashpad/crashpad/util",
] ]
}
} }
static_library("stability") { static_library("stability") {
sources = [ sources = [
"features.cc", "features.cc",
"features.h", "features.h",
"stability_debugging_win.cc", "stability_debugging.cc",
"stability_debugging_win.h", "stability_debugging.h",
] ]
deps = [ deps = [
"//base", "//base",
...@@ -90,7 +92,8 @@ static_library("stability_data") { ...@@ -90,7 +92,8 @@ static_library("stability_data") {
] ]
} }
source_set("unit_tests") { if (is_win) {
source_set("unit_tests") {
testonly = true testonly = true
sources = [ sources = [
"endsession_watcher_window_win_unittest.cc", "endsession_watcher_window_win_unittest.cc",
...@@ -120,9 +123,9 @@ source_set("unit_tests") { ...@@ -120,9 +123,9 @@ source_set("unit_tests") {
"//third_party/crashpad/crashpad/snapshot", "//third_party/crashpad/crashpad/snapshot",
"//third_party/crashpad/crashpad/util", "//third_party/crashpad/crashpad/util",
] ]
} }
executable("dump_postmortem") { executable("dump_postmortem") {
sources = [ sources = [
"dump_postmortem_minidump_main_win.cc", "dump_postmortem_minidump_main_win.cc",
] ]
...@@ -130,4 +133,5 @@ executable("dump_postmortem") { ...@@ -130,4 +133,5 @@ executable("dump_postmortem") {
":stability_report_proto", ":stability_report_proto",
"//base", "//base",
] ]
}
} }
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace browser_watcher { namespace browser_watcher {
const char kStabilityChannel[] = "channel"; const char kStabilityChannel[] = "channel";
const char kStabilityExecutionPhase[] = "stability-execution-phase";
const char kStabilityPlatform[] = "platform"; const char kStabilityPlatform[] = "platform";
const char kStabilityProduct[] = "product"; const char kStabilityProduct[] = "product";
const char kStabilitySpecialBuild[] = "special-build"; const char kStabilitySpecialBuild[] = "special-build";
......
...@@ -9,6 +9,7 @@ namespace browser_watcher { ...@@ -9,6 +9,7 @@ namespace browser_watcher {
// Alphabetical list of stability data names. // Alphabetical list of stability data names.
extern const char kStabilityChannel[]; extern const char kStabilityChannel[];
extern const char kStabilityExecutionPhase[];
extern const char kStabilityPlatform[]; extern const char kStabilityPlatform[];
extern const char kStabilityProduct[]; extern const char kStabilityProduct[];
extern const char kStabilitySpecialBuild[]; extern const char kStabilitySpecialBuild[];
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/browser_watcher/stability_debugging_win.h" #include "components/browser_watcher/stability_debugging.h"
#include <string> #include <string>
#include "base/debug/activity_tracker.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/files/file.h" #include "base/files/file.h"
#include "base/metrics/persistent_memory_allocator.h" #include "base/metrics/persistent_memory_allocator.h"
...@@ -19,6 +20,7 @@ namespace browser_watcher { ...@@ -19,6 +20,7 @@ namespace browser_watcher {
namespace { namespace {
#if defined(OS_WIN)
bool GetCreationTime(const base::Process& process, base::Time* time) { bool GetCreationTime(const base::Process& process, base::Time* time) {
DCHECK(time); DCHECK(time);
...@@ -33,9 +35,12 @@ bool GetCreationTime(const base::Process& process, base::Time* time) { ...@@ -33,9 +35,12 @@ bool GetCreationTime(const base::Process& process, base::Time* time) {
*time = base::Time::FromFileTime(creation_time); *time = base::Time::FromFileTime(creation_time);
return true; return true;
} }
#endif // defined(OS_WIN)
} // namespace } // namespace
#if defined(OS_WIN)
base::FilePath GetStabilityDir(const base::FilePath& user_data_dir) { base::FilePath GetStabilityDir(const base::FilePath& user_data_dir) {
return user_data_dir.AppendASCII("Stability"); return user_data_dir.AppendASCII("Stability");
} }
...@@ -84,5 +89,15 @@ void MarkStabilityFileForDeletion(const base::FilePath& user_data_dir) { ...@@ -84,5 +89,15 @@ void MarkStabilityFileForDeletion(const base::FilePath& user_data_dir) {
base::File::FLAG_READ | base::File::FLAG_READ |
base::File::FLAG_DELETE_ON_CLOSE); base::File::FLAG_DELETE_ON_CLOSE);
} }
#endif // defined(OS_WIN)
void SetStabilityDataInt(base::StringPiece name, int64_t value) {
base::debug::GlobalActivityTracker* global_tracker =
base::debug::GlobalActivityTracker::Get();
if (!global_tracker)
return; // Activity tracking isn't enabled.
global_tracker->user_data().SetInt(name, value);
}
} // namespace browser_watcher } // namespace browser_watcher
...@@ -2,15 +2,20 @@ ...@@ -2,15 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_BROWSER_WATCHER_STABILITY_DEBUGGING_WIN_H_ #ifndef COMPONENTS_BROWSER_WATCHER_STABILITY_DEBUGGING_H_
#define COMPONENTS_BROWSER_WATCHER_STABILITY_DEBUGGING_WIN_H_ #define COMPONENTS_BROWSER_WATCHER_STABILITY_DEBUGGING_H_
#include <stdint.h>
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/process/process.h" #include "base/process/process.h"
#include "base/strings/string_piece.h"
namespace browser_watcher { namespace browser_watcher {
#if defined(OS_WIN)
// Returns the the stability debugging directory. // Returns the the stability debugging directory.
base::FilePath GetStabilityDir(const base::FilePath& user_data_dir); base::FilePath GetStabilityDir(const base::FilePath& user_data_dir);
...@@ -26,6 +31,11 @@ base::FilePath::StringType GetStabilityFilePattern(); ...@@ -26,6 +31,11 @@ base::FilePath::StringType GetStabilityFilePattern();
// Marks the stability file for deletion. // Marks the stability file for deletion.
void MarkStabilityFileForDeletion(const base::FilePath& user_data_dir); void MarkStabilityFileForDeletion(const base::FilePath& user_data_dir);
#endif // defined(OS_WIN)
// Adds or updates the global stability user data.
void SetStabilityDataInt(base::StringPiece name, int64_t value);
} // namespace browser_watcher } // namespace browser_watcher
#endif // COMPONENTS_BROWSER_WATCHER_STABILITY_DEBUGGING_WIN_H_ #endif // COMPONENTS_BROWSER_WATCHER_STABILITY_DEBUGGING_H_
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "base/win/registry.h" #include "base/win/registry.h"
#include "components/browser_watcher/features.h" #include "components/browser_watcher/features.h"
#include "components/browser_watcher/postmortem_report_collector.h" #include "components/browser_watcher/postmortem_report_collector.h"
#include "components/browser_watcher/stability_debugging_win.h" #include "components/browser_watcher/stability_debugging.h"
#include "third_party/crashpad/crashpad/client/crash_report_database.h" #include "third_party/crashpad/crashpad/client/crash_report_database.h"
namespace browser_watcher { namespace browser_watcher {
......
...@@ -85,6 +85,8 @@ static_library("metrics") { ...@@ -85,6 +85,8 @@ static_library("metrics") {
":call_stack_profile_params", ":call_stack_profile_params",
"//base", "//base",
"//base:base_static", "//base:base_static",
"//components/browser_watcher:stability",
"//components/browser_watcher:stability_data",
"//components/prefs", "//components/prefs",
"//components/variations", "//components/variations",
"//third_party/zlib:compression_utils", "//third_party/zlib:compression_utils",
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# dependencies to a minimal set. # dependencies to a minimal set.
include_rules = [ include_rules = [
"-components", "-components",
"+components/browser_watcher",
"+components/compression", "+components/compression",
"+components/metrics", "+components/metrics",
"+components/prefs", "+components/prefs",
......
...@@ -149,6 +149,8 @@ ...@@ -149,6 +149,8 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "base/tracked_objects.h" #include "base/tracked_objects.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/browser_watcher/stability_data_names.h"
#include "components/browser_watcher/stability_debugging.h"
#include "components/metrics/data_use_tracker.h" #include "components/metrics/data_use_tracker.h"
#include "components/metrics/metrics_log.h" #include "components/metrics/metrics_log.h"
#include "components/metrics/metrics_log_manager.h" #include "components/metrics/metrics_log_manager.h"
...@@ -499,6 +501,8 @@ void MetricsService::SetExecutionPhase(ExecutionPhase execution_phase, ...@@ -499,6 +501,8 @@ void MetricsService::SetExecutionPhase(ExecutionPhase execution_phase,
PrefService* local_state) { PrefService* local_state) {
execution_phase_ = execution_phase; execution_phase_ = execution_phase;
local_state->SetInteger(prefs::kStabilityExecutionPhase, execution_phase_); local_state->SetInteger(prefs::kStabilityExecutionPhase, execution_phase_);
browser_watcher::SetStabilityDataInt(
browser_watcher::kStabilityExecutionPhase, execution_phase_);
} }
void MetricsService::RecordBreakpadRegistration(bool success) { void MetricsService::RecordBreakpadRegistration(bool success) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment