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

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

Issue 8568030: base::Bind() conversion in renderer_host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing #include for Mac Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/compiler_specific.h" 10 #include "base/compiler_specific.h"
10 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
11 #include "base/message_loop.h" 12 #include "base/message_loop.h"
12 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
13 #include "base/sys_info.h" 14 #include "base/sys_info.h"
14 #include "base/time.h" 15 #include "base/time.h"
15 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/prefs/pref_service.h" 17 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/common/chrome_constants.h" 18 #include "chrome/common/chrome_constants.h"
18 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 prefs->RegisterIntegerPref(prefs::kMemoryCacheSize, GetDefaultCacheSize()); 57 prefs->RegisterIntegerPref(prefs::kMemoryCacheSize, GetDefaultCacheSize());
57 } 58 }
58 59
59 // static 60 // static
60 WebCacheManager* WebCacheManager::GetInstance() { 61 WebCacheManager* WebCacheManager::GetInstance() {
61 return Singleton<WebCacheManager>::get(); 62 return Singleton<WebCacheManager>::get();
62 } 63 }
63 64
64 WebCacheManager::WebCacheManager() 65 WebCacheManager::WebCacheManager()
65 : global_size_limit_(GetDefaultGlobalSizeLimit()), 66 : global_size_limit_(GetDefaultGlobalSizeLimit()),
66 ALLOW_THIS_IN_INITIALIZER_LIST(revise_allocation_factory_(this)) { 67 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
67 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, 68 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED,
68 content::NotificationService::AllBrowserContextsAndSources()); 69 content::NotificationService::AllBrowserContextsAndSources());
69 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 70 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
70 content::NotificationService::AllBrowserContextsAndSources()); 71 content::NotificationService::AllBrowserContextsAndSources());
71 } 72 }
72 73
73 WebCacheManager::~WebCacheManager() { 74 WebCacheManager::~WebCacheManager() {
74 } 75 }
75 76
76 void WebCacheManager::Add(int renderer_id) { 77 void WebCacheManager::Add(int renderer_id) {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 } else { 409 } else {
409 // DIVIDE_EVENLY / DIVIDE_EVENLY should always succeed. 410 // DIVIDE_EVENLY / DIVIDE_EVENLY should always succeed.
410 NOTREACHED() << "Unable to find a cache allocation"; 411 NOTREACHED() << "Unable to find a cache allocation";
411 } 412 }
412 } 413 }
413 414
414 void WebCacheManager::ReviseAllocationStrategyLater() { 415 void WebCacheManager::ReviseAllocationStrategyLater() {
415 // Ask to be called back in a few milliseconds to actually recompute our 416 // Ask to be called back in a few milliseconds to actually recompute our
416 // allocation. 417 // allocation.
417 MessageLoop::current()->PostDelayedTask(FROM_HERE, 418 MessageLoop::current()->PostDelayedTask(FROM_HERE,
418 revise_allocation_factory_.NewRunnableMethod( 419 base::Bind(
419 &WebCacheManager::ReviseAllocationStrategy), 420 &WebCacheManager::ReviseAllocationStrategy,
421 weak_factory_.GetWeakPtr()),
420 kReviseAllocationDelayMS); 422 kReviseAllocationDelayMS);
421 } 423 }
422 424
423 void WebCacheManager::FindInactiveRenderers() { 425 void WebCacheManager::FindInactiveRenderers() {
424 std::set<int>::const_iterator iter = active_renderers_.begin(); 426 std::set<int>::const_iterator iter = active_renderers_.begin();
425 while (iter != active_renderers_.end()) { 427 while (iter != active_renderers_.end()) {
426 StatsMap::iterator elmt = stats_.find(*iter); 428 StatsMap::iterator elmt = stats_.find(*iter);
427 DCHECK(elmt != stats_.end()); 429 DCHECK(elmt != stats_.end());
428 TimeDelta idle = Time::Now() - elmt->second.access; 430 TimeDelta idle = Time::Now() - elmt->second.access;
429 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { 431 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) {
430 // Moved to inactive status. This invalidates our iterator. 432 // Moved to inactive status. This invalidates our iterator.
431 inactive_renderers_.insert(*iter); 433 inactive_renderers_.insert(*iter);
432 active_renderers_.erase(*iter); 434 active_renderers_.erase(*iter);
433 iter = active_renderers_.begin(); 435 iter = active_renderers_.begin();
434 continue; 436 continue;
435 } 437 }
436 ++iter; 438 ++iter;
437 } 439 }
438 } 440 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/web_cache_manager.h ('k') | content/browser/renderer_host/render_widget_host_view_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698