blob: 455eecac25712086a3949347345ff0497115a862 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// Copyright 2015 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.
#ifndef BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_
#define BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_
#include "base/base_export.h"
#include "base/memory/ref_counted.h"
#include "base/trace_event/memory_allocator_attributes.h"
namespace base {
class SingleThreadTaskRunner;
namespace trace_event {
class ProcessMemoryDump;
// The contract interface that memory dump providers must implement.
class BASE_EXPORT MemoryDumpProvider {
public:
// Called by the MemoryDumpManager when generating memory dumps.
// Returns: true if the |pmd| was successfully populated, false otherwise.
virtual bool DumpInto(ProcessMemoryDump* pmd) = 0;
virtual const char* GetFriendlyName() const = 0;
const MemoryAllocatorDeclaredAttributes& allocator_attributes() const {
return allocator_attributes_;
}
// The dump provider can specify an optional thread affinity (in its
// base constructor call). If |task_runner| is non empty, all the calls to
// DumpInto are guaranteed to be posted to that TaskRunner.
const scoped_refptr<SingleThreadTaskRunner>& task_runner() const {
return task_runner_;
}
protected:
// Default ctor: the MDP is not bound to any thread (must be a singleton).
MemoryDumpProvider();
// Use this ctor to ensure that DumpInto() is called always on the same thread
// specified by |task_runner|.
explicit MemoryDumpProvider(
const scoped_refptr<SingleThreadTaskRunner>& task_runner);
virtual ~MemoryDumpProvider();
void DeclareAllocatorAttribute(const MemoryAllocatorDeclaredAttribute& attr);
private:
// The map (attribute name -> type) that specifies the semantic of the
// extra attributes that the MemoryAllocatorDump(s) produced by this
// MemoryDumpProvider will have.
MemoryAllocatorDeclaredAttributes allocator_attributes_;
// (Optional) TaskRunner on which the DumpInfo call should be posted.
const scoped_refptr<SingleThreadTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(MemoryDumpProvider);
};
} // namespace trace_event
} // namespace base
#endif // BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_
|