Roll src/third_party/WebKit f298044:aa8346d (svn 202628:202629)
[chromium-blink-merge.git] / components / browser_watcher / exit_funnel_win.h
blob9af2b388a56d9500511395609651caf624b4f353
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_BROWSER_WATCHER_EXIT_FUNNEL_WIN_H_
6 #define COMPONENTS_BROWSER_WATCHER_EXIT_FUNNEL_WIN_H_
8 #include "base/macros.h"
9 #include "base/process/process_handle.h"
10 #include "base/strings/string16.h"
11 #include "base/time/time.h"
12 #include "base/win/registry.h"
14 namespace browser_watcher {
16 // A wrapper class that takes care of persistently recording a trace of named,
17 // timed events in registry, associated with a process instance. This allows
18 // reconstructing and reporting an event trace on a subsequent launch.
19 // The event trace is stored in registry under a new key named
20 // <pid>-<uniquifier>, where each event is a value named after the event, with
21 // an associated QWORD value noting the event time.
22 class ExitFunnel {
23 public:
24 ExitFunnel();
25 ~ExitFunnel();
27 // Initializes the exit funnel with |registry_path| and |process|.
28 // |process| must be open for PROCESS_QUERY_INFORMATION at least.
29 // Returns false on failure to create or open the registry path corresponding
30 // to |process|.
31 bool Init(const base::char16* registry_path, base::ProcessHandle process);
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);
42 // Records |event_name| at the current time in the registry for the process
43 // this instance is associated with. Returns false on failure to record the
44 // event.
45 bool RecordEvent(const base::char16* event_name);
47 // Records |event_name| at the current time in the registry at |registry_path|
48 // for this process.
49 static bool RecordSingleEvent(const base::char16* registry_path,
50 const base::char16* event_name);
52 private:
53 base::win::RegKey key_;
55 DISALLOW_COPY_AND_ASSIGN(ExitFunnel);
58 } // namespace browser_watcher
60 #endif // COMPONENTS_BROWSER_WATCHER_EXIT_FUNNEL_WIN_H_