Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: base/win/scoped_handle.h

Issue 9150030: Initialize IPC:ChannelHandle from existing HANDLE (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed build error Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ipc/ipc_channel_handle.h » ('j') | ipc/ipc_channel_handle.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
cpu_(ooo_6.6-7.5) 2012/01/19 20:56:05 2012
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
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 51
52 void Set(HANDLE new_handle) { 52 void Set(HANDLE new_handle) {
53 Close(); 53 Close();
54 54
55 // Windows is inconsistent about invalid handles, so we always use NULL 55 // Windows is inconsistent about invalid handles, so we always use NULL
56 if (new_handle != INVALID_HANDLE_VALUE) 56 if (new_handle != INVALID_HANDLE_VALUE)
57 handle_ = new_handle; 57 handle_ = new_handle;
58 } 58 }
59 59
60 HANDLE Get() { 60 HANDLE Get() const {
61 return handle_; 61 return handle_;
62 } 62 }
63 63
64 operator HANDLE() { return handle_; } 64 operator HANDLE() const { return handle_; }
cpu_(ooo_6.6-7.5) 2012/01/19 20:56:05 can you make it so it looks like Get()? line-wise
65 65
66 HANDLE Take() { 66 HANDLE Take() {
67 // transfers ownership away from this object 67 // transfers ownership away from this object
68 HANDLE h = handle_; 68 HANDLE h = handle_;
69 handle_ = NULL; 69 handle_ = NULL;
70 return h; 70 return h;
71 } 71 }
72 72
73 void Close() { 73 void Close() {
74 if (handle_) { 74 if (handle_) {
75 if (!::CloseHandle(handle_)) { 75 if (!::CloseHandle(handle_)) {
76 NOTREACHED(); 76 NOTREACHED();
77 } 77 }
78 handle_ = NULL; 78 handle_ = NULL;
79 } 79 }
80 } 80 }
81 81
cpu_(ooo_6.6-7.5) 2012/01/19 20:56:05 can you add a method HANDLE Duplicate() const that
82 private: 82 private:
83 HANDLE handle_; 83 HANDLE handle_;
84 DISALLOW_COPY_AND_ASSIGN(ScopedHandle); 84 DISALLOW_COPY_AND_ASSIGN(ScopedHandle);
85 }; 85 };
86 86
87 } // namespace win 87 } // namespace win
88 } // namespace base 88 } // namespace base
89 89
90 #endif // BASE_SCOPED_HANDLE_WIN_H_ 90 #endif // BASE_SCOPED_HANDLE_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | ipc/ipc_channel_handle.h » ('j') | ipc/ipc_channel_handle.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698