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 BASE_WIN_SCOPED_HANDLE_H_ | 5 #ifndef BASE_WIN_SCOPED_HANDLE_H_ |
6 #define BASE_WIN_SCOPED_HANDLE_H_ | 6 #define BASE_WIN_SCOPED_HANDLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <windows.h> | 9 #include <windows.h> |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 Handle Take() { | 67 Handle Take() { |
68 Handle temp = handle_; | 68 Handle temp = handle_; |
69 handle_ = Traits::NullHandle(); | 69 handle_ = Traits::NullHandle(); |
70 return temp; | 70 return temp; |
71 } | 71 } |
72 | 72 |
73 // Explicitly closes the owned handle. | 73 // Explicitly closes the owned handle. |
74 void Close() { | 74 void Close() { |
75 if (Traits::IsHandleValid(handle_)) { | 75 if (Traits::IsHandleValid(handle_)) { |
76 if (!Traits::CloseHandle(handle_)) { | 76 if (!Traits::CloseHandle(handle_)) { |
77 NOTREACHED(); | 77 CHECK(false); |
78 } | 78 } |
79 handle_ = Traits::NullHandle(); | 79 handle_ = Traits::NullHandle(); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 private: | 83 private: |
84 Handle handle_; | 84 Handle handle_; |
85 | 85 |
86 DISALLOW_COPY_AND_ASSIGN(GenericScopedHandle); | 86 DISALLOW_COPY_AND_ASSIGN(GenericScopedHandle); |
87 }; | 87 }; |
(...skipping 21 matching lines...) Expand all Loading... |
109 private: | 109 private: |
110 DISALLOW_IMPLICIT_CONSTRUCTORS(HandleTraits); | 110 DISALLOW_IMPLICIT_CONSTRUCTORS(HandleTraits); |
111 }; | 111 }; |
112 | 112 |
113 typedef GenericScopedHandle<HandleTraits> ScopedHandle; | 113 typedef GenericScopedHandle<HandleTraits> ScopedHandle; |
114 | 114 |
115 } // namespace win | 115 } // namespace win |
116 } // namespace base | 116 } // namespace base |
117 | 117 |
118 #endif // BASE_SCOPED_HANDLE_WIN_H_ | 118 #endif // BASE_SCOPED_HANDLE_WIN_H_ |
OLD | NEW |