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

Side by Side Diff: third_party/WebKit/public/platform/WebVectorMojoArrayTraits.h

Issue 2353003004: Move ViewHostMsg_CreateWindow to mojom (Closed)
Patch Set: . Created 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef WebVectorMojoArrayTraits_h
6 #define WebVectorMojoArrayTraits_h
7
8 #include "WebVector.h"
9 #include "mojo/public/cpp/bindings/array_traits.h"
10
11 #include <algorithm>
12 #include <vector>
13
14 namespace mojo {
15
16 template <typename T>
17 struct ArrayTraits<::blink::WebVector<T>> {
18 using Element = T;
19
20 static size_t GetSize(const ::blink::WebVector<T>& input) { return input.siz e(); }
21 static T* GetData(::blink::WebVector<T>& input) { return input.data(); }
22 static const T* GetData(const ::blink::WebVector<T>& input) { return input.d ata(); }
23 static T& GetAt(::blink::WebVector<T>& input, size_t index) { return input[i ndex]; }
24 static const T& GetAt(const ::blink::WebVector<T>& input, size_t index) { re turn input[index]; }
25
26 static bool Resize(::blink::WebVector<T>& input, size_t size)
27 {
28 ::blink::WebVector<T> new_vector(size);
29 for (size_t i = 0; i < std::min(size, input.size()); ++i)
30 new_vector[i] = input[i];
31 input = new_vector;
32 return true;
33 }
34 };
35
36 } // namespace mojo
37
38 #endif
OLDNEW
« 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