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

Side by Side Diff: chrome/browser/renderer_host/web_cache_manager.cc

Issue 258663002: Expose a low-end device mode override flags for non-android OSs as well (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Forward command-line flags to renderer and gpu processes Created 6 years, 7 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
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 "chrome/browser/renderer_host/web_cache_manager.h" 5 #include "chrome/browser/renderer_host/web_cache_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/prefs/pref_registry_simple.h" 14 #include "base/prefs/pref_registry_simple.h"
15 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
16 #include "base/sys_info.h" 16 #include "base/sys_info.h"
17 #include "base/sys_utils.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chrome_notification_types.h" 20 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/common/chrome_constants.h" 21 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
22 #include "chrome/common/render_messages.h" 23 #include "chrome/common/render_messages.h"
23 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/render_process_host.h" 25 #include "content/public/browser/render_process_host.h"
25 26
26 #if defined(OS_ANDROID)
27 #include "base/android/sys_utils.h"
28 #endif
29
30 using base::Time; 27 using base::Time;
31 using base::TimeDelta; 28 using base::TimeDelta;
32 using blink::WebCache; 29 using blink::WebCache;
33 30
34 static const int kReviseAllocationDelayMS = 200; 31 static const int kReviseAllocationDelayMS = 200;
35 32
36 // The default size limit of the in-memory cache is 8 MB 33 // The default size limit of the in-memory cache is 8 MB
37 static const int kDefaultMemoryCacheSize = 8 * 1024 * 1024; 34 static const int kDefaultMemoryCacheSize = 8 * 1024 * 1024;
38 35
39 namespace { 36 namespace {
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 // This is the capacity this renderer has been allocated. 316 // This is the capacity this renderer has been allocated.
320 size_t capacity = allocation->second; 317 size_t capacity = allocation->second;
321 318
322 // We don't reserve any space for dead objects in the cache. Instead, we 319 // We don't reserve any space for dead objects in the cache. Instead, we
323 // prefer to keep live objects around. There is probably some performance 320 // prefer to keep live objects around. There is probably some performance
324 // tuning to be done here. 321 // tuning to be done here.
325 size_t min_dead_capacity = 0; 322 size_t min_dead_capacity = 0;
326 323
327 // We allow the dead objects to consume up to half of the cache capacity. 324 // We allow the dead objects to consume up to half of the cache capacity.
328 size_t max_dead_capacity = capacity / 2; 325 size_t max_dead_capacity = capacity / 2;
329 #if defined(OS_ANDROID) 326 if (base::SysUtils::IsLowEndDevice())
brettw 2014/06/09 22:49:57 Can you put {} in this block since it's more than
c.shu 2014/06/10 17:36:26 Done.
330 if (base::android::SysUtils::IsLowEndDevice())
331 max_dead_capacity = std::min(static_cast<size_t>(512 * 1024), 327 max_dead_capacity = std::min(static_cast<size_t>(512 * 1024),
332 max_dead_capacity); 328 max_dead_capacity);
333 #endif
334 329
335 host->Send(new ChromeViewMsg_SetCacheCapacities(min_dead_capacity, 330 host->Send(new ChromeViewMsg_SetCacheCapacities(min_dead_capacity,
336 max_dead_capacity, 331 max_dead_capacity,
337 capacity)); 332 capacity));
338 } 333 }
339 ++allocation; 334 ++allocation;
340 } 335 }
341 } 336 }
342 337
343 void WebCacheManager::ClearRendererCache( 338 void WebCacheManager::ClearRendererCache(
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { 436 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) {
442 // Moved to inactive status. This invalidates our iterator. 437 // Moved to inactive status. This invalidates our iterator.
443 inactive_renderers_.insert(*iter); 438 inactive_renderers_.insert(*iter);
444 active_renderers_.erase(*iter); 439 active_renderers_.erase(*iter);
445 iter = active_renderers_.begin(); 440 iter = active_renderers_.begin();
446 continue; 441 continue;
447 } 442 }
448 ++iter; 443 ++iter;
449 } 444 }
450 } 445 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698