| Index: chrome/profiling/stack.cc
|
| diff --git a/chrome/profiling/stack.cc b/chrome/profiling/stack.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5715177e1a1a60d0616b84b52f15c6d5bcd95bb2
|
| --- /dev/null
|
| +++ b/chrome/profiling/stack.cc
|
| @@ -0,0 +1,46 @@
|
| +// 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/stack.h"
|
| +
|
| +#include <algorithm>
|
| +
|
| +#include "base/hash.h"
|
| +#include "chrome/profiling/profiling_globals.h"
|
| +#include "chrome/profiling/stack_storage.h"
|
| +
|
| +namespace profiling {
|
| +
|
| +namespace {
|
| +
|
| +size_t ComputeHash(const std::vector<Address>& addrs) {
|
| + 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
|
| +
|
| +Stack::Stack(std::vector<Address>&& a)
|
| + : addrs_(std::move(a)), hash_(ComputeHash(addrs_)) {}
|
| +
|
| +Stack::~Stack() {}
|
| +
|
| +bool Stack::operator==(const Stack& other) const {
|
| + if (addrs_.size() != other.addrs_.size())
|
| + return false;
|
| + for (size_t i = 0; i < addrs_.size(); i++) {
|
| + if (addrs_[i] != other.addrs_[i])
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +bool Stack::operator!=(const Stack& other) const {
|
| + return !operator==(other);
|
| +}
|
| +
|
| +} // namespace profiling
|
|
|