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

Unified Diff: mojo/public/cpp/bindings/array.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/array.h
diff --git a/mojo/public/cpp/bindings/array.h b/mojo/public/cpp/bindings/array.h
index 0ef62619439c7e03642eb1805f3de9d52c212c4b..53c8c1842dda113d84efc592e95c05e9e19900be 100644
--- a/mojo/public/cpp/bindings/array.h
+++ b/mojo/public/cpp/bindings/array.h
@@ -105,6 +105,16 @@ class Array {
vec_.swap(*other);
}
+ // Please note that calling this method will fail compilation if the element
+ // type cannot be cloned (which usually means that it is a Mojo handle type or
+ // a type contains Mojo handles).
+ Array Clone() const {
+ Array result;
+ result.is_null_ = is_null_;
+ Traits::Clone(vec_, &result.vec_);
+ return result.Pass();
+ }
+
private:
typedef std::vector<StorageType> Array::*Testable;

Powered by Google App Engine
This is Rietveld 408576698