| 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_storage.h" |
| 6 |
| 7 #include "chrome/profiling/backtrace.h" |
| 8 |
| 9 namespace profiling { |
| 10 |
| 11 BacktraceStorage::BacktraceStorage() {} |
| 12 |
| 13 BacktraceStorage::~BacktraceStorage() {} |
| 14 |
| 15 BacktraceStorage::Key BacktraceStorage::Insert(std::vector<Address>&& bt) { |
| 16 base::AutoLock lock(lock_); |
| 17 |
| 18 BacktraceStorage::Key key = |
| 19 backtraces_.insert(Backtrace(std::move(bt))).first; |
| 20 key->AddRef(); |
| 21 return key; |
| 22 } |
| 23 |
| 24 void BacktraceStorage::Free(const Key& key) { |
| 25 base::AutoLock lock(lock_); |
| 26 if (!key->Release()) |
| 27 backtraces_.erase(key); |
| 28 } |
| 29 |
| 30 void BacktraceStorage::Free(const std::vector<Key>& keys) { |
| 31 base::AutoLock lock(lock_); |
| 32 for (size_t i = 0; i < keys.size(); i++) { |
| 33 if (!keys[i]->Release()) |
| 34 backtraces_.erase(keys[i]); |
| 35 } |
| 36 } |
| 37 |
| 38 const Backtrace& BacktraceStorage::GetBacktraceForKey(const Key& key) const { |
| 39 // Since the caller should own a reference to the key and the container has |
| 40 // stable iterators, we can access without a lock. |
| 41 return *key; |
| 42 } |
| 43 |
| 44 } // namespace profiling |
| OLD | NEW |