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

Unified Diff: mojo/public/cpp/system/core.h

Issue 220063005: Adds ScopedHandleBase::From (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wrong comment Created 6 years, 9 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: mojo/public/cpp/system/core.h
diff --git a/mojo/public/cpp/system/core.h b/mojo/public/cpp/system/core.h
index 70221107ab0a2d6ee332d461294840c34c601d55..fc65ea5cc6fe386c13aa4d8ba510654423d222ab 100644
--- a/mojo/public/cpp/system/core.h
+++ b/mojo/public/cpp/system/core.h
@@ -49,6 +49,16 @@ class ScopedHandleBase {
const HandleType& get() const { return handle_; }
+ template <typename PassedHandleType>
+ static ScopedHandleBase<HandleType> From(
+ ScopedHandleBase<PassedHandleType> other) {
+ MOJO_COMPILE_ASSERT(
+ sizeof(static_cast<PassedHandleType*>(static_cast<HandleType*>(0))),
+ HandleType_is_not_a_subtype_of_PassedHandleType);
+ return ScopedHandleBase<HandleType>(
+ static_cast<HandleType>(other.release().value()));
darin (slow to review) 2014/04/04 22:40:49 Are you sure about the .value() call here? Doesn't
darin (slow to review) 2014/04/04 22:56:14 Nevermind. I somehow missed the compile assert :-P
+ }
+
void swap(ScopedHandleBase& other) {
handle_.swap(other.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