summaryrefslogtreecommitdiffstats
path: root/base/win
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-08 06:45:35 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-08 06:45:35 +0000
commit73f0bac97dfaf7283f662c72d01217d462c09317 (patch)
treed87cb0deb887ef81b34887969fd6dfa1c8a9717f /base/win
parentbc0d7b86f1bb6ed7a4e0374a2c1a4c8182de307c (diff)
downloadchromium_src-73f0bac97dfaf7283f662c72d01217d462c09317.zip
chromium_src-73f0bac97dfaf7283f662c72d01217d462c09317.tar.gz
chromium_src-73f0bac97dfaf7283f662c72d01217d462c09317.tar.bz2
[Chromoting] Move CreateSessionToken() next to launch process utilities.
BUG=134694 Review URL: https://chromiumcodereview.appspot.com/10828160 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150508 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/win')
-rw-r--r--base/win/scoped_handle.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/base/win/scoped_handle.h b/base/win/scoped_handle.h
index 458519d..3378d00 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
+ // 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