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

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

Issue 11078014: Fix move.h's to use a concrete RValue carrier object rather than hacking a RValue&. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix error. Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « base/move.h ('k') | chrome/browser/usb/usb_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 public: 42 public:
43 typedef typename Traits::Handle Handle; 43 typedef typename Traits::Handle Handle;
44 44
45 GenericScopedHandle() : handle_(Traits::NullHandle()) {} 45 GenericScopedHandle() : handle_(Traits::NullHandle()) {}
46 46
47 explicit GenericScopedHandle(Handle handle) : handle_(Traits::NullHandle()) { 47 explicit GenericScopedHandle(Handle handle) : handle_(Traits::NullHandle()) {
48 Set(handle); 48 Set(handle);
49 } 49 }
50 50
51 // Move constructor for C++03 move emulation of this type. 51 // Move constructor for C++03 move emulation of this type.
52 GenericScopedHandle(RValue& other) : handle_(Traits::NullHandle()) { 52 GenericScopedHandle(RValue other) : handle_(Traits::NullHandle()) {
53 Set(other.Take()); 53 Set(other.object->Take());
54 } 54 }
55 55
56 ~GenericScopedHandle() { 56 ~GenericScopedHandle() {
57 Close(); 57 Close();
58 } 58 }
59 59
60 bool IsValid() const { 60 bool IsValid() const {
61 return Traits::IsHandleValid(handle_); 61 return Traits::IsHandleValid(handle_);
62 } 62 }
63 63
64 // Move operator= for C++03 move emulation of this type. 64 // Move operator= for C++03 move emulation of this type.
65 GenericScopedHandle& operator=(RValue& other) { 65 GenericScopedHandle& operator=(RValue other) {
66 if (this != &other) { 66 if (this != other.object) {
67 Set(other.Take()); 67 Set(other.object->Take());
68 } 68 }
69 return *this; 69 return *this;
70 } 70 }
71 71
72 void Set(Handle handle) { 72 void Set(Handle handle) {
73 if (handle_ != handle) { 73 if (handle_ != handle) {
74 Close(); 74 Close();
75 75
76 if (Traits::IsHandleValid(handle)) { 76 if (Traits::IsHandleValid(handle)) {
77 handle_ = handle; 77 handle_ = handle;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 private: 179 private:
180 DISALLOW_IMPLICIT_CONSTRUCTORS(VerifierTraits); 180 DISALLOW_IMPLICIT_CONSTRUCTORS(VerifierTraits);
181 }; 181 };
182 182
183 typedef GenericScopedHandle<HandleTraits, VerifierTraits> ScopedHandle; 183 typedef GenericScopedHandle<HandleTraits, VerifierTraits> ScopedHandle;
184 184
185 } // namespace win 185 } // namespace win
186 } // namespace base 186 } // namespace base
187 187
188 #endif // BASE_SCOPED_HANDLE_WIN_H_ 188 #endif // BASE_SCOPED_HANDLE_WIN_H_
OLDNEW
« no previous file with comments | « base/move.h ('k') | chrome/browser/usb/usb_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698