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

Side by Side Diff: mojo/public/cpp/bindings/lib/clone_equals_util.h

Issue 2686763002: [Mojo Video Capture] Split OnIncomingCapturedVideoFrame() to OnNewBuffer() and OnFrameReadyInBuffer( (Closed)
Patch Set: Remove unused bool accidentally introduced in PS2 Created 3 years, 10 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 MOJO_PUBLIC_CPP_BINDINGS_LIB_CLONE_EQUALS_UTIL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_CLONE_EQUALS_UTIL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_CLONE_EQUALS_UTIL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_CLONE_EQUALS_UTIL_H_
7 7
8 #include <memory>
8 #include <type_traits> 9 #include <type_traits>
9 #include <unordered_map> 10 #include <unordered_map>
10 #include <vector> 11 #include <vector>
11 12
13 #include "base/memory/ptr_util.h"
12 #include "base/optional.h" 14 #include "base/optional.h"
15 #include "base/values.h"
13 #include "mojo/public/cpp/bindings/lib/template_util.h" 16 #include "mojo/public/cpp/bindings/lib/template_util.h"
14 17
15 namespace mojo { 18 namespace mojo {
16 namespace internal { 19 namespace internal {
17 20
18 template <typename T> 21 template <typename T>
19 struct HasCloneMethod { 22 struct HasCloneMethod {
20 template <typename U> 23 template <typename U>
21 static char Test(decltype(&U::Clone)); 24 static char Test(decltype(&U::Clone));
22 template <typename U> 25 template <typename U>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 static std::unordered_map<K, V> Clone(const std::unordered_map<K, V>& input) { 73 static std::unordered_map<K, V> Clone(const std::unordered_map<K, V>& input) {
71 std::unordered_map<K, V> result; 74 std::unordered_map<K, V> result;
72 for (const auto& element : input) { 75 for (const auto& element : input) {
73 result.insert(std::make_pair(internal::Clone(element.first), 76 result.insert(std::make_pair(internal::Clone(element.first),
74 internal::Clone(element.second))); 77 internal::Clone(element.second)));
75 } 78 }
76 return result; 79 return result;
77 } 80 }
78 }; 81 };
79 82
83 template <>
84 struct CloneTraits<std::unique_ptr<base::DictionaryValue>, false> {
85 static std::unique_ptr<base::DictionaryValue> Clone(
86 const std::unique_ptr<base::DictionaryValue>& input) {
87 auto result = base::MakeUnique<base::DictionaryValue>();
88 result->MergeDictionary(input.get());
89 return result;
90 }
91 };
92
80 template <typename T> 93 template <typename T>
81 T Clone(const T& input) { 94 T Clone(const T& input) {
82 return CloneTraits<T>::Clone(input); 95 return CloneTraits<T>::Clone(input);
83 }; 96 };
84 97
85 template <typename T> 98 template <typename T>
86 struct HasEqualsMethod { 99 struct HasEqualsMethod {
87 template <typename U> 100 template <typename U>
88 static char Test(decltype(&U::Equals)); 101 static char Test(decltype(&U::Equals));
89 template <typename U> 102 template <typename U>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 165
153 template <typename T> 166 template <typename T>
154 bool Equals(const T& a, const T& b) { 167 bool Equals(const T& a, const T& b) {
155 return EqualsTraits<T>::Equals(a, b); 168 return EqualsTraits<T>::Equals(a, b);
156 } 169 }
157 170
158 } // namespace internal 171 } // namespace internal
159 } // namespace mojo 172 } // namespace mojo
160 173
161 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CLONE_EQUALS_UTIL_H_ 174 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CLONE_EQUALS_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698