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

Unified Diff: third_party/WebKit/public/platform/WebVectorMojoArrayTraits.h

Issue 2353003004: Move ViewHostMsg_CreateWindow to mojom (Closed)
Patch Set: . Created 4 years, 3 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: third_party/WebKit/public/platform/WebVectorMojoArrayTraits.h
diff --git a/third_party/WebKit/public/platform/WebVectorMojoArrayTraits.h b/third_party/WebKit/public/platform/WebVectorMojoArrayTraits.h
new file mode 100644
index 0000000000000000000000000000000000000000..b2a4af43cb16493c2955c04919dc436b7e6fb576
--- /dev/null
+++ b/third_party/WebKit/public/platform/WebVectorMojoArrayTraits.h
@@ -0,0 +1,38 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WebVectorMojoArrayTraits_h
+#define WebVectorMojoArrayTraits_h
+
+#include "WebVector.h"
+#include "mojo/public/cpp/bindings/array_traits.h"
+
+#include <algorithm>
+#include <vector>
+
+namespace mojo {
+
+template <typename T>
+struct ArrayTraits<::blink::WebVector<T>> {
+ using Element = T;
+
+ static size_t GetSize(const ::blink::WebVector<T>& input) { return input.size(); }
+ static T* GetData(::blink::WebVector<T>& input) { return input.data(); }
+ static const T* GetData(const ::blink::WebVector<T>& input) { return input.data(); }
+ static T& GetAt(::blink::WebVector<T>& input, size_t index) { return input[index]; }
+ static const T& GetAt(const ::blink::WebVector<T>& input, size_t index) { return input[index]; }
+
+ static bool Resize(::blink::WebVector<T>& input, size_t size)
+ {
+ ::blink::WebVector<T> new_vector(size);
+ for (size_t i = 0; i < std::min(size, input.size()); ++i)
+ new_vector[i] = input[i];
+ input = new_vector;
+ return true;
+ }
+};
+
+} // namespace mojo
+
+#endif
« no previous file with comments | « third_party/WebKit/public/platform/WebStringMojoStringTraits.h ('k') | third_party/WebKit/public/platform/referrer.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698