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

Unified Diff: base/win/scoped_handle.h

Issue 10828160: [Chromoting] Move CreateSessionToken() next to launch process utilities. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/host/daemon_process_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/win/scoped_handle.h
diff --git a/base/win/scoped_handle.h b/base/win/scoped_handle.h
index 458519d9bfe85f1348e5a193cec221b24cbe8922..3378d004f32c96386cf29ef8defeee157ef9e51b 100644
--- a/base/win/scoped_handle.h
+++ b/base/win/scoped_handle.h
@@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/move.h"
namespace base {
namespace win {
@@ -36,6 +37,8 @@ extern "C" {
// takes a raw handle pointer only.
template <class Traits, class Verifier>
class GenericScopedHandle {
+ MOVE_ONLY_TYPE_FOR_CPP_03(GenericScopedHandle, RValue)
+
public:
typedef typename Traits::Handle Handle;
@@ -45,6 +48,10 @@ class GenericScopedHandle {
Set(handle);
}
+ // Move constructor for C++03 move emulation of this type.
+ GenericScopedHandle(RValue& other) : handle_(other.Take()) {
+ }
+
~GenericScopedHandle() {
Close();
}
@@ -53,6 +60,14 @@ class GenericScopedHandle {
return Traits::IsHandleValid(handle_);
}
+ // Move operator= for C++03 move emulation of this type.
+ GenericScopedHandle& operator=(RValue& other) {
+ // Swapping the handles helps to avoid problems while assigning a handle
jar (doing other things) 2012/08/08 01:42:52 The usual "trick" with dealing with self assignmen
alexeypa (please no reviews) 2012/08/08 01:59:30 src/base/move.h has a long explanation what it is
+ // to itself. It is also cheap and matches base::scoped_ptr behavior.
+ Swap(other);
+ return *this;
+ }
+
void Set(Handle handle) {
if (handle_ != handle) {
Close();
@@ -82,6 +97,12 @@ class GenericScopedHandle {
return &handle_;
}
+ void Swap(GenericScopedHandle& other) {
+ Handle tmp = handle_;
+ handle_ = other.handle_;
+ other.handle_ = tmp;
+ }
+
// Transfers ownership away from this object.
Handle Take() {
Handle temp = handle_;
@@ -106,8 +127,6 @@ class GenericScopedHandle {
private:
Handle handle_;
-
- DISALLOW_COPY_AND_ASSIGN(GenericScopedHandle);
};
#undef BASE_WIN_GET_CALLER
« no previous file with comments | « no previous file | remoting/host/daemon_process_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698