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

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

Issue 1293873005: Expire resources in ResourcePool after non-use (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@re-use
Patch Set: Created 5 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
« no previous file with comments | « no previous file | cc/resources/resource_pool.cc » ('j') | cc/resources/resource_pool.cc » ('J')
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 <deque> 8 #include <deque>
9 9
10 #include "base/containers/scoped_ptr_map.h" 10 #include "base/containers/scoped_ptr_map.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 ResourceProvider* resource_provider) { 70 ResourceProvider* resource_provider) {
71 return make_scoped_ptr(new PoolResource(resource_provider)); 71 return make_scoped_ptr(new PoolResource(resource_provider));
72 } 72 }
73 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, 73 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
74 const ResourceProvider* resource_provider, 74 const ResourceProvider* resource_provider,
75 bool is_free) const; 75 bool is_free) const;
76 76
77 uint64_t content_id() const { return content_id_; } 77 uint64_t content_id() const { return content_id_; }
78 void set_content_id(uint64_t content_id) { content_id_ = content_id; } 78 void set_content_id(uint64_t content_id) { content_id_ = content_id; }
79 79
80 base::TimeTicks last_usage() const { return last_usage_; }
81 void set_last_usage(base::TimeTicks time) { last_usage_ = time; }
82
80 private: 83 private:
81 explicit PoolResource(ResourceProvider* resource_provider) 84 explicit PoolResource(ResourceProvider* resource_provider)
82 : ScopedResource(resource_provider), content_id_(0) {} 85 : ScopedResource(resource_provider), content_id_(0) {}
83 uint64_t content_id_; 86 uint64_t content_id_;
87 base::TimeTicks last_usage_;
84 }; 88 };
85 89
86 void DidFinishUsingResource(scoped_ptr<PoolResource> resource); 90 void DidFinishUsingResource(scoped_ptr<PoolResource> resource);
87 void DeleteResource(scoped_ptr<PoolResource> resource); 91 void DeleteResource(scoped_ptr<PoolResource> resource);
92 void DeleteUnusedResource(scoped_ptr<PoolResource> resource);
93
94 // Functions which manage periodic eviction of expired resources.
95 void ScheduleEvictExpiredResources();
96 void EvictExpiredResources();
97 void EvictResourcesNotUsedSince(base::TimeTicks time_limit);
98 bool HasEvictableResources() const;
99 base::TimeTicks GetUsageTimeForLRUResource() const;
88 100
89 ResourceProvider* resource_provider_; 101 ResourceProvider* resource_provider_;
90 const GLenum target_; 102 const GLenum target_;
91 size_t max_memory_usage_bytes_; 103 size_t max_memory_usage_bytes_;
92 size_t max_unused_memory_usage_bytes_; 104 size_t max_unused_memory_usage_bytes_;
reveman 2015/08/20 21:43:37 Let's remove all traces of unused usage based evic
ericrk 2015/08/21 12:48:22 Done.
93 size_t max_resource_count_; 105 size_t max_resource_count_;
94 size_t memory_usage_bytes_; 106 size_t memory_usage_bytes_;
95 size_t unused_memory_usage_bytes_; 107 size_t unused_memory_usage_bytes_;
reveman 2015/08/20 21:43:37 I think this member can also be removed.
ericrk 2015/08/21 12:48:22 This is still sort of nice to track - we trace thi
96 size_t resource_count_; 108 size_t resource_count_;
97 109
98 using ResourceDeque = ScopedPtrDeque<PoolResource>; 110 using ResourceDeque = ScopedPtrDeque<PoolResource>;
99 ResourceDeque unused_resources_; 111 ResourceDeque unused_resources_;
100 ResourceDeque busy_resources_; 112 ResourceDeque busy_resources_;
101 113
102 using ResourceMap = base::ScopedPtrMap<ResourceId, scoped_ptr<PoolResource>>; 114 using ResourceMap = base::ScopedPtrMap<ResourceId, scoped_ptr<PoolResource>>;
103 ResourceMap in_use_resources_; 115 ResourceMap in_use_resources_;
104 116
117 bool evict_expired_resources_pending_;
118 base::TimeDelta resource_expiration_delay_;
119 base::Closure evict_expired_resources_callback_;
120
121 base::WeakPtrFactory<ResourcePool> weak_ptr_factory_;
122
105 DISALLOW_COPY_AND_ASSIGN(ResourcePool); 123 DISALLOW_COPY_AND_ASSIGN(ResourcePool);
106 }; 124 };
107 125
108 } // namespace cc 126 } // namespace cc
109 127
110 #endif // CC_RESOURCES_RESOURCE_POOL_H_ 128 #endif // CC_RESOURCES_RESOURCE_POOL_H_
OLDNEW
« no previous file with comments | « no previous file | cc/resources/resource_pool.cc » ('j') | cc/resources/resource_pool.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698