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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_TRACKING_H_
6 #define CONTENT_COMMON_GPU_GPU_MEMORY_TRACKING_H_
7
8 #if defined(ENABLE_GPU)
9
10 #include "base/basictypes.h"
11 #include "content/common/gpu/gpu_memory_manager.h"
12
13 // All decoders in a context group point to a single GpuMemoryTrackingGroup,
14 // which tracks GPU resource consumption for the entire context group.
15 class GpuMemoryTrackingGroup {
16 public:
17 GpuMemoryTrackingGroup(base::ProcessId pid, GpuMemoryManager* memory_manager)
18 : pid_(pid),
19 size_(0),
20 memory_manager_(memory_manager) {
21 memory_manager_->AddTrackingGroup(this);
22 }
23 ~GpuMemoryTrackingGroup() {
24 memory_manager_->RemoveTrackingGroup(this);
25 }
26 void TrackMemoryAllocatedChange(size_t old_size, size_t new_size) {
27 if (old_size < new_size) {
28 size_t delta = new_size - old_size;
29 size_ += delta;
30 }
31 if (new_size < old_size) {
32 size_t delta = old_size - new_size;
33 DCHECK(size_ >= delta);
34 size_ -= delta;
35 }
36 memory_manager_->TrackMemoryAllocatedChange(old_size, new_size);
37 }
38 base::ProcessId GetPid() const {
39 return pid_;
40 }
41 size_t GetSize() const {
42 return size_;
43 }
44
45 private:
46 base::ProcessId pid_;
47 size_t size_;
48 GpuMemoryManager* memory_manager_;
49 };
50
51 #endif
52
53 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_TRACKING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698