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

Unified Diff: content/common/gpu/gpu_memory_manager.cc

Issue 10854076: Add GPU memory tab to the task manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate review feedback Created 8 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: content/common/gpu/gpu_memory_manager.cc
diff --git a/content/common/gpu/gpu_memory_manager.cc b/content/common/gpu/gpu_memory_manager.cc
index 945894e0c43f366039f4f6fd049c8992b6e91953..73469abf097b4df4c4b4a02a4eb8fcc830eb913a 100644
--- a/content/common/gpu/gpu_memory_manager.cc
+++ b/content/common/gpu/gpu_memory_manager.cc
@@ -12,9 +12,11 @@
#include "base/command_line.h"
#include "base/debug/trace_event.h"
#include "base/message_loop.h"
+#include "base/process_util.h"
#include "base/string_number_conversions.h"
#include "content/common/gpu/gpu_command_buffer_stub.h"
#include "content/common/gpu/gpu_memory_allocation.h"
+#include "content/common/gpu/gpu_memory_tracking.h"
#include "gpu/command_buffer/service/gpu_switches.h"
namespace {
@@ -92,6 +94,7 @@ GpuMemoryManager::GpuMemoryManager(GpuMemoryManagerClient* client,
}
GpuMemoryManager::~GpuMemoryManager() {
+ DCHECK(tracking_groups_.empty());
}
bool GpuMemoryManager::StubWithSurfaceComparator::operator()(
@@ -129,8 +132,7 @@ void GpuMemoryManager::ScheduleManage(bool immediate) {
}
void GpuMemoryManager::TrackMemoryAllocatedChange(size_t old_size,
- size_t new_size)
-{
+ size_t new_size) {
if (new_size < old_size) {
size_t delta = old_size - new_size;
DCHECK(bytes_allocated_current_ >= delta);
@@ -150,6 +152,34 @@ void GpuMemoryManager::TrackMemoryAllocatedChange(size_t old_size,
}
}
+void GpuMemoryManager::AddTrackingGroup(
+ GpuMemoryTrackingGroup* tracking_group) {
+ tracking_groups_.insert(tracking_group);
+}
+
+void GpuMemoryManager::RemoveTrackingGroup(
+ GpuMemoryTrackingGroup* tracking_group) {
+ tracking_groups_.erase(tracking_group);
+}
+
+void GpuMemoryManager::GetVideoMemoryUsageStats(
+ content::GPUVideoMemoryUsageStats& video_memory_usage_stats) const {
+ // For each context group, assign its memory usage to its PID
+ video_memory_usage_stats.process_map.clear();
+ for (std::set<GpuMemoryTrackingGroup*>::const_iterator i =
+ tracking_groups_.begin(); i != tracking_groups_.end(); ++i) {
+ const GpuMemoryTrackingGroup* tracking_group = (*i);
+ video_memory_usage_stats.process_map[
+ tracking_group->GetPid()].video_memory += tracking_group->GetSize();
+ }
+
+ // Assign the total across all processes in the GPU process
+ video_memory_usage_stats.process_map[
+ base::GetCurrentProcId()].video_memory = bytes_allocated_current_;
+ video_memory_usage_stats.process_map[
+ base::GetCurrentProcId()].has_duplicates = true;
+}
+
// The current Manage algorithm simply classifies contexts (stubs) into
// "foreground", "background", or "hibernated" categories.
// For each of these three categories, there are predefined memory allocation

Powered by Google App Engine
This is Rietveld 408576698