Chromium Code Reviews| Index: chrome/profiling/backtrace.cc |
| diff --git a/chrome/profiling/backtrace.cc b/chrome/profiling/backtrace.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e6b5000bd3e328485c742236231031b0fef3cb6f |
| --- /dev/null |
| +++ b/chrome/profiling/backtrace.cc |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/profiling/backtrace.h" |
| + |
| +#include <string.h> |
| + |
| +#include <algorithm> |
| + |
| +#include "base/hash.h" |
| +#include "chrome/profiling/backtrace_storage.h" |
| +#include "chrome/profiling/profiling_globals.h" |
| + |
| +namespace profiling { |
| + |
| +namespace { |
| + |
| +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
|
| + if (addrs.empty()) |
| + return 0; |
| + // Assume Address is a POD containing only the address with no padding. |
| + return base::Hash(reinterpret_cast<const char*>(&addrs[0]), |
| + addrs.size() * sizeof(Address)); |
| +} |
| + |
| +} // namespace |
| + |
| +Backtrace::Backtrace(std::vector<Address>&& a) |
| + : addrs_(std::move(a)), fingerprint_(ComputeHash(addrs_)) {} |
| + |
| +Backtrace::Backtrace(Backtrace&& other) noexcept = default; |
| + |
| +Backtrace::~Backtrace() {} |
| + |
| +Backtrace& Backtrace::operator=(Backtrace&& other) = default; |
| + |
| +bool Backtrace::operator==(const Backtrace& other) const { |
| + if (addrs_.size() != other.addrs_.size()) |
| + return false; |
| + return memcmp(addrs_.data(), other.addrs_.data(), |
| + addrs_.size() * sizeof(Address)) == 0; |
| +} |
| + |
| +bool Backtrace::operator!=(const Backtrace& other) const { |
| + return !operator==(other); |
| +} |
| + |
| +} // namespace profiling |