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

Unified 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: Adding DCHECK. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: skia/ext/SkTraceMemoryDump_chrome.cc
diff --git a/skia/ext/SkTraceMemoryDump_chrome.cc b/skia/ext/SkTraceMemoryDump_chrome.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e7997a5bde1e30735d6610689b21c4c96f3f3e01
--- /dev/null
+++ b/skia/ext/SkTraceMemoryDump_chrome.cc
@@ -0,0 +1,53 @@
+// 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.
+
+#include "skia/ext/SkTraceMemoryDump_chrome.h"
+
+#include "base/trace_event/memory_allocator_dump.h"
+#include "base/trace_event/memory_dump_manager.h"
+#include "base/trace_event/process_memory_dump.h"
+#include "skia/ext/SkDiscardableMemory_chrome.h"
+
+namespace skia {
+
+SkTraceMemoryDump_Chrome::SkTraceMemoryDump_Chrome(
+ base::trace_event::ProcessMemoryDump* process_memory_dump)
+ : process_memory_dump_(process_memory_dump) {}
+
+SkTraceMemoryDump_Chrome::~SkTraceMemoryDump_Chrome() {}
+
+void SkTraceMemoryDump_Chrome::dumpNumericValue(const char* dumpName,
+ const char* valueName,
+ const char* units,
+ uint64_t value) {
+ auto mad = process_memory_dump_->GetAllocatorDump(dumpName);
+ if (!mad)
+ mad = process_memory_dump_->CreateAllocatorDump(dumpName);
+ mad->AddScalar(valueName, units, value);
+}
+
+void SkTraceMemoryDump_Chrome::setMemoryBacking(const char* dumpName,
+ const char* backingType,
+ const char* backingObjectId) {
+ if (strcmp(backingType, "malloc") == 0) {
+ auto mad = process_memory_dump_->GetAllocatorDump(dumpName);
+ if (!mad)
+ mad = process_memory_dump_->CreateAllocatorDump(dumpName);
Primiano Tucci (use gerrit) 2015/08/26 15:34:01 do you need the GetOrCreate semantic also here? if
ssid 2015/08/26 15:45:19 Ah, sorry. I just updated the CL. after i sent for
+ process_memory_dump_->AddSuballocation(
+ mad->guid(), base::trace_event::MemoryDumpManager::GetInstance()
+ ->system_allocator_pool_name());
+ }
+}
+
+void SkTraceMemoryDump_Chrome::setDiscardableMemoryBacking(
+ const char* dumpName,
+ const SkDiscardableMemory& discardableMemoryObject) {
+ DCHECK(!process_memory_dump_->GetAllocatorDump(dumpName));
+ const SkDiscardableMemoryChrome& memory =
Primiano Tucci (use gerrit) 2015/08/26 15:34:01 why this dcheck. don't you want the GetOrCreate se
ssid 2015/08/26 15:45:19 Hm, hard failing here because it will fail inside
+ static_cast<const SkDiscardableMemoryChrome&>(discardableMemoryObject);
+ auto mad = memory.CreateMemoryAllocatorDump(dumpName, process_memory_dump_);
+ DCHECK(mad);
Primiano Tucci (use gerrit) 2015/08/26 15:34:01 please s/memory/discardable_memory_obj/ or similar
ssid 2015/08/26 15:45:19 Done.
+}
+
+} // namespace skia

Powered by Google App Engine
This is Rietveld 408576698