Chromium Code Reviews| 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 size_t ComputeHash(const std::vector<Address>& addrs) { | |
|
awong
2017/06/19 23:42:05
Can you add a TODO here assigned to me to fix this
| |
| 20 if (addrs.empty()) | |
| 21 return 0; | |
| 22 // Assume Address is a POD containing only the address with no padding. | |
| 23 return base::Hash(reinterpret_cast<const char*>(&addrs[0]), | |
| 24 addrs.size() * sizeof(Address)); | |
| 25 } | |
| 26 | |
| 27 } // namespace | |
| 28 | |
| 29 Backtrace::Backtrace(std::vector<Address>&& a) | |
| 30 : addrs_(std::move(a)), fingerprint_(ComputeHash(addrs_)) {} | |
| 31 | |
| 32 Backtrace::Backtrace(Backtrace&& other) noexcept = default; | |
| 33 | |
| 34 Backtrace::~Backtrace() {} | |
| 35 | |
| 36 Backtrace& Backtrace::operator=(Backtrace&& other) = default; | |
| 37 | |
| 38 bool Backtrace::operator==(const Backtrace& other) const { | |
| 39 if (addrs_.size() != other.addrs_.size()) | |
| 40 return false; | |
| 41 return memcmp(addrs_.data(), other.addrs_.data(), | |
| 42 addrs_.size() * sizeof(Address)) == 0; | |
| 43 } | |
| 44 | |
| 45 bool Backtrace::operator!=(const Backtrace& other) const { | |
| 46 return !operator==(other); | |
| 47 } | |
| 48 | |
| 49 } // namespace profiling | |
| OLD | NEW |