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

Side by Side Diff: content/browser/renderer_host/backing_store_manager.cc

Issue 10106022: TabContents -> WebContentsImpl, part 19. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 8 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
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 122
123 // TODO(erikkay) 32bpp is not always accurate 123 // TODO(erikkay) 32bpp is not always accurate
124 size_t new_mem = backing_store_size.GetArea() * 4; 124 size_t new_mem = backing_store_size.GetArea() * 4;
125 size_t current_mem = BackingStoreManager::MemorySize(); 125 size_t current_mem = BackingStoreManager::MemorySize();
126 size_t max_mem = MaxBackingStoreMemory(); 126 size_t max_mem = MaxBackingStoreMemory();
127 DCHECK(new_mem < max_mem); 127 DCHECK(new_mem < max_mem);
128 if (current_mem + new_mem > max_mem) { 128 if (current_mem + new_mem > max_mem) {
129 // Need to remove old backing stores to make room for the new one. We 129 // Need to remove old backing stores to make room for the new one. We
130 // don't want to do this when the backing store is being replace by a new 130 // don't want to do this when the backing store is being replace by a new
131 // one for the same tab, but this case won't get called then: we'll have 131 // one for the same WebContents, but this case won't get called then: we'll
132 // removed the old one in the RemoveBackingStore above, and the cache 132 // have removed the old one in the RemoveBackingStore above, and the cache
133 // won't be over-sized. 133 // won't be over-sized.
134 CreateCacheSpace((current_mem + new_mem) - max_mem); 134 CreateCacheSpace((current_mem + new_mem) - max_mem);
135 } 135 }
136 DCHECK((BackingStoreManager::MemorySize() + new_mem) <= max_mem); 136 DCHECK((BackingStoreManager::MemorySize() + new_mem) <= max_mem);
137 137
138 BackingStoreCache* cache; 138 BackingStoreCache* cache;
139 if (new_mem > kSmallThreshold) { 139 if (new_mem > kSmallThreshold) {
140 // Limit the number of large backing stores (tabs) to the memory tier number 140 // Limit the number of large backing stores (tabs) to the memory tier number
141 // (between 2-5). While we allow a larger amount of memory for people who 141 // (between 2-5). While we allow a larger amount of memory for people who
142 // have large windows, this means that those who use small browser windows 142 // have large windows, this means that those who use small browser windows
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 size_t mem = 0; 271 size_t mem = 0;
272 BackingStoreCache::iterator it; 272 BackingStoreCache::iterator it;
273 for (it = large_cache->begin(); it != large_cache->end(); ++it) 273 for (it = large_cache->begin(); it != large_cache->end(); ++it)
274 mem += it->second->MemorySize(); 274 mem += it->second->MemorySize();
275 275
276 for (it = small_cache->begin(); it != small_cache->end(); ++it) 276 for (it = small_cache->begin(); it != small_cache->end(); ++it)
277 mem += it->second->MemorySize(); 277 mem += it->second->MemorySize();
278 278
279 return mem; 279 return mem;
280 } 280 }
OLDNEW
« no previous file with comments | « content/browser/host_zoom_map_impl.h ('k') | content/browser/renderer_host/render_view_host_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698