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

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

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest Created 5 years, 7 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/trace_event/memory_allocator_attributes.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/trace_event/memory_allocator_attributes_type_info.h"
10 11
11 namespace base { 12 namespace base {
13
14 class SingleThreadTaskRunner;
15
12 namespace trace_event { 16 namespace trace_event {
13 17
14 class ProcessMemoryDump; 18 class ProcessMemoryDump;
15 19
16 // The contract interface that memory dump providers must implement. 20 // The contract interface that memory dump providers must implement.
17 class BASE_EXPORT MemoryDumpProvider { 21 class BASE_EXPORT MemoryDumpProvider {
18 public: 22 public:
19 // Called by the MemoryDumpManager when generating dump points. 23 // Called by the MemoryDumpManager when generating memory dumps.
20 // Returns: true if the |pmd| was successfully populated, false otherwise. 24 // Returns: true if the |pmd| was successfully populated, false otherwise.
21 virtual bool DumpInto(ProcessMemoryDump* pmd) = 0; 25 virtual bool DumpInto(ProcessMemoryDump* pmd) = 0;
22 26
23 virtual const char* GetFriendlyName() const = 0; 27 virtual const char* GetFriendlyName() const = 0;
24 28
25 const MemoryAllocatorDeclaredAttributes& allocator_attributes() const { 29 const MemoryAllocatorAttributesTypeInfo& allocator_attributes_type_info()
26 return allocator_attributes_; 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_;
27 } 39 }
28 40
29 protected: 41 protected:
42 // Default ctor: the MDP is not bound to any thread (must be a singleton).
30 MemoryDumpProvider(); 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
31 virtual ~MemoryDumpProvider(); 50 virtual ~MemoryDumpProvider();
32 51
33 void DeclareAllocatorAttribute(const MemoryAllocatorDeclaredAttribute& attr); 52 void DeclareAllocatorAttribute(const std::string& allocator_name,
53 const std::string& attribute_name,
54 const std::string& attribute_type);
34 55
35 private: 56 private:
36 // The map (attribute name -> type) that specifies the semantic of the 57 // A map of attributes types (declared through DeclareAllocatorAttribute())
37 // extra attributes that the MemoryAllocatorDump(s) produced by this 58 // emitted by this allocator dumper.
38 // MemoryDumpProvider will have. 59 MemoryAllocatorAttributesTypeInfo allocator_attributes_type_info_;
39 MemoryAllocatorDeclaredAttributes allocator_attributes_; 60
61 // (Optional) TaskRunner on which the DumpInfo call should be posted.
62 scoped_refptr<SingleThreadTaskRunner> task_runner_;
40 63
41 DISALLOW_COPY_AND_ASSIGN(MemoryDumpProvider); 64 DISALLOW_COPY_AND_ASSIGN(MemoryDumpProvider);
42 }; 65 };
43 66
44 } // namespace trace_event 67 } // namespace trace_event
45 } // namespace base 68 } // namespace base
46 69
47 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_ 70 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698