1 // Copyright 2014 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 THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_DATA_EQUIVALENCY_H_
6 #define THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_DATA_EQUIVALENCY_H_
7 
8 #include <memory>
9 #include "base/memory/scoped_refptr.h"
10 
11 namespace blink {
12 
13 template <typename T>
14 class Persistent;
15 template <typename T>
16 class Member;
17 
18 template <typename T>
DataEquivalent(const T * a,const T * b)19 bool DataEquivalent(const T* a, const T* b) {
20   if (a == b)
21     return true;
22   if (!a || !b)
23     return false;
24   return *a == *b;
25 }
26 
27 template <typename T>
DataEquivalent(const scoped_refptr<T> & a,const scoped_refptr<T> & b)28 bool DataEquivalent(const scoped_refptr<T>& a, const scoped_refptr<T>& b) {
29   return DataEquivalent(a.get(), b.get());
30 }
31 
32 template <typename T>
DataEquivalent(const Persistent<T> & a,const Persistent<T> & b)33 bool DataEquivalent(const Persistent<T>& a, const Persistent<T>& b) {
34   return DataEquivalent(a.Get(), b.Get());
35 }
36 
37 template <typename T>
DataEquivalent(const Member<T> & a,const Member<T> & b)38 bool DataEquivalent(const Member<T>& a, const Member<T>& b) {
39   return DataEquivalent(a.Get(), b.Get());
40 }
41 
42 template <typename T>
DataEquivalent(const std::unique_ptr<T> & a,const std::unique_ptr<T> & b)43 bool DataEquivalent(const std::unique_ptr<T>& a, const std::unique_ptr<T>& b) {
44   return DataEquivalent(a.get(), b.get());
45 }
46 
47 }  // namespace blink
48 
49 #endif  // THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_DATA_EQUIVALENCY_H_
50