| OLD | NEW |
| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 uint64_t previous_content_id, | 64 uint64_t previous_content_id, |
| 65 gfx::Rect* total_invalidated_rect); | 65 gfx::Rect* total_invalidated_rect); |
| 66 | 66 |
| 67 // Called when a resource's content has been fully replaced (and is completely | 67 // Called when a resource's content has been fully replaced (and is completely |
| 68 // valid). Updates the resource's content ID to its new value. | 68 // valid). Updates the resource's content ID to its new value. |
| 69 void OnContentReplaced(ResourceId resource_id, uint64_t content_id); | 69 void OnContentReplaced(ResourceId resource_id, uint64_t content_id); |
| 70 void ReleaseResource(Resource* resource); | 70 void ReleaseResource(Resource* resource); |
| 71 | 71 |
| 72 void SetResourceUsageLimits(size_t max_memory_usage_bytes, | 72 void SetResourceUsageLimits(size_t max_memory_usage_bytes, |
| 73 size_t max_resource_count); | 73 size_t max_resource_count); |
| 74 | |
| 75 void ReduceResourceUsage(); | 74 void ReduceResourceUsage(); |
| 75 bool ResourceUsageTooHigh(); |
| 76 | 76 |
| 77 // Must be called regularly to move resources from the busy pool to the unused | 77 // Must be called regularly to move resources from the busy pool to the unused |
| 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, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 97 size_t GetBusyResourceCountForTesting() const { | 97 size_t GetBusyResourceCountForTesting() const { |
| 98 return busy_resources_.size(); | 98 return busy_resources_.size(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 protected: | 101 protected: |
| 102 ResourcePool(ResourceProvider* resource_provider, | 102 ResourcePool(ResourceProvider* resource_provider, |
| 103 base::SingleThreadTaskRunner* task_runner, | 103 base::SingleThreadTaskRunner* task_runner, |
| 104 bool use_gpu_memory_buffers, | 104 bool use_gpu_memory_buffers, |
| 105 const base::TimeDelta& expiration_delay); | 105 const base::TimeDelta& expiration_delay); |
| 106 | 106 |
| 107 bool ResourceUsageTooHigh(); | |
| 108 | |
| 109 private: | 107 private: |
| 110 FRIEND_TEST_ALL_PREFIXES(ResourcePoolTest, ReuseResource); | 108 FRIEND_TEST_ALL_PREFIXES(ResourcePoolTest, ReuseResource); |
| 111 class PoolResource : public ScopedResource { | 109 class PoolResource : public ScopedResource { |
| 112 public: | 110 public: |
| 113 static std::unique_ptr<PoolResource> Create( | 111 static std::unique_ptr<PoolResource> Create( |
| 114 ResourceProvider* resource_provider) { | 112 ResourceProvider* resource_provider) { |
| 115 return base::WrapUnique(new PoolResource(resource_provider)); | 113 return base::WrapUnique(new PoolResource(resource_provider)); |
| 116 } | 114 } |
| 117 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 115 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
| 118 const ResourceProvider* resource_provider, | 116 const ResourceProvider* resource_provider, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 const base::TimeDelta resource_expiration_delay_; | 181 const base::TimeDelta resource_expiration_delay_; |
| 184 | 182 |
| 185 base::WeakPtrFactory<ResourcePool> weak_ptr_factory_; | 183 base::WeakPtrFactory<ResourcePool> weak_ptr_factory_; |
| 186 | 184 |
| 187 DISALLOW_COPY_AND_ASSIGN(ResourcePool); | 185 DISALLOW_COPY_AND_ASSIGN(ResourcePool); |
| 188 }; | 186 }; |
| 189 | 187 |
| 190 } // namespace cc | 188 } // namespace cc |
| 191 | 189 |
| 192 #endif // CC_RESOURCES_RESOURCE_POOL_H_ | 190 #endif // CC_RESOURCES_RESOURCE_POOL_H_ |
| OLD | NEW |