| 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 // Declaration of a Windows event trace consumer base class. | 5 // Declaration of a Windows event trace consumer base class. |
| 6 #ifndef BASE_WIN_EVENT_TRACE_CONSUMER_H_ | 6 #ifndef BASE_WIN_EVENT_TRACE_CONSUMER_H_ |
| 7 #define BASE_WIN_EVENT_TRACE_CONSUMER_H_ | 7 #define BASE_WIN_EVENT_TRACE_CONSUMER_H_ |
| 8 | 8 |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 #include <wmistr.h> | 10 #include <wmistr.h> |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 if (reinterpret_cast<TRACEHANDLE>(INVALID_HANDLE_VALUE) == trace_handle) | 112 if (reinterpret_cast<TRACEHANDLE>(INVALID_HANDLE_VALUE) == trace_handle) |
| 113 return HRESULT_FROM_WIN32(::GetLastError()); | 113 return HRESULT_FROM_WIN32(::GetLastError()); |
| 114 | 114 |
| 115 trace_handles_.push_back(trace_handle); | 115 trace_handles_.push_back(trace_handle); |
| 116 return S_OK; | 116 return S_OK; |
| 117 } | 117 } |
| 118 | 118 |
| 119 template <class ImplClass> inline | 119 template <class ImplClass> inline |
| 120 HRESULT EtwTraceConsumerBase<ImplClass>::Consume() { | 120 HRESULT EtwTraceConsumerBase<ImplClass>::Consume() { |
| 121 ULONG err = ::ProcessTrace(&trace_handles_[0], | 121 ULONG err = ::ProcessTrace(&trace_handles_[0], |
| 122 trace_handles_.size(), | 122 static_cast<ULONG>(trace_handles_.size()), |
| 123 NULL, | 123 NULL, |
| 124 NULL); | 124 NULL); |
| 125 return HRESULT_FROM_WIN32(err); | 125 return HRESULT_FROM_WIN32(err); |
| 126 } | 126 } |
| 127 | 127 |
| 128 template <class ImplClass> inline | 128 template <class ImplClass> inline |
| 129 HRESULT EtwTraceConsumerBase<ImplClass>::Close() { | 129 HRESULT EtwTraceConsumerBase<ImplClass>::Close() { |
| 130 HRESULT hr = S_OK; | 130 HRESULT hr = S_OK; |
| 131 for (size_t i = 0; i < trace_handles_.size(); ++i) { | 131 for (size_t i = 0; i < trace_handles_.size(); ++i) { |
| 132 if (NULL != trace_handles_[i]) { | 132 if (NULL != trace_handles_[i]) { |
| 133 ULONG ret = ::CloseTrace(trace_handles_[i]); | 133 ULONG ret = ::CloseTrace(trace_handles_[i]); |
| 134 trace_handles_[i] = NULL; | 134 trace_handles_[i] = NULL; |
| 135 | 135 |
| 136 if (FAILED(HRESULT_FROM_WIN32(ret))) | 136 if (FAILED(HRESULT_FROM_WIN32(ret))) |
| 137 hr = HRESULT_FROM_WIN32(ret); | 137 hr = HRESULT_FROM_WIN32(ret); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 trace_handles_.clear(); | 140 trace_handles_.clear(); |
| 141 | 141 |
| 142 return hr; | 142 return hr; |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace win | 145 } // namespace win |
| 146 } // namespace base | 146 } // namespace base |
| 147 | 147 |
| 148 #endif // BASE_WIN_EVENT_TRACE_CONSUMER_H_ | 148 #endif // BASE_WIN_EVENT_TRACE_CONSUMER_H_ |
| OLD | NEW |