| OLD | NEW |
| 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 | 7 |
| 8 #include <guiddef.h> | 8 #include <guiddef.h> |
| 9 #include <stdint.h> |
| 9 | 10 |
| 10 #include "base/basictypes.h" | 11 #include "base/macros.h" |
| 11 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 12 #include "base/win/event_trace_controller.h" | 13 #include "base/win/event_trace_controller.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 class FilePath; | 16 class FilePath; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace logging_win { | 19 namespace logging_win { |
| 19 | 20 |
| 20 // A file logger instance captures LOG messages and trace events emitted via | 21 // A file logger instance captures LOG messages and trace events emitted via |
| (...skipping 12 matching lines...) Expand all Loading... |
| 33 public: | 34 public: |
| 34 enum EventProviderBits { | 35 enum EventProviderBits { |
| 35 // Log messages from chrome.exe. | 36 // Log messages from chrome.exe. |
| 36 CHROME_LOG_PROVIDER = 1 << 0, | 37 CHROME_LOG_PROVIDER = 1 << 0, |
| 37 // Log messages from npchrome_frame.dll. | 38 // Log messages from npchrome_frame.dll. |
| 38 CHROME_FRAME_LOG_PROVIDER = 1 << 1, | 39 CHROME_FRAME_LOG_PROVIDER = 1 << 1, |
| 39 // Log messages from the current process. | 40 // Log messages from the current process. |
| 40 CHROME_TESTS_LOG_PROVIDER = 1 << 2, | 41 CHROME_TESTS_LOG_PROVIDER = 1 << 2, |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 static const uint32 kAllEventProviders = (CHROME_LOG_PROVIDER | | 44 static const uint32_t kAllEventProviders = |
| 44 CHROME_FRAME_LOG_PROVIDER | | 45 (CHROME_LOG_PROVIDER | CHROME_FRAME_LOG_PROVIDER | |
| 45 CHROME_TESTS_LOG_PROVIDER); | 46 CHROME_TESTS_LOG_PROVIDER); |
| 46 | 47 |
| 47 FileLogger(); | 48 FileLogger(); |
| 48 ~FileLogger(); | 49 ~FileLogger(); |
| 49 | 50 |
| 50 // Initializes the instance to collect logs from all supported providers. | 51 // Initializes the instance to collect logs from all supported providers. |
| 51 void Initialize(); | 52 void Initialize(); |
| 52 | 53 |
| 53 // Initializes the instance to collect logs from the providers present in | 54 // Initializes the instance to collect logs from the providers present in |
| 54 // the given mask; see EventProviderBits. | 55 // the given mask; see EventProviderBits. |
| 55 void Initialize(uint32 event_provider_mask); | 56 void Initialize(uint32_t event_provider_mask); |
| 56 | 57 |
| 57 // Starts capturing logs from all providers into |log_file|. The common file | 58 // Starts capturing logs from all providers into |log_file|. The common file |
| 58 // extension for such files is .etl. Returns false if the session could not | 59 // extension for such files is .etl. Returns false if the session could not |
| 59 // be started (e.g., if not running as admin) or if no providers could be | 60 // be started (e.g., if not running as admin) or if no providers could be |
| 60 // enabled. | 61 // enabled. |
| 61 bool StartLogging(const base::FilePath& log_file); | 62 bool StartLogging(const base::FilePath& log_file); |
| 62 | 63 |
| 63 // Stops capturing logs. | 64 // Stops capturing logs. |
| 64 void StopLogging(); | 65 void StopLogging(); |
| 65 | 66 |
| 66 // Returns true if logs are being captured. | 67 // Returns true if logs are being captured. |
| 67 bool is_logging() const { | 68 bool is_logging() const { |
| 68 return controller_.session_name() && *controller_.session_name(); | 69 return controller_.session_name() && *controller_.session_name(); |
| 69 } | 70 } |
| 70 | 71 |
| 71 private: | 72 private: |
| 72 bool EnableProviders(); | 73 bool EnableProviders(); |
| 73 void DisableProviders(); | 74 void DisableProviders(); |
| 74 | 75 |
| 75 static bool is_initialized_; | 76 static bool is_initialized_; |
| 76 | 77 |
| 77 base::win::EtwTraceController controller_; | 78 base::win::EtwTraceController controller_; |
| 78 uint32 event_provider_mask_; | 79 uint32_t event_provider_mask_; |
| 79 | 80 |
| 80 DISALLOW_COPY_AND_ASSIGN(FileLogger); | 81 DISALLOW_COPY_AND_ASSIGN(FileLogger); |
| 81 }; | 82 }; |
| 82 | 83 |
| 83 } // namespace logging_win | 84 } // namespace logging_win |
| 84 | 85 |
| 85 #endif // CHROME_TEST_LOGGING_WIN_FILE_LOGGER_H_ | 86 #endif // CHROME_TEST_LOGGING_WIN_FILE_LOGGER_H_ |
| OLD | NEW |