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

Unified Diff: content/common/gpu/gpu_memory_tracking.h

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_tracking.h
diff --git a/content/common/gpu/gpu_memory_tracking.h b/content/common/gpu/gpu_memory_tracking.h
new file mode 100644
index 0000000000000000000000000000000000000000..c20ad850f675999bd39163dcc72aeb21b086007f
--- /dev/null
+++ b/content/common/gpu/gpu_memory_tracking.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2012 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.
+
+#ifndef CONTENT_COMMON_GPU_GPU_MEMORY_TRACKING_H_
+#define CONTENT_COMMON_GPU_GPU_MEMORY_TRACKING_H_
+
+#if defined(ENABLE_GPU)
+
+#include "base/basictypes.h"
+#include "content/common/gpu/gpu_memory_manager.h"
+
+// All decoders in a context group point to a single GpuMemoryTrackingGroup,
+// which tracks GPU resource consumption for the entire context group.
+class GpuMemoryTrackingGroup {
+ public:
+ GpuMemoryTrackingGroup(base::ProcessId pid, GpuMemoryManager* memory_manager)
+ : pid_(pid),
+ size_(0),
+ memory_manager_(memory_manager) {
+ memory_manager_->AddTrackingGroup(this);
+ }
+ ~GpuMemoryTrackingGroup() {
+ memory_manager_->RemoveTrackingGroup(this);
+ }
+ void TrackMemoryAllocatedChange(size_t old_size, size_t new_size) {
+ if (old_size < new_size) {
+ size_t delta = new_size - old_size;
+ size_ += delta;
+ }
+ if (new_size < old_size) {
+ size_t delta = old_size - new_size;
+ DCHECK(size_ >= delta);
+ size_ -= delta;
+ }
+ memory_manager_->TrackMemoryAllocatedChange(old_size, new_size);
+ }
+ base::ProcessId GetPid() const {
+ return pid_;
+ }
+ size_t GetSize() const {
+ return size_;
+ }
+
+ private:
+ base::ProcessId pid_;
+ size_t size_;
+ GpuMemoryManager* memory_manager_;
+};
+
+#endif
+
+#endif // CONTENT_COMMON_GPU_GPU_MEMORY_TRACKING_H_

Powered by Google App Engine
This is Rietveld 408576698