OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "content/browser/renderer_host/backing_store_manager.h" | 5 #include "content/browser/renderer_host/backing_store_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/mru_cache.h" | 9 #include "base/memory/mru_cache.h" |
10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // Limit the number of large backing stores (tabs) to the memory tier number | 138 // Limit the number of large backing stores (tabs) to the memory tier number |
139 // (between 2-5). While we allow a larger amount of memory for people who | 139 // (between 2-5). While we allow a larger amount of memory for people who |
140 // have large windows, this means that those who use small browser windows | 140 // have large windows, this means that those who use small browser windows |
141 // won't ever cache more than 5 tabs, so they pay a smaller memory cost. | 141 // won't ever cache more than 5 tabs, so they pay a smaller memory cost. |
142 if (large_cache->size() >= MaxNumberOfBackingStores()) | 142 if (large_cache->size() >= MaxNumberOfBackingStores()) |
143 ExpireLastBackingStore(large_cache); | 143 ExpireLastBackingStore(large_cache); |
144 cache = large_cache; | 144 cache = large_cache; |
145 } else { | 145 } else { |
146 cache = small_cache; | 146 cache = small_cache; |
147 } | 147 } |
148 BackingStore* backing_store = static_cast<RenderWidgetHostImpl*>( | 148 BackingStore* backing_store = |
149 host)->AllocBackingStore(backing_store_size); | 149 RenderWidgetHostImpl::From(host)->AllocBackingStore(backing_store_size); |
150 if (backing_store) | 150 if (backing_store) |
151 cache->Put(host, backing_store); | 151 cache->Put(host, backing_store); |
152 return backing_store; | 152 return backing_store; |
153 } | 153 } |
154 | 154 |
155 int ComputeTotalArea(const std::vector<gfx::Rect>& rects) { | 155 int ComputeTotalArea(const std::vector<gfx::Rect>& rects) { |
156 // We assume that the given rects are non-overlapping, which is a property of | 156 // We assume that the given rects are non-overlapping, which is a property of |
157 // the paint rects generated by the PaintAggregator. | 157 // the paint rects generated by the PaintAggregator. |
158 #ifndef NDEBUG | 158 #ifndef NDEBUG |
159 for (size_t i = 0; i < rects.size(); ++i) { | 159 for (size_t i = 0; i < rects.size(); ++i) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 !(backing_store = CreateBackingStore(host, backing_store_size))) { | 209 !(backing_store = CreateBackingStore(host, backing_store_size))) { |
210 DCHECK(needs_full_paint != NULL); | 210 DCHECK(needs_full_paint != NULL); |
211 *needs_full_paint = true; | 211 *needs_full_paint = true; |
212 *scheduled_completion_callback = false; | 212 *scheduled_completion_callback = false; |
213 // Makes no sense to paint the transport dib if we are going | 213 // Makes no sense to paint the transport dib if we are going |
214 // to request a full paint. | 214 // to request a full paint. |
215 return; | 215 return; |
216 } | 216 } |
217 } | 217 } |
218 | 218 |
219 backing_store->PaintToBackingStore(host->process(), bitmap, | 219 backing_store->PaintToBackingStore(host->GetProcess(), bitmap, |
220 bitmap_rect, copy_rects, | 220 bitmap_rect, copy_rects, |
221 completion_callback, | 221 completion_callback, |
222 scheduled_completion_callback); | 222 scheduled_completion_callback); |
223 } | 223 } |
224 | 224 |
225 // static | 225 // static |
226 BackingStore* BackingStoreManager::Lookup(RenderWidgetHost* host) { | 226 BackingStore* BackingStoreManager::Lookup(RenderWidgetHost* host) { |
227 if (large_cache) { | 227 if (large_cache) { |
228 BackingStoreCache::iterator it = large_cache->Get(host); | 228 BackingStoreCache::iterator it = large_cache->Get(host); |
229 if (it != large_cache->end()) | 229 if (it != large_cache->end()) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 size_t mem = 0; | 269 size_t mem = 0; |
270 BackingStoreCache::iterator it; | 270 BackingStoreCache::iterator it; |
271 for (it = large_cache->begin(); it != large_cache->end(); ++it) | 271 for (it = large_cache->begin(); it != large_cache->end(); ++it) |
272 mem += it->second->MemorySize(); | 272 mem += it->second->MemorySize(); |
273 | 273 |
274 for (it = small_cache->begin(); it != small_cache->end(); ++it) | 274 for (it = small_cache->begin(); it != small_cache->end(); ++it) |
275 mem += it->second->MemorySize(); | 275 mem += it->second->MemorySize(); |
276 | 276 |
277 return mem; | 277 return mem; |
278 } | 278 } |
OLD | NEW |