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

Unified Diff: content/common/host_shared_bitmap_manager.cc

Issue 1099403008: content: Add SharedBitmap MemoryDumpProvider implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove kNameInnerSize Created 5 years, 8 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
« no previous file with comments | « content/common/host_shared_bitmap_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/host_shared_bitmap_manager.cc
diff --git a/content/common/host_shared_bitmap_manager.cc b/content/common/host_shared_bitmap_manager.cc
index b95820c2f32c44867d7b3abba5f2b05d70f1d00d..3e499d648d03fc0666186a4f8e9ecffbceb9093f 100644
--- a/content/common/host_shared_bitmap_manager.cc
+++ b/content/common/host_shared_bitmap_manager.cc
@@ -6,6 +6,10 @@
#include "base/lazy_instance.h"
#include "base/memory/ref_counted.h"
+#include "base/strings/stringprintf.h"
+#include "base/thread_task_runner_handle.h"
+#include "base/trace_event/memory_dump_manager.h"
+#include "base/trace_event/process_memory_dump.h"
#include "content/common/view_messages.h"
#include "ui/gfx/geometry/size.h"
@@ -50,6 +54,8 @@ class HostSharedBitmap : public cc::SharedBitmap {
HostSharedBitmapManager* manager_;
};
+const char kMemoryAllocatorName[] = "sharedbitmap";
+
} // namespace
base::LazyInstance<HostSharedBitmapManager> g_shared_memory_manager =
@@ -90,9 +96,15 @@ void HostSharedBitmapManagerClient::ChildDeletedSharedBitmap(
owned_bitmaps_.erase(id);
}
-HostSharedBitmapManager::HostSharedBitmapManager() {}
+HostSharedBitmapManager::HostSharedBitmapManager() {
+ base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
+ this);
Primiano Tucci (use gerrit) 2015/04/28 21:40:06 I think you want a task_runner (IIRC the HostSBM i
reveman 2015/04/29 01:45:58 This is a singleton. See HostSharedBitmapManager::
+}
+
HostSharedBitmapManager::~HostSharedBitmapManager() {
DCHECK(handle_map_.empty());
+ base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
+ this);
Primiano Tucci (use gerrit) 2015/04/28 21:40:06 Hmm if you unregister you should specify a task_ru
reveman 2015/04/29 01:45:58 Makes sense. I moved RegisterDumpProvider() call t
}
HostSharedBitmapManager* HostSharedBitmapManager::current() {
@@ -146,6 +158,29 @@ scoped_ptr<cc::SharedBitmap> HostSharedBitmapManager::GetSharedBitmapFromId(
static_cast<uint8*>(data->memory->memory()), data, id, nullptr));
}
+bool HostSharedBitmapManager::OnMemoryDump(
+ base::trace_event::ProcessMemoryDump* pmd) {
+ base::AutoLock lock(lock_);
+
+ for (const auto& bitmap_it : handle_map_) {
+ std::string heap_name;
+
+ for (size_t i = 0; i < sizeof(bitmap_it.first.name); ++i)
+ base::StringAppendF(&heap_name, "%02x", bitmap_it.first.name[i]);
+
+ base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(
+ base::StringPrintf("%s/%s", kMemoryAllocatorName, heap_name.c_str()));
+ if (!dump)
+ return false;
+
+ dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameOuterSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ bitmap_it.second->buffer_size);
+ }
+
+ return true;
+}
+
void HostSharedBitmapManager::ChildAllocatedSharedBitmap(
size_t buffer_size,
const base::SharedMemoryHandle& handle,
« no previous file with comments | « content/common/host_shared_bitmap_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698