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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/profiling/backtrace.h ('k') | chrome/profiling/backtrace_storage.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/profiling/backtrace.cc
diff --git a/chrome/profiling/backtrace.cc b/chrome/profiling/backtrace.cc
new file mode 100644
index 0000000000000000000000000000000000000000..29094dafbd7680eb9f7fa2b92eddd413935fbe27
--- /dev/null
+++ b/chrome/profiling/backtrace.cc
@@ -0,0 +1,50 @@
+// 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 {
+
+// TODO(ajwong) replace with a fingerprint capable hash.
+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
+
+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
« 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