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

Side by Side Diff: base/trace_event/memory_dump_provider.h

Issue 1107093004: [tracing] Simplify MemoryDumpProvider interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_ 5 #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_
6 #define BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_ 6 #define BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/trace_event/memory_allocator_attributes_type_info.h"
11 9
12 namespace base { 10 namespace base {
13
14 class SingleThreadTaskRunner;
15
16 namespace trace_event { 11 namespace trace_event {
17 12
18 class ProcessMemoryDump; 13 class ProcessMemoryDump;
19 14
20 // The contract interface that memory dump providers must implement. 15 // The contract interface that memory dump providers must implement.
21 class BASE_EXPORT MemoryDumpProvider { 16 class BASE_EXPORT MemoryDumpProvider {
22 public: 17 public:
23 // Called by the MemoryDumpManager when generating memory dumps. 18 // Called by the MemoryDumpManager when generating memory dumps.
24 // Returns: true if the |pmd| was successfully populated, false otherwise. 19 // The embedder should return true if the |pmd| was successfully populated,
25 virtual bool DumpInto(ProcessMemoryDump* pmd) = 0; 20 // false if something went wrong and the dump should be considered invalid.
26 21 // (Note, the MemoryDumpManager has a fail-safe logic which will disable the
27 virtual const char* GetFriendlyName() const = 0; 22 // MemoryDumpProvider for the entire trace session if it fails consistently).
28 23 virtual bool OnMemoryDump(ProcessMemoryDump* pmd) = 0;
29 const MemoryAllocatorAttributesTypeInfo& allocator_attributes_type_info()
30 const {
31 return allocator_attributes_type_info_;
32 }
33
34 // The dump provider can specify an optional thread affinity (in its
35 // base constructor call). If |task_runner| is non empty, all the calls to
36 // DumpInto are guaranteed to be posted to that TaskRunner.
37 const scoped_refptr<SingleThreadTaskRunner>& task_runner() const {
38 return task_runner_;
39 }
40
41 protected:
42 // Default ctor: the MDP is not bound to any thread (must be a singleton).
43 MemoryDumpProvider();
44
45 // Use this ctor to ensure that DumpInto() is called always on the same thread
46 // specified by |task_runner|.
47 explicit MemoryDumpProvider(
48 const scoped_refptr<SingleThreadTaskRunner>& task_runner);
49
50 virtual ~MemoryDumpProvider();
reveman 2015/04/27 23:01:24 Can we keep an empty protected dtor to prevent thi
Primiano Tucci (use gerrit) 2015/04/28 08:03:03 Done.
51
52 void DeclareAllocatorAttribute(const std::string& allocator_name,
53 const std::string& attribute_name,
54 const std::string& attribute_type);
55
56 private:
57 // A map of attributes types (declared through DeclareAllocatorAttribute())
58 // emitted by this allocator dumper.
59 MemoryAllocatorAttributesTypeInfo allocator_attributes_type_info_;
60
61 // (Optional) TaskRunner on which the DumpInfo call should be posted.
62 scoped_refptr<SingleThreadTaskRunner> task_runner_;
63
64 DISALLOW_COPY_AND_ASSIGN(MemoryDumpProvider);
65 }; 24 };
66 25
67 } // namespace trace_event 26 } // namespace trace_event
68 } // namespace base 27 } // namespace base
69 28
70 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_ 29 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_
OLDNEW
« no previous file with comments | « base/trace_event/memory_dump_manager_unittest.cc ('k') | base/trace_event/memory_dump_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698