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

Side by Side Diff: chrome/profiling/stack_storage.h

Issue 2943733002: Add out-of-process memory logging stream parsing. (Closed)
Patch Set: Remove version 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
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 #ifndef CHROME_PROFILING_STACK_STORAGE_H_
6 #define CHROME_PROFILING_STACK_STORAGE_H_
7
8 #include <unordered_set>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/synchronization/lock.h"
14 #include "chrome/profiling/stack.h"
15
16 namespace profiling {
17
18 // This class is threadsafe.
19 class StackStorage {
20 public:
21 using Container = std::unordered_set<Stack>;
22 using Key = Container::iterator;
23
24 StackStorage();
25 ~StackStorage();
26
27 // Adds the give stack to the storage and returns a key to it. If a matching
Boris Vidolov 2017/06/17 03:13:15 nit: "given"
28 // stack already exists, a key to the existing one will be returned.
29 //
30 // The returned key will have a reference count associated with it, call
31 // Free when the key is no longer needed.
32 Key Insert(Stack&& stack);
33
34 // Frees one reference to a stack.
35 void Free(const Key& key);
36 void Free(const std::vector<Key>& keys);
37
38 // Returns the stack associated with the given key. Assumes the caller holds
39 // a key to it that will keep the stack in scope.
40 const Stack& GetStackForKey(const Key& key) const;
41
42 private:
43 mutable base::Lock lock_;
44
45 // List of live stacks for de-duping. Protected by the lock_.
46 Container stacks_;
47 };
48
49 } // namespace profiling
50
51 #endif // CHROME_PROFILING_STACK_STORAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698