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

Side by Side Diff: chrome/test/base/file_logger_win.h

Issue 9584017: New test infrastructure for producing verbose logs in failing tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: decoupled parsing and printing, extracted mof parser, simplified all around Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/base/file_logger_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 CHROME_TEST_BASE_FILE_LOGGER_WIN_H_
6 #define CHROME_TEST_BASE_FILE_LOGGER_WIN_H_
7 #pragma once
8
9 #include <guiddef.h>
10
11 #include "base/basictypes.h"
12 #include "base/win/event_trace_controller.h"
13
14 class FilePath;
15
16 // A file logger instance captures LOG messages and trace events emitted via
17 // Event Tracing for Windows (ETW) and sends them to a file. The contents of
18 // such a file can be sent to an output stream sometime later.
19 //
20 // Important usage notes (read this):
21 // - Due to the nature of event generation, only one instance of this class may
22 // be initialized at a time, and only one file may be dumped at a time.
grt (UTC plus 2) 2012/03/08 21:37:06 oops, i need to remove reference to dumping here.
23 // - This class is not thread safe.
24 // - This class uses facilities that require the process to run with admin
25 // rights; StartLogging() will return false if this is not the case.
26 //
27 // Initializing an instance will add the variable CHROME_ETW_LOGGING=1 to the
28 // system-wide environment if it is not present. In the case where it is not
29 // already present, log messages will not be captured from currently running
30 // instances of Chrome, Chrome Frame, or other providers that generate events
31 // conditionally based on that environment variable.
32 class FileLogger {
33 public:
34 enum EventProviderBits {
35 // Log messages from chrome.exe.
36 CHROME_LOG_PROVIDER = 1 << 0,
37 // Log messages from npchrome_frame.dll.
38 CHROME_FRAME_LOG_PROVIDER = 1 << 1,
39 // Log messages from the current process.
40 CHROME_TESTS_LOG_PROVIDER = 1 << 2,
41 // Trace events.
42 CHROME_TRACE_EVENT_PROVIDER = 1 << 3,
43 };
44
45 static const uint32 kAllEventProviders = (CHROME_LOG_PROVIDER |
46 CHROME_FRAME_LOG_PROVIDER |
47 CHROME_TESTS_LOG_PROVIDER |
48 CHROME_TRACE_EVENT_PROVIDER);
49
50 FileLogger();
51 ~FileLogger();
52
53 // Initializes the instance to collect logs from all supported providers.
54 void Initialize();
55
56 // Initializes the instance to collect logs from the providers present in
57 // the given mask; see EventProviderBits.
58 void Initialize(uint32 event_provider_mask);
59
60 // Removes the system-wide CHROME_ETW_LOGGING=1 variable from the environment
61 // if it was inserted in Initialize().
62 void Uninitialize();
63
64 // Starts capturing logs from all providers into |log_file|. The common file
65 // extension for such files is .etl. Returns false if the session could not
66 // be started (e.g., if not running as admin).
67 bool StartLogging(const FilePath& log_file);
68
69 // Stops capturing logs.
70 void StopLogging();
71
72 // Returns true if logs are being captured.
73 bool is_logging() const {
74 return controller_.session_name() && *controller_.session_name();
75 }
76
77 private:
78 bool EnableProviders();
79 void DisableProviders();
80
81 void ConfigureChromeEtwLogging();
82 void RevertChromeEtwLogging();
83
84 base::win::EtwTraceController controller_;
85 uint32 event_provider_mask_;
86
87 // True if the system-wide variable CHROME_ETW_LOGGING=1 was inserted into the
88 // environment.
89 bool added_chrome_etw_variable_;
90
91 DISALLOW_COPY_AND_ASSIGN(FileLogger);
92 };
93
94 #endif // CHROME_TEST_BASE_FILE_LOGGER_WIN_H_
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/base/file_logger_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698