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

Side by Side Diff: components/browser_watcher/exit_funnel_win.h

Issue 811483006: Don't report exit funnels for live processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_BROWSER_WATCHER_EXIT_FUNNEL_WIN_H_ 5 #ifndef COMPONENTS_BROWSER_WATCHER_EXIT_FUNNEL_WIN_H_
6 #define COMPONENTS_BROWSER_WATCHER_EXIT_FUNNEL_WIN_H_ 6 #define COMPONENTS_BROWSER_WATCHER_EXIT_FUNNEL_WIN_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/process/process_handle.h" 9 #include "base/process/process_handle.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
11 #include "base/time/time.h"
11 #include "base/win/registry.h" 12 #include "base/win/registry.h"
12 13
13 namespace browser_watcher { 14 namespace browser_watcher {
14 15
15 // A wrapper class that takes care of persistently recording a trace of named, 16 // A wrapper class that takes care of persistently recording a trace of named,
16 // timed events in registry, associated with a process instance. This allows 17 // timed events in registry, associated with a process instance. This allows
17 // reconstructing and reporting an event trace on a subsequent launch. 18 // reconstructing and reporting an event trace on a subsequent launch.
18 // The event trace is stored in registry under a new key named 19 // The event trace is stored in registry under a new key named
19 // <pid>-<uniquifier>, where each event is a value named after the event, with 20 // <pid>-<uniquifier>, where each event is a value named after the event, with
20 // an associated QWORD value noting the event time. 21 // an associated QWORD value noting the event time.
21 class ExitFunnel { 22 class ExitFunnel {
22 public: 23 public:
23 ExitFunnel(); 24 ExitFunnel();
24 ~ExitFunnel(); 25 ~ExitFunnel();
25 26
26 // Initializes the exit funnel with |registry_path| and |process|. 27 // Initializes the exit funnel with |registry_path| and |process|.
27 // |process| must be open for PROCESS_QUERY_INFORMATION at least. 28 // |process| must be open for PROCESS_QUERY_INFORMATION at least.
28 // Returns false on failure to create or open the registry path corresponding 29 // Returns false on failure to create or open the registry path corresponding
29 // to |process|. 30 // to |process|.
30 bool Init(const base::char16* registry_path, base::ProcessHandle process); 31 bool Init(const base::char16* registry_path, base::ProcessHandle process);
31 32
33 // Initializes the exit funnel with |registry_path|, |pid| and
34 // |creation_time|.
35 // Returns false on failure to create or open the registry path corresponding
36 // to |process|.
37 // Exposed for testing.
38 bool InitImpl(const base::char16* registry_path,
39 base::ProcessId pid,
40 base::Time creation_time);
41
32 // Records |event_name| at the current time in the registry for the process 42 // Records |event_name| at the current time in the registry for the process
33 // this instance is associated with. Returns false on failure to record the 43 // this instance is associated with. Returns false on failure to record the
34 // event. 44 // event.
35 bool RecordEvent(const base::char16* event_name); 45 bool RecordEvent(const base::char16* event_name);
36 46
37 // Records |event_name| at the current time in the registry at |registry_path| 47 // Records |event_name| at the current time in the registry at |registry_path|
38 // for this process. 48 // for this process.
39 static bool RecordSingleEvent(const base::char16* registry_path, 49 static bool RecordSingleEvent(const base::char16* registry_path,
40 const base::char16* event_name); 50 const base::char16* event_name);
41 51
42 private: 52 private:
43 base::win::RegKey key_; 53 base::win::RegKey key_;
44 54
45 DISALLOW_COPY_AND_ASSIGN(ExitFunnel); 55 DISALLOW_COPY_AND_ASSIGN(ExitFunnel);
46 }; 56 };
47 57
48 } // namespace browser_watcher 58 } // namespace browser_watcher
49 59
50 #endif // COMPONENTS_BROWSER_WATCHER_EXIT_FUNNEL_WIN_H_ 60 #endif // COMPONENTS_BROWSER_WATCHER_EXIT_FUNNEL_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698