| 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 #include "chrome/test/logging/win/file_logger.h" | 5 #include "chrome/test/logging/win/file_logger.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <guiddef.h> | 8 #include <guiddef.h> |
| 9 #include <objbase.h> | 9 #include <objbase.h> |
| 10 #include <stddef.h> |
| 10 | 11 |
| 11 #include <ios> | 12 #include <ios> |
| 12 | 13 |
| 13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "base/logging_win.h" | 16 #include "base/logging_win.h" |
| 17 #include "base/macros.h" |
| 16 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/win/event_trace_consumer.h" | 20 #include "base/win/event_trace_consumer.h" |
| 19 #include "base/win/registry.h" | 21 #include "base/win/registry.h" |
| 20 | 22 |
| 21 namespace logging_win { | 23 namespace logging_win { |
| 22 | 24 |
| 23 namespace { | 25 namespace { |
| 24 | 26 |
| 25 const wchar_t kChromeTestSession[] = L"chrome_tests"; | 27 const wchar_t kChromeTestSession[] = L"chrome_tests"; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 | 38 |
| 37 // {81729947-CD2A-49e6-8885-785429F339F5} | 39 // {81729947-CD2A-49e6-8885-785429F339F5} |
| 38 const GUID kChromeTestsProvider = | 40 const GUID kChromeTestsProvider = |
| 39 { 0x81729947, 0xcd2a, 0x49e6, | 41 { 0x81729947, 0xcd2a, 0x49e6, |
| 40 { 0x88, 0x85, 0x78, 0x54, 0x29, 0xf3, 0x39, 0xf5 } }; | 42 { 0x88, 0x85, 0x78, 0x54, 0x29, 0xf3, 0x39, 0xf5 } }; |
| 41 | 43 |
| 42 // The configurations for the supported providers. This must be in sync with | 44 // The configurations for the supported providers. This must be in sync with |
| 43 // FileLogger::EventProviderBits. | 45 // FileLogger::EventProviderBits. |
| 44 const struct { | 46 const struct { |
| 45 const GUID* provider_name; | 47 const GUID* provider_name; |
| 46 uint8 level; | 48 uint8_t level; |
| 47 uint32 flags; | 49 uint32_t flags; |
| 48 } kProviders[] = { | 50 } kProviders[] = { |
| 49 { &kChromeTraceProviderName, 255, 0 }, | 51 { &kChromeTraceProviderName, 255, 0 }, |
| 50 { &kChromeFrameProvider, 255, 0 }, | 52 { &kChromeFrameProvider, 255, 0 }, |
| 51 { &kChromeTestsProvider, 255, 0 }, | 53 { &kChromeTestsProvider, 255, 0 }, |
| 52 }; | 54 }; |
| 53 | 55 |
| 54 static_assert((1 << arraysize(kProviders)) - 1 == | 56 static_assert((1 << arraysize(kProviders)) - 1 == |
| 55 FileLogger::kAllEventProviders, | 57 FileLogger::kAllEventProviders, |
| 56 "size of kProviders is inconsistent with kAllEventProviders"); | 58 "size of kProviders is inconsistent with kAllEventProviders"); |
| 57 | 59 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 123 } |
| 122 | 124 |
| 123 if (event_provider_mask_ & CHROME_TESTS_LOG_PROVIDER) | 125 if (event_provider_mask_ & CHROME_TESTS_LOG_PROVIDER) |
| 124 logging::LogEventProvider::Uninitialize(); | 126 logging::LogEventProvider::Uninitialize(); |
| 125 } | 127 } |
| 126 | 128 |
| 127 void FileLogger::Initialize() { | 129 void FileLogger::Initialize() { |
| 128 Initialize(kAllEventProviders); | 130 Initialize(kAllEventProviders); |
| 129 } | 131 } |
| 130 | 132 |
| 131 void FileLogger::Initialize(uint32 event_provider_mask) { | 133 void FileLogger::Initialize(uint32_t event_provider_mask) { |
| 132 CHECK(!is_initialized_); | 134 CHECK(!is_initialized_); |
| 133 | 135 |
| 134 // Stop a previous session that wasn't shut down properly. | 136 // Stop a previous session that wasn't shut down properly. |
| 135 base::win::EtwTraceProperties ignore; | 137 base::win::EtwTraceProperties ignore; |
| 136 HRESULT hr = base::win::EtwTraceController::Stop(kChromeTestSession, | 138 HRESULT hr = base::win::EtwTraceController::Stop(kChromeTestSession, |
| 137 &ignore); | 139 &ignore); |
| 138 LOG_IF(ERROR, FAILED(hr) && | 140 LOG_IF(ERROR, FAILED(hr) && |
| 139 hr != HRESULT_FROM_WIN32(ERROR_WMI_INSTANCE_NOT_FOUND)) | 141 hr != HRESULT_FROM_WIN32(ERROR_WMI_INSTANCE_NOT_FOUND)) |
| 140 << "Failed to stop a previous trace session; hr=" << std::hex << hr; | 142 << "Failed to stop a previous trace session; hr=" << std::hex << hr; |
| 141 | 143 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 178 |
| 177 hr = controller_.Flush(NULL); | 179 hr = controller_.Flush(NULL); |
| 178 LOG_IF(ERROR, FAILED(hr)) | 180 LOG_IF(ERROR, FAILED(hr)) |
| 179 << "Failed to flush events; hr=" << std::hex << hr; | 181 << "Failed to flush events; hr=" << std::hex << hr; |
| 180 hr = controller_.Stop(NULL); | 182 hr = controller_.Stop(NULL); |
| 181 LOG_IF(ERROR, FAILED(hr)) | 183 LOG_IF(ERROR, FAILED(hr)) |
| 182 << "Failed to stop ETW session; hr=" << std::hex << hr; | 184 << "Failed to stop ETW session; hr=" << std::hex << hr; |
| 183 } | 185 } |
| 184 | 186 |
| 185 } // namespace logging_win | 187 } // namespace logging_win |
| OLD | NEW |