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 "base/win/scoped_handle.h" | 5 #include "base/win/scoped_handle.h" |
6 | 6 |
7 #include <unordered_map> | 7 #include <unordered_map> |
8 | 8 |
9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
10 #include "base/hash.h" | 10 #include "base/hash.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 const void* pc2; | 33 const void* pc2; |
34 DWORD thread_id; | 34 DWORD thread_id; |
35 }; | 35 }; |
36 typedef std::unordered_map<HANDLE, Info, HandleHash> HandleMap; | 36 typedef std::unordered_map<HANDLE, Info, HandleHash> HandleMap; |
37 | 37 |
38 // g_lock protects the handle map and setting g_active_verifier. | 38 // g_lock protects the handle map and setting g_active_verifier. |
39 typedef base::internal::LockImpl NativeLock; | 39 typedef base::internal::LockImpl NativeLock; |
40 base::LazyInstance<NativeLock>::Leaky g_lock = LAZY_INSTANCE_INITIALIZER; | 40 base::LazyInstance<NativeLock>::Leaky g_lock = LAZY_INSTANCE_INITIALIZER; |
41 | 41 |
42 bool CloseHandleWrapper(HANDLE handle) { | 42 bool CloseHandleWrapper(HANDLE handle) { |
43 if (!::CloseHandle(handle)) | 43 if (::CloseHandle(handle)) |
44 CHECK(false); | 44 return true; |
45 return true; | 45 |
| 46 NOTREACHED(); |
| 47 return false; |
46 } | 48 } |
47 | 49 |
48 // Simple automatic locking using a native critical section so it supports | 50 // Simple automatic locking using a native critical section so it supports |
49 // recursive locking. | 51 // recursive locking. |
50 class AutoNativeLock { | 52 class AutoNativeLock { |
51 public: | 53 public: |
52 explicit AutoNativeLock(NativeLock& lock) : lock_(lock) { | 54 explicit AutoNativeLock(NativeLock& lock) : lock_(lock) { |
53 lock_.Lock(); | 55 lock_.Lock(); |
54 } | 56 } |
55 | 57 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 void DisableHandleVerifier() { | 239 void DisableHandleVerifier() { |
238 return ActiveVerifier::Get()->Disable(); | 240 return ActiveVerifier::Get()->Disable(); |
239 } | 241 } |
240 | 242 |
241 void OnHandleBeingClosed(HANDLE handle) { | 243 void OnHandleBeingClosed(HANDLE handle) { |
242 return ActiveVerifier::Get()->OnHandleBeingClosed(handle); | 244 return ActiveVerifier::Get()->OnHandleBeingClosed(handle); |
243 } | 245 } |
244 | 246 |
245 } // namespace win | 247 } // namespace win |
246 } // namespace base | 248 } // namespace base |
OLD | NEW |