| 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 REMOTING_BASE_SCOPED_SC_HANDLE_WIN_H_ | 5 #ifndef REMOTING_BASE_SCOPED_SC_HANDLE_WIN_H_ |
| 6 #define REMOTING_BASE_SCOPED_SC_HANDLE_WIN_H_ | 6 #define REMOTING_BASE_SCOPED_SC_HANDLE_WIN_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include "base/win/scoped_handle.h" | 10 #include "base/win/scoped_handle.h" |
| 11 | 11 |
| 12 namespace remoting { | 12 namespace remoting { |
| 13 | 13 |
| 14 class ScHandleTraits { | 14 class ScHandleTraits { |
| 15 public: | 15 public: |
| 16 typedef SC_HANDLE Handle; | 16 typedef SC_HANDLE Handle; |
| 17 | 17 |
| 18 // Closes the handle. | 18 // Closes the handle. |
| 19 static bool CloseHandle(SC_HANDLE handle) { | 19 static bool CloseHandle(SC_HANDLE handle) { |
| 20 return ::CloseServiceHandle(handle) != FALSE; | 20 return ::CloseServiceHandle(handle) != FALSE; |
| 21 } | 21 } |
| 22 | 22 |
| 23 // Returns true if the handle value is valid. | 23 // Returns true if the handle value is valid. |
| 24 static bool IsHandleValid(SC_HANDLE handle) { | 24 static bool IsHandleValid(SC_HANDLE handle) { |
| 25 return handle != NULL; | 25 return handle != NULL; |
| 26 } | 26 } |
| 27 | 27 |
| 28 // Returns true if the handles are the same. |
| 29 static bool IsSame(SC_HANDLE lhs, SC_HANDLE rhs) { |
| 30 return lhs == rhs; |
| 31 } |
| 32 |
| 28 // Returns NULL handle value. | 33 // Returns NULL handle value. |
| 29 static SC_HANDLE NullHandle() { | 34 static SC_HANDLE NullHandle() { |
| 30 return NULL; | 35 return NULL; |
| 31 } | 36 } |
| 32 | 37 |
| 33 private: | 38 private: |
| 34 DISALLOW_IMPLICIT_CONSTRUCTORS(ScHandleTraits); | 39 DISALLOW_IMPLICIT_CONSTRUCTORS(ScHandleTraits); |
| 35 }; | 40 }; |
| 36 | 41 |
| 37 typedef base::win::GenericScopedHandle<ScHandleTraits> ScopedScHandle; | 42 typedef base::win::GenericScopedHandle<ScHandleTraits> ScopedScHandle; |
| 38 | 43 |
| 39 } // namespace remoting | 44 } // namespace remoting |
| 40 | 45 |
| 41 #endif // REMOTING_BASE_SCOPED_SC_HANDLE_WIN_H_ | 46 #endif // REMOTING_BASE_SCOPED_SC_HANDLE_WIN_H_ |
| OLD | NEW |