Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Side by Side Diff: chrome/profiling/backtrace.cc

Issue 2943733002: Add out-of-process memory logging stream parsing. (Closed)
Patch Set: Add TODO Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/profiling/backtrace.h ('k') | chrome/profiling/backtrace_storage.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « chrome/profiling/backtrace.h ('k') | chrome/profiling/backtrace_storage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698