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

Unified Diff: components/browser_watcher/system_session_analyzer_win.h

Issue 2715903003: Bound the impact of system instability on chrome instability. (Closed)
Patch Set: record start timestamp, analysis metric, make log scrape lazy Created 3 years, 10 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: components/browser_watcher/system_session_analyzer_win.h
diff --git a/components/browser_watcher/system_session_analyzer_win.h b/components/browser_watcher/system_session_analyzer_win.h
new file mode 100644
index 0000000000000000000000000000000000000000..e3a24a66a8bd1c7c42137b58b1424d455a38d9a3
--- /dev/null
+++ b/components/browser_watcher/system_session_analyzer_win.h
@@ -0,0 +1,78 @@
+// 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.
+
+#ifndef COMPONENTS_BROWSER_WATCHER_SYSTEM_SESSION_ANALYZER_WIN_H_
+#define COMPONENTS_BROWSER_WATCHER_SYSTEM_SESSION_ANALYZER_WIN_H_
+
+#include <map>
+#include <memory>
+#include <vector>
+
+#include "base/time/time.h"
+
+namespace browser_watcher {
+
+// Queries system logs for system session events.
+class SystemSessionEventFetcher {
+ public:
+ // Minimal information about a log event.
+ struct EventInfo {
+ uint16_t event_id;
+ base::Time event_time;
+ };
+
+ // Create a SystemSessionEventFetcher that will query for events pertaining to
+ // the last session_cnt sessions.
+ explicit SystemSessionEventFetcher(size_t session_cnt);
+
+ // Query for events pertaining to the last session_cnt sessions. On success,
+ // returns true and event_infos contains events ordered from newest to oldest.
+ // Returns false otherwise.
+ virtual bool FetchEvents(std::vector<EventInfo>* event_infos) const;
+
+ private:
+ size_t session_cnt_;
+
+ DISALLOW_COPY_AND_ASSIGN(SystemSessionEventFetcher);
+};
+
+// Analyzes system session events for unclean sessions.
+class SystemSessionAnalyzer {
+ public:
+ enum Status {
+ FAILED = 0,
+ CLEAN = 1,
+ UNCLEAN = 2,
+ OUTSIDE_RANGE = 3,
+ };
+
+ explicit SystemSessionAnalyzer(std::unique_ptr<SystemSessionEventFetcher>);
+ virtual ~SystemSessionAnalyzer() = default;
+
+ virtual Status IsSessionUnclean(base::Time timestamp);
Will Harris 2017/02/27 22:40:11 comment?
manzagop (departed) 2017/02/28 14:51:51 Done.
+
+ private:
+ void Initialize();
+
+ std::unique_ptr<SystemSessionEventFetcher> event_fetcher_;
+
+ bool initialized_ = false;
+ bool init_success_ = false;
+
+ // Information about unclean sessions: start time to duration until the next
+ // session start, ie *not* session duration. Note: it's easier to get the
+ // delta to the next session start, and changes nothing wrt classiying
+ // events that occur during sessions assuming query timestamps fall within
+ // system sessions.
+ std::map<base::Time, base::TimeDelta> unclean_sessions_;
+
+ // Timestamp of the oldest event.
+ base::Time coverage_start_;
+
+ DISALLOW_COPY_AND_ASSIGN(SystemSessionAnalyzer);
+};
+
+} // namespace browser_watcher
+
+#endif // COMPONENTS_BROWSER_WATCHER_SYSTEM_SESSION_ANALYZER_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698