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

Unified Diff: components/browser_watcher/fetch_system_session_events_main_win.cc

Issue 2715903003: Bound the impact of system instability on chrome instability. (Closed)
Patch Set: Merge fixups Created 3 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 | « components/browser_watcher/BUILD.gn ('k') | components/browser_watcher/postmortem_report_collector.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/browser_watcher/fetch_system_session_events_main_win.cc
diff --git a/components/browser_watcher/fetch_system_session_events_main_win.cc b/components/browser_watcher/fetch_system_session_events_main_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2f17b9333c70195cb40705a803572bec2ce34ca1
--- /dev/null
+++ b/components/browser_watcher/fetch_system_session_events_main_win.cc
@@ -0,0 +1,48 @@
+// Copyright 2017 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.
+
+// A utility for testing locally the retrieval of system session events.
+
+#include <iostream>
+
+#include "base/logging.h"
+#include "base/strings/stringprintf.h"
+#include "base/time/time.h"
+#include "components/browser_watcher/system_session_analyzer_win.h"
+
+namespace {
+
+using browser_watcher::SystemSessionAnalyzer;
+
+class SystemSessionEventFetcher : public SystemSessionAnalyzer {
+ public:
+ explicit SystemSessionEventFetcher(uint32_t session_cnt)
+ : SystemSessionAnalyzer(session_cnt) {}
+ using SystemSessionAnalyzer::FetchEvents;
+};
+
+} // namespace
+
+int main(int argc, char** argv) {
+ // Retrieve events for the last 5 sessions.
+ SystemSessionEventFetcher fetcher(5U);
+ std::vector<SystemSessionEventFetcher::EventInfo> events;
+ if (!fetcher.FetchEvents(&events)) {
+ std::cerr << "Failed to fetch events." << std::endl;
+ return 1;
+ }
+
+ // Print the event ids and times.
+ for (const SystemSessionEventFetcher::EventInfo& event : events) {
+ base::Time::Exploded exploded = {};
+ event.event_time.LocalExplode(&exploded);
+ std::string time = base::StringPrintf(
+ "%d/%d/%d %d:%02d:%02d", exploded.month, exploded.day_of_month,
+ exploded.year, exploded.hour, exploded.minute, exploded.second);
+ std::cout << "Event: " << event.event_id << " (" << time << ")"
+ << std::endl;
+ }
+
+ return 0;
+}
« no previous file with comments | « components/browser_watcher/BUILD.gn ('k') | components/browser_watcher/postmortem_report_collector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698