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

Side by Side Diff: third_party/WebKit/Source/platform/mojo/MojoHelper.h

Issue 1808203005: [OnionSoup] Moving VR service from content to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reworked as per new comments. Fixed build errors! Created 4 years, 7 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MojoHelper_h 5 #ifndef MojoHelper_h
6 #define MojoHelper_h 6 #define MojoHelper_h
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "mojo/public/cpp/bindings/callback.h" 9 #include "mojo/public/cpp/bindings/callback.h"
10 #include "mojo/public/cpp/bindings/wtf_array.h" 10 #include "mojo/public/cpp/bindings/wtf_array.h"
(...skipping 22 matching lines...) Expand all
33 { 33 {
34 return base::Bind(method, base::Unretained(instance)); 34 return base::Bind(method, base::Unretained(instance));
35 } 35 }
36 36
37 template <typename R, typename... Args> 37 template <typename R, typename... Args>
38 base::Callback<R(Args...)> createBaseCallback(PassOwnPtr<Function<R(Args...)>> f unctor) 38 base::Callback<R(Args...)> createBaseCallback(PassOwnPtr<Function<R(Args...)>> f unctor)
39 { 39 {
40 return base::Bind(&internal::CallWTFFunction<R, Args...>, base::Owned(functo r.leakPtr())); 40 return base::Bind(&internal::CallWTFFunction<R, Args...>, base::Owned(functo r.leakPtr()));
41 } 41 }
42 42
43 template <typename Class, typename ReturnType, typename BoundArgs, typename... A rgs>
44 mojo::Callback<ReturnType(Args...)>
45 sameThreadBindForMojoWithBoundArgs(ReturnType (Class::*method)(BoundArgs*, Args. ..), Class* instance, BoundArgs* bound)
haraken 2016/04/27 06:51:07 I want to avoid introducing this method (because U
46 {
47 return base::Bind(method, base::Unretained(instance), base::Unretained(bound ));
48 }
49
43 } // namespace blink 50 } // namespace blink
44 51
45 namespace mojo { 52 namespace mojo {
46 53
47 // A |TypeConverter| that will create a |WTFArray<T>| containing a copy of the 54 // A |TypeConverter| that will create a |WTFArray<T>| containing a copy of the
48 // contents of a |blink::HeapVector<E>|, using |TypeConverter<T, E>| to copy 55 // contents of a |blink::HeapVector<E>|, using |TypeConverter<T, E>| to copy
49 // each element. The returned array will always be non-null. 56 // each element. The returned array will always be non-null.
50 template <typename T, typename E> 57 template <typename T, typename E>
51 struct TypeConverter<WTFArray<T>, blink::HeapVector<E>> { 58 struct TypeConverter<WTFArray<T>, blink::HeapVector<E>> {
52 static WTFArray<T> Convert(const blink::HeapVector<E>& input) 59 static WTFArray<T> Convert(const blink::HeapVector<E>& input)
53 { 60 {
54 WTFArray<T> result(input.size()); 61 WTFArray<T> result(input.size());
55 for (size_t i = 0; i < input.size(); ++i) 62 for (size_t i = 0; i < input.size(); ++i)
56 result[i] = TypeConverter<T, E>::Convert(input[i]); 63 result[i] = TypeConverter<T, E>::Convert(input[i]);
57 return std::move(result); 64 return std::move(result);
58 } 65 }
59 }; 66 };
60 67
61 } // namespace mojo 68 } // namespace mojo
62 69
63 #endif // MojoHelper_h 70 #endif // MojoHelper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698