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

Side by Side Diff: chrome/test/logging/win/file_logger.h

Issue 9702021: Unconditionally send Chrome and Chrome Frame events through ETW machinery. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/common/logging_chrome.cc ('k') | chrome/test/logging/win/file_logger.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 CHROME_TEST_LOGGING_WIN_FILE_LOGGER_H_ 5 #ifndef CHROME_TEST_LOGGING_WIN_FILE_LOGGER_H_
6 #define CHROME_TEST_LOGGING_WIN_FILE_LOGGER_H_ 6 #define CHROME_TEST_LOGGING_WIN_FILE_LOGGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <guiddef.h> 9 #include <guiddef.h>
10 10
(...skipping 11 matching lines...) Expand all
22 // pulled from the file sometime later with PrintLogFile or ReadLogFile 22 // pulled from the file sometime later with PrintLogFile or ReadLogFile
23 // (currently in log_file_printer_win.h and log_file_reader_win.h, 23 // (currently in log_file_printer_win.h and log_file_reader_win.h,
24 // respectively). 24 // respectively).
25 // 25 //
26 // Important usage notes (read this): 26 // Important usage notes (read this):
27 // - Due to the nature of event generation, only one instance of this class may 27 // - Due to the nature of event generation, only one instance of this class may
28 // be initialized at a time. 28 // be initialized at a time.
29 // - This class is not thread safe. 29 // - This class is not thread safe.
30 // - This class uses facilities that require the process to run with admin 30 // - This class uses facilities that require the process to run with admin
31 // rights; StartLogging() will return false if this is not the case. 31 // rights; StartLogging() will return false if this is not the case.
32 //
33 // Initializing an instance will add the variable CHROME_ETW_LOGGING=1 to the
34 // system-wide environment if it is not present. In the case where it is not
35 // already present, log messages will not be captured from currently running
36 // instances of Chrome, Chrome Frame, or other providers that generate events
37 // conditionally based on that environment variable.
38 class FileLogger { 32 class FileLogger {
39 public: 33 public:
40 enum EventProviderBits { 34 enum EventProviderBits {
41 // Log messages from chrome.exe. 35 // Log messages from chrome.exe.
42 CHROME_LOG_PROVIDER = 1 << 0, 36 CHROME_LOG_PROVIDER = 1 << 0,
43 // Log messages from npchrome_frame.dll. 37 // Log messages from npchrome_frame.dll.
44 CHROME_FRAME_LOG_PROVIDER = 1 << 1, 38 CHROME_FRAME_LOG_PROVIDER = 1 << 1,
45 // Log messages from the current process. 39 // Log messages from the current process.
46 CHROME_TESTS_LOG_PROVIDER = 1 << 2, 40 CHROME_TESTS_LOG_PROVIDER = 1 << 2,
47 // Trace events. 41 // Trace events.
(...skipping 23 matching lines...) Expand all
71 65
72 // Stops capturing logs. 66 // Stops capturing logs.
73 void StopLogging(); 67 void StopLogging();
74 68
75 // Returns true if logs are being captured. 69 // Returns true if logs are being captured.
76 bool is_logging() const { 70 bool is_logging() const {
77 return controller_.session_name() && *controller_.session_name(); 71 return controller_.session_name() && *controller_.session_name();
78 } 72 }
79 73
80 private: 74 private:
81 // A helper for setting/clearing a variable in the system-wide environment.
82 class ScopedSystemEnvironmentVariable {
83 public:
84 ScopedSystemEnvironmentVariable(const string16& variable,
85 const string16& value);
86 ~ScopedSystemEnvironmentVariable();
87
88 private:
89 static void NotifyOtherProcesses();
90
91 // Non-empty if the variable was inserted into the system-wide environment.
92 string16 variable_;
93 DISALLOW_COPY_AND_ASSIGN(ScopedSystemEnvironmentVariable);
94 };
95
96 bool EnableProviders(); 75 bool EnableProviders();
97 void DisableProviders(); 76 void DisableProviders();
98 77
99 void ConfigureChromeEtwLogging();
100 void RevertChromeEtwLogging();
101
102 static bool is_initialized_; 78 static bool is_initialized_;
103 79
104 scoped_ptr<ScopedSystemEnvironmentVariable> etw_logging_configurator_;
105 base::win::EtwTraceController controller_; 80 base::win::EtwTraceController controller_;
106 uint32 event_provider_mask_; 81 uint32 event_provider_mask_;
107 82
108 DISALLOW_COPY_AND_ASSIGN(FileLogger); 83 DISALLOW_COPY_AND_ASSIGN(FileLogger);
109 }; 84 };
110 85
111 } // namespace logging_win 86 } // namespace logging_win
112 87
113 #endif // CHROME_TEST_LOGGING_WIN_FILE_LOGGER_H_ 88 #endif // CHROME_TEST_LOGGING_WIN_FILE_LOGGER_H_
OLDNEW
« no previous file with comments | « chrome/common/logging_chrome.cc ('k') | chrome/test/logging/win/file_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698