| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // This is the browser side of the cache manager, it tracks the activity of the | 5 // This is the browser side of the cache manager, it tracks the activity of the |
| 6 // render processes and allocates available memory cache resources. | 6 // render processes and allocates available memory cache resources. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_CACHE_MANAGER_HOST_H__ | 8 #ifndef CHROME_BROWSER_CACHE_MANAGER_HOST_H__ |
| 9 #define CHROME_BROWSER_CACHE_MANAGER_HOST_H__ | 9 #define CHROME_BROWSER_CACHE_MANAGER_HOST_H__ |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // An allocation is the number of bytes a specific renderer should use for | 80 // An allocation is the number of bytes a specific renderer should use for |
| 81 // its cache. | 81 // its cache. |
| 82 typedef std::pair<int,size_t> Allocation; | 82 typedef std::pair<int,size_t> Allocation; |
| 83 | 83 |
| 84 // An allocation strategy is a list of allocations specifying the resources | 84 // An allocation strategy is a list of allocations specifying the resources |
| 85 // each renderer is permitted to consume for its cache. | 85 // each renderer is permitted to consume for its cache. |
| 86 typedef std::list<Allocation> AllocationStrategy; | 86 typedef std::list<Allocation> AllocationStrategy; |
| 87 | 87 |
| 88 // This class is a singleton. Do not instantiate directly. | 88 // This class is a singleton. Do not instantiate directly. |
| 89 CacheManagerHost(); | 89 CacheManagerHost(); |
| 90 friend DefaultSingletonTraits<CacheManagerHost>; | 90 friend struct DefaultSingletonTraits<CacheManagerHost>; |
| 91 | 91 |
| 92 ~CacheManagerHost(); | 92 ~CacheManagerHost(); |
| 93 | 93 |
| 94 // Recomputes the allocation of cache resources among the renderers. Also | 94 // Recomputes the allocation of cache resources among the renderers. Also |
| 95 // informs the renderers of their new allocation. | 95 // informs the renderers of their new allocation. |
| 96 void ReviseAllocationStrategy(); | 96 void ReviseAllocationStrategy(); |
| 97 | 97 |
| 98 // Schedules a call to ReviseAllocationStrategy after a short delay. | 98 // Schedules a call to ReviseAllocationStrategy after a short delay. |
| 99 void ReviseAllocationStrategyLater(); | 99 void ReviseAllocationStrategyLater(); |
| 100 | 100 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 130 // Helper functions for devising an allocation strategy | 130 // Helper functions for devising an allocation strategy |
| 131 | 131 |
| 132 // Add up all the stats from the given set of renderers and place the result | 132 // Add up all the stats from the given set of renderers and place the result |
| 133 // in |stats|. | 133 // in |stats|. |
| 134 void GatherStats(const std::set<int>& renderers, | 134 void GatherStats(const std::set<int>& renderers, |
| 135 CacheManager::UsageStats* stats); | 135 CacheManager::UsageStats* stats); |
| 136 | 136 |
| 137 // Get the amount of memory that would be required to implement |tactic| | 137 // Get the amount of memory that would be required to implement |tactic| |
| 138 // using the specified allocation tactic. This function defines the | 138 // using the specified allocation tactic. This function defines the |
| 139 // semantics for each of the tactics. | 139 // semantics for each of the tactics. |
| 140 static size_t CacheManagerHost::GetSize(AllocationTactic tactic, | 140 static size_t GetSize(AllocationTactic tactic, |
| 141 const CacheManager::UsageStats& stats)
; | 141 const CacheManager::UsageStats& stats); |
| 142 | 142 |
| 143 // Attempt to use the specified tactics to compute an allocation strategy | 143 // Attempt to use the specified tactics to compute an allocation strategy |
| 144 // and place the result in |strategy|. |active_stats| and |inactive_stats| | 144 // and place the result in |strategy|. |active_stats| and |inactive_stats| |
| 145 // are the aggregate statistics for |active_renderers_| and | 145 // are the aggregate statistics for |active_renderers_| and |
| 146 // |inactive_renderers_|, respectively. | 146 // |inactive_renderers_|, respectively. |
| 147 // | 147 // |
| 148 // Returns |true| on success and |false| on failure. Does not modify | 148 // Returns |true| on success and |false| on failure. Does not modify |
| 149 // |strategy| on failure. | 149 // |strategy| on failure. |
| 150 bool AttemptTactic(AllocationTactic active_tactic, | 150 bool AttemptTactic(AllocationTactic active_tactic, |
| 151 const CacheManager::UsageStats& active_stats, | 151 const CacheManager::UsageStats& active_stats, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // recently than they have been active. | 183 // recently than they have been active. |
| 184 std::set<int> inactive_renderers_; | 184 std::set<int> inactive_renderers_; |
| 185 | 185 |
| 186 ScopedRunnableMethodFactory<CacheManagerHost> revise_allocation_factory_; | 186 ScopedRunnableMethodFactory<CacheManagerHost> revise_allocation_factory_; |
| 187 | 187 |
| 188 DISALLOW_EVIL_CONSTRUCTORS(CacheManagerHost); | 188 DISALLOW_EVIL_CONSTRUCTORS(CacheManagerHost); |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 #endif // CHROME_BROWSER_CACHE_MANAGER_HOST_H__ | 191 #endif // CHROME_BROWSER_CACHE_MANAGER_HOST_H__ |
| 192 | 192 |
| OLD | NEW |