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

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: Allow only one outstanding vidmem refresh 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..0f12a51a752bde3c0e2722cfafdea8a081ed452d 100644
--- a/content/common/gpu/gpu_memory_manager.cc
+++ b/content/common/gpu/gpu_memory_manager.cc
@@ -12,6 +12,7 @@
#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"
@@ -92,6 +93,7 @@ GpuMemoryManager::GpuMemoryManager(GpuMemoryManagerClient* client,
}
GpuMemoryManager::~GpuMemoryManager() {
+ DCHECK(tracking_groups_.empty());
}
bool GpuMemoryManager::StubWithSurfaceComparator::operator()(
@@ -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::GetVidmem(content::GPUVidmem& vidmem) const
+{
+ // For each context group, assign its memory usage to its PID
+ vidmem.process_map.clear();
+ for (std::set<GpuMemoryTrackingGroup*>::const_iterator i =
+ tracking_groups_.begin(); i != tracking_groups_.end(); ++i) {
+ const GpuMemoryTrackingGroup* tracking_group = (*i);
+ vidmem.process_map[tracking_group->GetPid()].vidmem +=
+ tracking_group->GetSize();
+ }
+
+ // Assign the total across all processes in the GPU process
+ vidmem.process_map[base::GetCurrentProcId()].vidmem =
+ bytes_allocated_current_;
+ vidmem.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