| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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 #include "chrome/profiling/backtrace.h" |
| 6 |
| 7 #include <string.h> |
| 8 |
| 9 #include <algorithm> |
| 10 |
| 11 #include "base/hash.h" |
| 12 #include "chrome/profiling/backtrace_storage.h" |
| 13 #include "chrome/profiling/profiling_globals.h" |
| 14 |
| 15 namespace profiling { |
| 16 |
| 17 namespace { |
| 18 |
| 19 // TODO(ajwong) replace with a fingerprint capable hash. |
| 20 size_t ComputeHash(const std::vector<Address>& addrs) { |
| 21 if (addrs.empty()) |
| 22 return 0; |
| 23 // Assume Address is a POD containing only the address with no padding. |
| 24 return base::Hash(reinterpret_cast<const char*>(&addrs[0]), |
| 25 addrs.size() * sizeof(Address)); |
| 26 } |
| 27 |
| 28 } // namespace |
| 29 |
| 30 Backtrace::Backtrace(std::vector<Address>&& a) |
| 31 : addrs_(std::move(a)), fingerprint_(ComputeHash(addrs_)) {} |
| 32 |
| 33 Backtrace::Backtrace(Backtrace&& other) noexcept = default; |
| 34 |
| 35 Backtrace::~Backtrace() {} |
| 36 |
| 37 Backtrace& Backtrace::operator=(Backtrace&& other) = default; |
| 38 |
| 39 bool Backtrace::operator==(const Backtrace& other) const { |
| 40 if (addrs_.size() != other.addrs_.size()) |
| 41 return false; |
| 42 return memcmp(addrs_.data(), other.addrs_.data(), |
| 43 addrs_.size() * sizeof(Address)) == 0; |
| 44 } |
| 45 |
| 46 bool Backtrace::operator!=(const Backtrace& other) const { |
| 47 return !operator==(other); |
| 48 } |
| 49 |
| 50 } // namespace profiling |
| OLD | NEW |