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 return true; | 44 CHECK(false); |
45 | 45 return true; |
46 NOTREACHED(); | |
47 return false; | |
48 } | 46 } |
49 | 47 |
50 // Simple automatic locking using a native critical section so it supports | 48 // Simple automatic locking using a native critical section so it supports |
51 // recursive locking. | 49 // recursive locking. |
52 class AutoNativeLock { | 50 class AutoNativeLock { |
53 public: | 51 public: |
54 explicit AutoNativeLock(NativeLock& lock) : lock_(lock) { | 52 explicit AutoNativeLock(NativeLock& lock) : lock_(lock) { |
55 lock_.Lock(); | 53 lock_.Lock(); |
56 } | 54 } |
57 | 55 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 void DisableHandleVerifier() { | 237 void DisableHandleVerifier() { |
240 return ActiveVerifier::Get()->Disable(); | 238 return ActiveVerifier::Get()->Disable(); |
241 } | 239 } |
242 | 240 |
243 void OnHandleBeingClosed(HANDLE handle) { | 241 void OnHandleBeingClosed(HANDLE handle) { |
244 return ActiveVerifier::Get()->OnHandleBeingClosed(handle); | 242 return ActiveVerifier::Get()->OnHandleBeingClosed(handle); |
245 } | 243 } |
246 | 244 |
247 } // namespace win | 245 } // namespace win |
248 } // namespace base | 246 } // namespace base |
OLD | NEW |