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

Unified Diff: base/win/scoped_handle.h

Issue 10855061: Properly notify the handle verifier when a handle is passed around. This CL fixes issues introduced… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | no next file » | 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 3378d004f32c96386cf29ef8defeee157ef9e51b..99522e3678591159223fb9ac974218d295c0592b 100644
--- a/base/win/scoped_handle.h
+++ b/base/win/scoped_handle.h
@@ -49,7 +49,8 @@ class GenericScopedHandle {
}
// Move constructor for C++03 move emulation of this type.
- GenericScopedHandle(RValue& other) : handle_(other.Take()) {
+ GenericScopedHandle(RValue& other) : handle_(Traits::NullHandle()) {
+ Set(other.Take());
}
~GenericScopedHandle() {
@@ -62,9 +63,9 @@ class GenericScopedHandle {
// 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);
+ if (this != static_cast<GenericScopedHandle*>(&other)) {
jar (doing other things) 2012/08/09 00:00:49 nit: You *might* even get away without a cast... b
alexeypa (please no reviews) 2012/08/09 15:39:03 Done.
+ Set(other.Take());
+ }
return *this;
}
@@ -97,12 +98,6 @@ 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_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698