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

Side by Side Diff: cc/resources/resource_pool.h

Issue 2367953002: Implement OnMemoryStateChange for Various CC Classes (Closed)
Patch Set: feedback Created 4 years, 2 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
« no previous file with comments | « cc/raster/staging_buffer_pool.cc ('k') | cc/resources/resource_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_RESOURCES_RESOURCE_POOL_H_ 5 #ifndef CC_RESOURCES_RESOURCE_POOL_H_
6 #define CC_RESOURCES_RESOURCE_POOL_H_ 6 #define CC_RESOURCES_RESOURCE_POOL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // pool. 78 // pool.
79 void CheckBusyResources(); 79 void CheckBusyResources();
80 80
81 size_t memory_usage_bytes() const { return in_use_memory_usage_bytes_; } 81 size_t memory_usage_bytes() const { return in_use_memory_usage_bytes_; }
82 size_t resource_count() const { return in_use_resources_.size(); } 82 size_t resource_count() const { return in_use_resources_.size(); }
83 83
84 // Overridden from base::trace_event::MemoryDumpProvider: 84 // Overridden from base::trace_event::MemoryDumpProvider:
85 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, 85 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
86 base::trace_event::ProcessMemoryDump* pmd) override; 86 base::trace_event::ProcessMemoryDump* pmd) override;
87 87
88 // Overriden from base::MemoryCoordinatorClient.
89 void OnMemoryStateChange(base::MemoryState state) override;
90
88 size_t GetTotalMemoryUsageForTesting() const { 91 size_t GetTotalMemoryUsageForTesting() const {
89 return total_memory_usage_bytes_; 92 return total_memory_usage_bytes_;
90 } 93 }
91 size_t GetTotalResourceCountForTesting() const { 94 size_t GetTotalResourceCountForTesting() const {
92 return total_resource_count_; 95 return total_resource_count_;
93 } 96 }
94 size_t GetBusyResourceCountForTesting() const { 97 size_t GetBusyResourceCountForTesting() const {
95 return busy_resources_.size(); 98 return busy_resources_.size();
96 } 99 }
97 100
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 uint64_t new_content_id, 154 uint64_t new_content_id,
152 const gfx::Rect& new_invalidated_rect); 155 const gfx::Rect& new_invalidated_rect);
153 156
154 // Functions which manage periodic eviction of expired resources. 157 // Functions which manage periodic eviction of expired resources.
155 void ScheduleEvictExpiredResourcesIn(base::TimeDelta time_from_now); 158 void ScheduleEvictExpiredResourcesIn(base::TimeDelta time_from_now);
156 void EvictExpiredResources(); 159 void EvictExpiredResources();
157 void EvictResourcesNotUsedSince(base::TimeTicks time_limit); 160 void EvictResourcesNotUsedSince(base::TimeTicks time_limit);
158 bool HasEvictableResources() const; 161 bool HasEvictableResources() const;
159 base::TimeTicks GetUsageTimeForLRUResource() const; 162 base::TimeTicks GetUsageTimeForLRUResource() const;
160 163
161 // Overriden from base::MemoryCoordinatorClient.
162 void OnMemoryStateChange(base::MemoryState state) override;
163
164 ResourceProvider* resource_provider_; 164 ResourceProvider* resource_provider_;
165 bool use_gpu_memory_buffers_; 165 bool use_gpu_memory_buffers_;
166 gfx::BufferUsage usage_; 166 gfx::BufferUsage usage_;
167 size_t max_memory_usage_bytes_; 167 size_t max_memory_usage_bytes_;
168 size_t max_resource_count_; 168 size_t max_resource_count_;
169 size_t in_use_memory_usage_bytes_; 169 size_t in_use_memory_usage_bytes_;
170 size_t total_memory_usage_bytes_; 170 size_t total_memory_usage_bytes_;
171 size_t total_resource_count_; 171 size_t total_resource_count_;
172 172
173 // Holds most recently used resources at the front of the queue. 173 // Holds most recently used resources at the front of the queue.
174 using ResourceDeque = std::deque<std::unique_ptr<PoolResource>>; 174 using ResourceDeque = std::deque<std::unique_ptr<PoolResource>>;
175 ResourceDeque unused_resources_; 175 ResourceDeque unused_resources_;
176 ResourceDeque busy_resources_; 176 ResourceDeque busy_resources_;
177 177
178 using InUseResourceMap = std::map<ResourceId, std::unique_ptr<PoolResource>>; 178 using InUseResourceMap = std::map<ResourceId, std::unique_ptr<PoolResource>>;
179 InUseResourceMap in_use_resources_; 179 InUseResourceMap in_use_resources_;
180 180
181 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 181 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
182 bool evict_expired_resources_pending_; 182 bool evict_expired_resources_pending_;
183 const base::TimeDelta resource_expiration_delay_; 183 const base::TimeDelta resource_expiration_delay_;
184 184
185 base::WeakPtrFactory<ResourcePool> weak_ptr_factory_; 185 base::WeakPtrFactory<ResourcePool> weak_ptr_factory_;
186 186
187 DISALLOW_COPY_AND_ASSIGN(ResourcePool); 187 DISALLOW_COPY_AND_ASSIGN(ResourcePool);
188 }; 188 };
189 189
190 } // namespace cc 190 } // namespace cc
191 191
192 #endif // CC_RESOURCES_RESOURCE_POOL_H_ 192 #endif // CC_RESOURCES_RESOURCE_POOL_H_
OLDNEW
« no previous file with comments | « cc/raster/staging_buffer_pool.cc ('k') | cc/resources/resource_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698