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

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: Address siggi@ comments 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 // Creates a SystemSessionEventFetcher that will query for events pertaining
26 // to the last session_cnt sessions.
27 explicit SystemSessionEventFetcher(uint32_t session_cnt);
28
29 // Queries 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 uint32_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(SystemSessionEventFetcher* fetcher);
Sigurður Ásgeirsson 2017/03/02 21:52:58 If you (can) rearrange initialization, maybe it ma
manzagop (departed) 2017/03/06 15:37:40 As commented below, using lazy initialization as m
51 virtual ~SystemSessionAnalyzer();
52
53 // Returns an analysis status for the system session that contains timestamp.
54 virtual Status IsSessionUnclean(base::Time timestamp);
Sigurður Ásgeirsson 2017/03/02 21:52:58 looks like initialization here is implicit. Is the
manzagop (departed) 2017/03/06 15:37:40 That's correct: most of the time there will be no
55
56 private:
57 void Initialize();
58
59 SystemSessionEventFetcher* event_fetcher_; // Not owned.
60
61 bool initialized_ = false;
62 bool init_success_ = false;
63
64 // Information about unclean sessions: start time to duration until the next
65 // session start, ie *not* session duration. Note: it's easier to get the
66 // delta to the next session start, and changes nothing wrt classiying
67 // events that occur during sessions assuming query timestamps fall within
68 // system sessions.
69 std::map<base::Time, base::TimeDelta> unclean_sessions_;
70
71 // Timestamp of the oldest event.
72 base::Time coverage_start_;
73
74 DISALLOW_COPY_AND_ASSIGN(SystemSessionAnalyzer);
75 };
76
77 } // namespace browser_watcher
78
79 #endif // COMPONENTS_BROWSER_WATCHER_SYSTEM_SESSION_ANALYZER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698