Commit 5bf01aa8 authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Commit Bot

Move SystemSessionAnalyzer into the metrics component.

Bug: 799526
Change-Id: Id1f4e62914232e4cf37d550f6914690334f7ddee
Reviewed-on: https://chromium-review.googlesource.com/893207Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532977}
parent 059010de
......@@ -49,20 +49,18 @@ if (is_win) {
"postmortem_minidump_writer_win.cc",
"postmortem_report_collector.cc",
"postmortem_report_collector.h",
"system_session_analyzer_win.cc",
"system_session_analyzer_win.h",
]
deps = [
":stability_client",
":stability_common",
":stability_report_proto",
"//base",
"//components/metrics:metrics",
"//components/variations",
"//third_party/crashpad/crashpad/client",
"//third_party/crashpad/crashpad/minidump",
"//third_party/crashpad/crashpad/util",
]
libs = [ "wevtapi.lib" ]
ldflags = [ "/DELAYLOAD:wevtapi.dll" ] # Only used after unclean shutdowns.
}
......@@ -128,7 +126,6 @@ if (is_win) {
"stability_debugging_win_unittest.cc",
"stability_paths_unittest.cc",
"stability_report_extractor_unittest.cc",
"system_session_analyzer_win_unittest.cc",
"watcher_client_win_unittest.cc",
"watcher_metrics_provider_win_unittest.cc",
"window_hang_monitor_win_unittest.cc",
......@@ -143,6 +140,7 @@ if (is_win) {
":stability_report_proto",
"//base",
"//base/test:test_support",
"//components/metrics:metrics",
"//testing/gmock",
"//testing/gtest",
"//third_party/crashpad/crashpad/client",
......@@ -171,6 +169,7 @@ if (is_win) {
deps = [
":postmortem_stability",
"//base",
"//components/metrics:metrics",
]
}
}
......@@ -9,11 +9,11 @@
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "components/browser_watcher/system_session_analyzer_win.h"
#include "components/metrics/system_session_analyzer_win.h"
namespace {
using browser_watcher::SystemSessionAnalyzer;
using metrics::SystemSessionAnalyzer;
class SystemSessionEventFetcher : public SystemSessionAnalyzer {
public:
......
......@@ -60,14 +60,14 @@ void LogCollectionStatus(CollectionStatus status) {
} // namespace
PostmortemReportCollector::PostmortemReportCollector(
SystemSessionAnalyzer* analyzer)
metrics::SystemSessionAnalyzer* analyzer)
: report_database_(nullptr), system_session_analyzer_(analyzer) {}
PostmortemReportCollector::PostmortemReportCollector(
const std::string& product_name,
const std::string& version_number,
const std::string& channel_name,
crashpad::CrashReportDatabase* report_database,
SystemSessionAnalyzer* analyzer)
metrics::SystemSessionAnalyzer* analyzer)
: product_name_(product_name),
version_number_(version_number),
channel_name_(channel_name),
......@@ -193,19 +193,19 @@ void PostmortemReportCollector::RecordSystemShutdownState(
} else if (!system_session_analyzer_) {
status = SYSTEM_SESSION_ANALYSIS_NO_ANALYZER;
} else {
SystemSessionAnalyzer::Status analyzer_status =
metrics::SystemSessionAnalyzer::Status analyzer_status =
system_session_analyzer_->IsSessionUnclean(time);
switch (analyzer_status) {
case SystemSessionAnalyzer::FAILED:
case metrics::SystemSessionAnalyzer::FAILED:
status = SYSTEM_SESSION_ANALYSIS_FAILED;
break;
case SystemSessionAnalyzer::CLEAN:
case metrics::SystemSessionAnalyzer::CLEAN:
session_state = SystemState::CLEAN;
break;
case SystemSessionAnalyzer::UNCLEAN:
case metrics::SystemSessionAnalyzer::UNCLEAN:
session_state = SystemState::UNCLEAN;
break;
case SystemSessionAnalyzer::OUTSIDE_RANGE:
case metrics::SystemSessionAnalyzer::OUTSIDE_RANGE:
status = SYSTEM_SESSION_ANALYSIS_OUTSIDE_RANGE;
break;
}
......
......@@ -23,7 +23,7 @@
#include "base/strings/string16.h"
#include "components/browser_watcher/stability_report.pb.h"
#include "components/browser_watcher/stability_report_extractor.h"
#include "components/browser_watcher/system_session_analyzer_win.h"
#include "components/metrics/system_session_analyzer_win.h"
#include "third_party/crashpad/crashpad/client/crash_report_database.h"
namespace browser_watcher {
......@@ -39,12 +39,12 @@ class PostmortemReportCollector {
// crash reports. If |report_database| is set, postmortem crash reports are
// generated and registered against it. If |analyzer| is set, it used to
// analyze the containing system session.
PostmortemReportCollector(SystemSessionAnalyzer* analyzer);
PostmortemReportCollector(metrics::SystemSessionAnalyzer* analyzer);
PostmortemReportCollector(const std::string& product_name,
const std::string& version_number,
const std::string& channel_name,
crashpad::CrashReportDatabase* report_database,
SystemSessionAnalyzer* analyzer);
metrics::SystemSessionAnalyzer* analyzer);
~PostmortemReportCollector();
// Analyzes |stability_files|, logs postmortem user metrics and optionally
......@@ -104,7 +104,7 @@ class PostmortemReportCollector {
std::string channel_name_;
crashpad::CrashReportDatabase* report_database_; // Not owned.
SystemSessionAnalyzer* system_session_analyzer_; // Not owned.
metrics::SystemSessionAnalyzer* system_session_analyzer_; // Not owned.
DISALLOW_COPY_AND_ASSIGN(PostmortemReportCollector);
};
......
......@@ -28,6 +28,7 @@
#include "base/threading/platform_thread.h"
#include "components/browser_watcher/stability_data_names.h"
#include "components/browser_watcher/stability_report_extractor.h"
#include "components/metrics/system_session_analyzer_win.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/crashpad/crashpad/client/crash_report_database.h"
......@@ -119,7 +120,7 @@ class MockPostmortemReportCollector final : public PostmortemReportCollector {
base::PlatformFile minidump_file));
};
class MockSystemSessionAnalyzer : public SystemSessionAnalyzer {
class MockSystemSessionAnalyzer : public metrics::SystemSessionAnalyzer {
public:
MockSystemSessionAnalyzer() : SystemSessionAnalyzer(10U) {}
MOCK_METHOD1(IsSessionUnclean, Status(base::Time timestamp));
......@@ -361,7 +362,7 @@ TEST_F(PostmortemReportCollectorCollectionFromGlobalTrackerTest,
EXPECT_CALL(analyzer,
IsSessionUnclean(base::Time::FromInternalValue(12345LL)))
.Times(1)
.WillOnce(Return(SystemSessionAnalyzer::CLEAN));
.WillOnce(Return(metrics::SystemSessionAnalyzer::CLEAN));
MockCrashReportDatabase crash_db;
PostmortemReportCollector collector(kProductName, kVersionNumber,
kChannelName, &crash_db, &analyzer);
......
......@@ -29,7 +29,7 @@
#include "components/browser_watcher/features.h"
#include "components/browser_watcher/postmortem_report_collector.h"
#include "components/browser_watcher/stability_paths.h"
#include "components/browser_watcher/system_session_analyzer_win.h"
#include "components/metrics/system_session_analyzer_win.h"
#include "third_party/crashpad/crashpad/client/crash_report_database.h"
namespace browser_watcher {
......@@ -285,7 +285,7 @@ void WatcherMetricsProviderWin::CollectPostmortemReportsImpl() {
LogCollectionInitStatus(INIT_SUCCESS);
const size_t kSystemSessionsToInspect = 5U;
SystemSessionAnalyzer analyzer(kSystemSessionsToInspect);
metrics::SystemSessionAnalyzer analyzer(kSystemSessionsToInspect);
if (should_collect) {
base::string16 product_name, version_number, channel_name;
......
......@@ -94,6 +94,8 @@ static_library("metrics") {
"system_memory_stats_recorder.h",
"system_memory_stats_recorder_linux.cc",
"system_memory_stats_recorder_win.cc",
"system_session_analyzer_win.cc",
"system_session_analyzer_win.h",
"url_constants.cc",
"url_constants.h",
"version_utils.cc",
......@@ -132,6 +134,7 @@ static_library("metrics") {
if (is_win) {
sources -= [ "machine_id_provider_stub.cc" ]
deps += [ "//components/browser_watcher:stability_client" ]
libs = [ "wevtapi.lib" ]
}
if (is_fuchsia) {
......@@ -346,6 +349,7 @@ source_set("unit_tests") {
"single_sample_metrics_factory_impl_unittest.cc",
"stability_metrics_helper_unittest.cc",
"stability_metrics_provider_unittest.cc",
"system_session_analyzer_win_unittest.cc",
"ui/screen_info_metrics_provider_unittest.cc",
]
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/browser_watcher/system_session_analyzer_win.h"
#include "components/metrics/system_session_analyzer_win.h"
#include <windows.h>
#include <winevt.h>
......@@ -12,7 +12,7 @@
#include "base/macros.h"
#include "base/time/time.h"
namespace browser_watcher {
namespace metrics {
namespace {
......@@ -241,4 +241,4 @@ bool SystemSessionAnalyzer::Initialize() {
return true;
}
} // namespace browser_watcher
} // namespace metrics
......@@ -12,7 +12,7 @@
#include "base/gtest_prod_util.h"
#include "base/time/time.h"
namespace browser_watcher {
namespace metrics {
// Analyzes system session events for unclean sessions. Initialization is
// expensive and therefore done lazily, as the analyzer is instantiated before
......@@ -38,6 +38,9 @@ class SystemSessionAnalyzer {
virtual ~SystemSessionAnalyzer();
// Returns an analysis status for the system session that contains timestamp.
// TODO(siggi): it'd make more sense to do iterative fetching in this
// function. This will require moving the query handle into the class
// declaration.
virtual Status IsSessionUnclean(base::Time timestamp);
protected:
......@@ -70,6 +73,6 @@ class SystemSessionAnalyzer {
DISALLOW_COPY_AND_ASSIGN(SystemSessionAnalyzer);
};
} // namespace browser_watcher
} // namespace metrics
#endif // COMPONENTS_BROWSER_WATCHER_SYSTEM_SESSION_ANALYZER_WIN_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/browser_watcher/system_session_analyzer_win.h"
#include "components/metrics/system_session_analyzer_win.h"
#include <utility>
#include <vector>
......@@ -11,7 +11,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace browser_watcher {
namespace metrics {
namespace {
......@@ -114,4 +114,4 @@ TEST(SystemSessionAnalyzerTest, IdInversion) {
analyzer.IsSessionUnclean(base::Time::Now()));
}
} // namespace browser_watcher
} // namespace metrics
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