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

Side by Side Diff: skia/ext/SkTraceMemoryDump_chrome.cc

Issue 1319473003: [tracing] Add SkResourceCache statistics to chrome://tracing (chrome side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@discardable_objdumps
Patch Set: Mac build fix. Created 5 years, 3 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
« no previous file with comments | « skia/ext/SkTraceMemoryDump_chrome.h ('k') | skia/ext/skia_memory_dump_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "skia/ext/SkTraceMemoryDump_chrome.h"
6
7 #include "base/trace_event/memory_allocator_dump.h"
8 #include "base/trace_event/memory_dump_manager.h"
9 #include "base/trace_event/process_memory_dump.h"
10 #include "skia/ext/SkDiscardableMemory_chrome.h"
11
12 namespace skia {
13
14 namespace {
15 const char kMallocBackingType[] = "malloc";
16 }
17
18 SkTraceMemoryDump_Chrome::SkTraceMemoryDump_Chrome(
19 base::trace_event::ProcessMemoryDump* process_memory_dump)
20 : SkTraceMemoryDump_Chrome("", process_memory_dump) {}
21
22 SkTraceMemoryDump_Chrome::SkTraceMemoryDump_Chrome(
23 const char* dump_name_prefix,
24 base::trace_event::ProcessMemoryDump* process_memory_dump)
25 : dump_name_prefix_(dump_name_prefix),
26 process_memory_dump_(process_memory_dump) {}
27
28 SkTraceMemoryDump_Chrome::~SkTraceMemoryDump_Chrome() {}
29
30 void SkTraceMemoryDump_Chrome::dumpNumericValue(const char* dumpName,
31 const char* valueName,
32 const char* units,
33 uint64_t value) {
34 auto dump = GetOrCreateAllocatorDump(dumpName);
35 dump->AddScalar(valueName, units, value);
36 }
37
38 void SkTraceMemoryDump_Chrome::setMemoryBacking(const char* dumpName,
39 const char* backingType,
40 const char* backingObjectId) {
41 if (strcmp(backingType, kMallocBackingType) == 0) {
42 auto dump = GetOrCreateAllocatorDump(dumpName);
43 const char* system_allocator_name =
44 base::trace_event::MemoryDumpManager::GetInstance()
45 ->system_allocator_pool_name();
46 if (system_allocator_name) {
47 process_memory_dump_->AddSuballocation(dump->guid(),
48 system_allocator_name);
49 }
50 } else {
51 NOTREACHED();
52 }
53 }
54
55 void SkTraceMemoryDump_Chrome::setDiscardableMemoryBacking(
56 const char* dumpName,
57 const SkDiscardableMemory& discardableMemoryObject) {
58 std::string name = dump_name_prefix_ + dumpName;
59 DCHECK(!process_memory_dump_->GetAllocatorDump(name));
60 const SkDiscardableMemoryChrome& discardable_memory_obj =
61 static_cast<const SkDiscardableMemoryChrome&>(discardableMemoryObject);
62 auto dump = discardable_memory_obj.CreateMemoryAllocatorDump(
63 name.c_str(), process_memory_dump_);
64 DCHECK(dump);
65 }
66
67 base::trace_event::MemoryAllocatorDump*
68 SkTraceMemoryDump_Chrome::GetOrCreateAllocatorDump(const char* dumpName) {
69 std::string name = dump_name_prefix_ + dumpName;
70 auto dump = process_memory_dump_->GetAllocatorDump(name);
71 if (!dump)
72 dump = process_memory_dump_->CreateAllocatorDump(name);
73 return dump;
74 }
75
76 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/SkTraceMemoryDump_chrome.h ('k') | skia/ext/skia_memory_dump_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698