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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_BROWSER_WATCHER_SYSTEM_SESSION_ANALYZER_WIN_H_
6 #define COMPONENTS_BROWSER_WATCHER_SYSTEM_SESSION_ANALYZER_WIN_H_
7
8 #include <map>
9 #include <memory>
10 #include <vector>
11
12 #include "base/time/time.h"
13
14 namespace browser_watcher {
15
16 // Queries system logs for system session events.
17 class SystemSessionEventFetcher {
18 public:
19 // Minimal information about a log event.
20 struct EventInfo {
21 uint16_t event_id;
22 base::Time event_time;
23 };
24
25 // Create a SystemSessionEventFetcher that will query for events pertaining to
26 // the last session_cnt sessions.
27 explicit SystemSessionEventFetcher(size_t session_cnt);
28
29 // Query for events pertaining to the last session_cnt sessions. On success,
30 // returns true and event_infos contains events ordered from newest to oldest.
31 // Returns false otherwise.
32 virtual bool FetchEvents(std::vector<EventInfo>* event_infos) const;
33
34 private:
35 size_t session_cnt_;
36
37 DISALLOW_COPY_AND_ASSIGN(SystemSessionEventFetcher);
38 };
39
40 // Analyzes system session events for unclean sessions.
41 class SystemSessionAnalyzer {
42 public:
43 enum Status {
44 FAILED = 0,
45 CLEAN = 1,
46 UNCLEAN = 2,
47 OUTSIDE_RANGE = 3,
48 };
49
50 explicit SystemSessionAnalyzer(std::unique_ptr<SystemSessionEventFetcher>);
51 virtual ~SystemSessionAnalyzer() = default;
52
53 virtual Status IsSessionUnclean(base::Time timestamp);
Will Harris 2017/02/27 22:40:11 comment?
manzagop (departed) 2017/02/28 14:51:51 Done.
54
55 private:
56 void Initialize();
57
58 std::unique_ptr<SystemSessionEventFetcher> event_fetcher_;
59
60 bool initialized_ = false;
61 bool init_success_ = false;
62
63 // Information about unclean sessions: start time to duration until the next
64 // session start, ie *not* session duration. Note: it's easier to get the
65 // delta to the next session start, and changes nothing wrt classiying
66 // events that occur during sessions assuming query timestamps fall within
67 // system sessions.
68 std::map<base::Time, base::TimeDelta> unclean_sessions_;
69
70 // Timestamp of the oldest event.
71 base::Time coverage_start_;
72
73 DISALLOW_COPY_AND_ASSIGN(SystemSessionAnalyzer);
74 };
75
76 } // namespace browser_watcher
77
78 #endif // COMPONENTS_BROWSER_WATCHER_SYSTEM_SESSION_ANALYZER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698