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

Unified Diff: mojo/public/cpp/bindings/struct_ptr.h

Issue 615063003: Mojo cpp bindings: support Clone() for structs and arrays which don't contain handles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/struct_ptr.h
diff --git a/mojo/public/cpp/bindings/struct_ptr.h b/mojo/public/cpp/bindings/struct_ptr.h
index 58b6cec87f9c1d96d1ed9101eac7835c70a22f4d..46729dd062e1c7ff983d93e6bd7d2b5bd8f0feaf 100644
--- a/mojo/public/cpp/bindings/struct_ptr.h
+++ b/mojo/public/cpp/bindings/struct_ptr.h
@@ -67,6 +67,13 @@ class StructPtr {
std::swap(ptr_, other->ptr_);
}
+ // Please note that calling this method will fail compilation if the value
+ // type |Struct| doesn't have a Clone() method defined (which usually means
+ // that it contains Mojo handles).
+ StructPtr Clone() const {
+ return is_null() ? StructPtr() : ptr_->Clone();
+ }
+
private:
typedef Struct* StructPtr::*Testable;
@@ -132,6 +139,10 @@ class InlinedStructPtr {
std::swap(is_null_, other->is_null_);
}
+ InlinedStructPtr Clone() const {
+ return is_null() ? InlinedStructPtr() : value_.Clone();
+ }
+
private:
typedef Struct InlinedStructPtr::*Testable;

Powered by Google App Engine
This is Rietveld 408576698