OLD | NEW |
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 SKIA_EXT_SK_TRACE_MEMORY_DUMP_CHROME_H_ | 5 #ifndef SKIA_EXT_SK_TRACE_MEMORY_DUMP_CHROME_H_ |
6 #define SKIA_EXT_SK_TRACE_MEMORY_DUMP_CHROME_H_ | 6 #define SKIA_EXT_SK_TRACE_MEMORY_DUMP_CHROME_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
| 10 #include "base/basictypes.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/trace_event/memory_dump_request_args.h" |
11 #include "third_party/skia/include/core/SkTraceMemoryDump.h" | 13 #include "third_party/skia/include/core/SkTraceMemoryDump.h" |
12 | 14 |
13 namespace base { | 15 namespace base { |
14 namespace trace_event { | 16 namespace trace_event { |
15 class MemoryAllocatorDump; | 17 class MemoryAllocatorDump; |
16 class ProcessMemoryDump; | 18 class ProcessMemoryDump; |
17 } | 19 } |
18 } | 20 } |
19 | 21 |
20 namespace skia { | 22 namespace skia { |
21 | 23 |
22 class SkTraceMemoryDump_Chrome : public SkTraceMemoryDump { | 24 class SkTraceMemoryDump_Chrome : public SkTraceMemoryDump { |
23 public: | 25 public: |
24 // This should never outlive the OnMemoryDump call since the | 26 // This should never outlive the OnMemoryDump call since the |
25 // ProcessMemoryDump is valid only in that timeframe. Optional | 27 // ProcessMemoryDump is valid only in that timeframe. Optional |
26 // |dump_name_prefix| argument specifies the prefix appended to the dump | 28 // |dump_name_prefix| argument specifies the prefix appended to the dump |
27 // name skia provides. By default it is taken as empty string. | 29 // name skia provides. By default it is taken as empty string. |
28 SkTraceMemoryDump_Chrome( | 30 SkTraceMemoryDump_Chrome( |
| 31 base::trace_event::MemoryDumpLevelOfDetail level_of_detail, |
29 base::trace_event::ProcessMemoryDump* process_memory_dump); | 32 base::trace_event::ProcessMemoryDump* process_memory_dump); |
30 | 33 |
31 SkTraceMemoryDump_Chrome( | 34 SkTraceMemoryDump_Chrome( |
32 const char* dump_name_prefix, | 35 const std::string& dump_name_prefix, |
| 36 base::trace_event::MemoryDumpLevelOfDetail level_of_detail, |
33 base::trace_event::ProcessMemoryDump* process_memory_dump); | 37 base::trace_event::ProcessMemoryDump* process_memory_dump); |
34 | 38 |
35 ~SkTraceMemoryDump_Chrome() override; | 39 ~SkTraceMemoryDump_Chrome() override; |
36 | 40 |
37 // SkTraceMemoryDump implementation: | 41 // SkTraceMemoryDump implementation: |
38 void dumpNumericValue(const char* dumpName, | 42 void dumpNumericValue(const char* dumpName, |
39 const char* valueName, | 43 const char* valueName, |
40 const char* units, | 44 const char* units, |
41 uint64_t value) override; | 45 uint64_t value) override; |
42 void setMemoryBacking(const char* dumpName, | 46 void setMemoryBacking(const char* dumpName, |
43 const char* backingType, | 47 const char* backingType, |
44 const char* backingObjectId) override; | 48 const char* backingObjectId) override; |
45 void setDiscardableMemoryBacking( | 49 void setDiscardableMemoryBacking( |
46 const char* dumpName, | 50 const char* dumpName, |
47 const SkDiscardableMemory& discardableMemoryObject) override; | 51 const SkDiscardableMemory& discardableMemoryObject) override; |
| 52 LevelOfDetail getRequestedDetails() const override; |
48 | 53 |
49 protected: | 54 protected: |
50 base::trace_event::ProcessMemoryDump* process_memory_dump() { | 55 base::trace_event::ProcessMemoryDump* process_memory_dump() { |
51 return process_memory_dump_; | 56 return process_memory_dump_; |
52 } | 57 } |
53 | 58 |
54 private: | 59 private: |
| 60 // Helper to create allocator dumps. |
| 61 base::trace_event::MemoryAllocatorDump* GetOrCreateAllocatorDump( |
| 62 const char* dumpName); |
| 63 |
55 std::string dump_name_prefix_; | 64 std::string dump_name_prefix_; |
56 | 65 |
57 base::trace_event::ProcessMemoryDump* process_memory_dump_; | 66 base::trace_event::ProcessMemoryDump* process_memory_dump_; |
58 | 67 |
59 // Helper to create allocator dumps. | 68 // Stores the level of detail for the current dump. |
60 base::trace_event::MemoryAllocatorDump* GetOrCreateAllocatorDump( | 69 LevelOfDetail request_level_; |
61 const char* dumpName); | |
62 | 70 |
63 DISALLOW_COPY_AND_ASSIGN(SkTraceMemoryDump_Chrome); | 71 DISALLOW_COPY_AND_ASSIGN(SkTraceMemoryDump_Chrome); |
64 }; | 72 }; |
65 | 73 |
66 } // namespace skia | 74 } // namespace skia |
67 | 75 |
68 #endif // SKIA_EXT_SK_TRACE_MEMORY_DUMP_CHROME_H_ | 76 #endif // SKIA_EXT_SK_TRACE_MEMORY_DUMP_CHROME_H_ |
OLD | NEW |