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

Unified Diff: mojo/public/cpp/bindings/lib/equals_traits.h

Issue 2686763002: [Mojo Video Capture] Split OnIncomingCapturedVideoFrame() to OnNewBuffer() and OnFrameReadyInBuffer( (Closed)
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/lib/equals_traits.h
diff --git a/mojo/public/cpp/bindings/lib/clone_equals_util.h b/mojo/public/cpp/bindings/lib/equals_traits.h
similarity index 54%
rename from mojo/public/cpp/bindings/lib/clone_equals_util.h
rename to mojo/public/cpp/bindings/lib/equals_traits.h
index f7bd898c3001c4e8e086d4e8408411061ad9248b..53c7dce6931d2b81fd3f9d3ec14c7b2ca9f86adc 100644
--- a/mojo/public/cpp/bindings/lib/clone_equals_util.h
+++ b/mojo/public/cpp/bindings/lib/equals_traits.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_CLONE_EQUALS_UTIL_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_LIB_CLONE_EQUALS_UTIL_H_
+#ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_EQUALS_TRAITS_H_
+#define MOJO_PUBLIC_CPP_BINDINGS_LIB_EQUALS_TRAITS_H_
#include <type_traits>
#include <unordered_map>
@@ -16,73 +16,6 @@ namespace mojo {
namespace internal {
template <typename T>
-struct HasCloneMethod {
- template <typename U>
- static char Test(decltype(&U::Clone));
- template <typename U>
- static int Test(...);
- static const bool value = sizeof(Test<T>(0)) == sizeof(char);
-
- private:
- EnsureTypeIsComplete<T> check_t_;
-};
-
-template <typename T, bool has_clone_method = HasCloneMethod<T>::value>
-struct CloneTraits;
-
-template <typename T>
-T Clone(const T& input);
-
-template <typename T>
-struct CloneTraits<T, true> {
- static T Clone(const T& input) { return input.Clone(); }
-};
-
-template <typename T>
-struct CloneTraits<T, false> {
- static T Clone(const T& input) { return input; }
-};
-
-template <typename T>
-struct CloneTraits<base::Optional<T>, false> {
- static base::Optional<T> Clone(const base::Optional<T>& input) {
- if (!input)
- return base::nullopt;
-
- return base::Optional<T>(internal::Clone(*input));
- }
-};
-
-template <typename T>
-struct CloneTraits<std::vector<T>, false> {
- static std::vector<T> Clone(const std::vector<T>& input) {
- std::vector<T> result;
- result.reserve(input.size());
- for (const auto& element : input)
- result.push_back(internal::Clone(element));
-
- return result;
- }
-};
-
-template <typename K, typename V>
-struct CloneTraits<std::unordered_map<K, V>, false> {
- static std::unordered_map<K, V> Clone(const std::unordered_map<K, V>& input) {
- std::unordered_map<K, V> result;
- for (const auto& element : input) {
- result.insert(std::make_pair(internal::Clone(element.first),
- internal::Clone(element.second)));
- }
- return result;
- }
-};
-
-template <typename T>
-T Clone(const T& input) {
- return CloneTraits<T>::Clone(input);
-};
-
-template <typename T>
struct HasEqualsMethod {
template <typename U>
static char Test(decltype(&U::Equals));
@@ -158,4 +91,4 @@ bool Equals(const T& a, const T& b) {
} // namespace internal
} // namespace mojo
-#endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CLONE_EQUALS_UTIL_H_
+#endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_EQUALS_TRAITS_H_
« no previous file with comments | « mojo/public/cpp/bindings/lib/clone_equals_util.h ('k') | mojo/public/cpp/bindings/lib/wtf_clone_equals_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698