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

Unified Diff: cc/playback/display_list_raster_source.cc

Issue 1725553002: Dump DisplayListRasterSource memory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing include for windows build Created 4 years, 10 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 | « cc/playback/display_list_raster_source.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/playback/display_list_raster_source.cc
diff --git a/cc/playback/display_list_raster_source.cc b/cc/playback/display_list_raster_source.cc
index f20252d66fac46a8549a7a26761a32a557b7eafe..ea4c337af27142b1ac9ba01bbb001306f2c7e1c4 100644
--- a/cc/playback/display_list_raster_source.cc
+++ b/cc/playback/display_list_raster_source.cc
@@ -7,6 +7,9 @@
#include <stddef.h>
#include "base/containers/adapters.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/trace_event.h"
#include "cc/base/region.h"
#include "cc/debug/debug_colors.h"
@@ -209,7 +212,16 @@ DisplayListRasterSource::DisplayListRasterSource(
slow_down_raster_scale_factor_for_debug_(
other->slow_down_raster_scale_factor_for_debug_),
should_attempt_to_use_distance_field_text_(false),
- image_decode_controller_(nullptr) {}
+ image_decode_controller_(nullptr) {
+ // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview).
+ // Don't register a dump provider in these cases.
+ // TODO(ericrk): Get this working in Android Webview. crbug.com/517156
+ if (base::ThreadTaskRunnerHandle::IsSet()) {
+ base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
+ this, "cc::DisplayListRasterSource",
+ base::ThreadTaskRunnerHandle::Get());
+ }
+}
DisplayListRasterSource::DisplayListRasterSource(
const DisplayListRasterSource* other,
@@ -228,9 +240,23 @@ DisplayListRasterSource::DisplayListRasterSource(
other->slow_down_raster_scale_factor_for_debug_),
should_attempt_to_use_distance_field_text_(
other->should_attempt_to_use_distance_field_text_),
- image_decode_controller_(other->image_decode_controller_) {}
+ image_decode_controller_(other->image_decode_controller_) {
+ // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview).
+ // Don't register a dump provider in these cases.
+ // TODO(ericrk): Get this working in Android Webview. crbug.com/517156
+ if (base::ThreadTaskRunnerHandle::IsSet()) {
+ base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
+ this, "cc::DisplayListRasterSource",
+ base::ThreadTaskRunnerHandle::Get());
+ }
+}
DisplayListRasterSource::~DisplayListRasterSource() {
+ // For MemoryDumpProvider deregistration to work correctly, this must happen
+ // on the same thread that the DisplayListRasterSource was created on.
+ DCHECK(memory_dump_thread_checker_.CalledOnValidThread());
+ base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
+ this);
}
void DisplayListRasterSource::PlaybackToSharedCanvas(
@@ -507,4 +533,22 @@ void DisplayListRasterSource::SetImageDecodeController(
image_decode_controller_ = image_decode_controller;
}
+bool DisplayListRasterSource::OnMemoryDump(
+ const base::trace_event::MemoryDumpArgs& args,
+ base::trace_event::ProcessMemoryDump* pmd) {
+ DCHECK(memory_dump_thread_checker_.CalledOnValidThread());
+
+ uint64_t memory_usage = GetPictureMemoryUsage();
+ if (memory_usage > 0) {
+ std::string dump_name = base::StringPrintf(
+ "cc/display_lists/display_list_raster_source_%p", this);
+ base::trace_event::MemoryAllocatorDump* dump =
+ pmd->CreateAllocatorDump(dump_name);
+ dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ memory_usage);
+ }
+ return true;
+}
+
} // namespace cc
« no previous file with comments | « cc/playback/display_list_raster_source.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698