| OLD | NEW |
| 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 // 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 COMPONENTS_WEB_CACHE_BROWSER_WEB_CACHE_MANAGER_H_ | 8 #ifndef COMPONENTS_WEB_CACHE_BROWSER_WEB_CACHE_MANAGER_H_ |
| 9 #define COMPONENTS_WEB_CACHE_BROWSER_WEB_CACHE_MANAGER_H_ | 9 #define COMPONENTS_WEB_CACHE_BROWSER_WEB_CACHE_MANAGER_H_ |
| 10 | 10 |
| 11 #include <list> | 11 #include <list> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <set> | 13 #include <set> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 21 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 22 #include "third_party/WebKit/public/web/WebCache.h" | 22 #include "third_party/WebKit/public/web/WebCache.h" |
| 23 | 23 |
| 24 namespace base { |
| 24 template<typename Type> | 25 template<typename Type> |
| 25 struct DefaultSingletonTraits; | 26 struct DefaultSingletonTraits; |
| 27 } // namespace base |
| 28 |
| 26 class PrefRegistrySimple; | 29 class PrefRegistrySimple; |
| 27 | 30 |
| 28 namespace web_cache { | 31 namespace web_cache { |
| 29 | 32 |
| 30 class WebCacheManager : public content::NotificationObserver { | 33 class WebCacheManager : public content::NotificationObserver { |
| 31 friend class WebCacheManagerTest; | 34 friend class WebCacheManagerTest; |
| 32 FRIEND_TEST_ALL_PREFIXES( | 35 FRIEND_TEST_ALL_PREFIXES( |
| 33 WebCacheManagerTest, | 36 WebCacheManagerTest, |
| 34 CallRemoveRendererAndObserveActivityInAnyOrderShouldNotCrashTest_1); | 37 CallRemoveRendererAndObserveActivityInAnyOrderShouldNotCrashTest_1); |
| 35 FRIEND_TEST_ALL_PREFIXES( | 38 FRIEND_TEST_ALL_PREFIXES( |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // An allocation is the number of bytes a specific renderer should use for | 120 // An allocation is the number of bytes a specific renderer should use for |
| 118 // its cache. | 121 // its cache. |
| 119 typedef std::pair<int,size_t> Allocation; | 122 typedef std::pair<int,size_t> Allocation; |
| 120 | 123 |
| 121 // An allocation strategy is a list of allocations specifying the resources | 124 // An allocation strategy is a list of allocations specifying the resources |
| 122 // each renderer is permitted to consume for its cache. | 125 // each renderer is permitted to consume for its cache. |
| 123 typedef std::list<Allocation> AllocationStrategy; | 126 typedef std::list<Allocation> AllocationStrategy; |
| 124 | 127 |
| 125 // This class is a singleton. Do not instantiate directly. | 128 // This class is a singleton. Do not instantiate directly. |
| 126 WebCacheManager(); | 129 WebCacheManager(); |
| 127 friend struct DefaultSingletonTraits<WebCacheManager>; | 130 friend struct base::DefaultSingletonTraits<WebCacheManager>; |
| 128 | 131 |
| 129 ~WebCacheManager() override; | 132 ~WebCacheManager() override; |
| 130 | 133 |
| 131 // Recomputes the allocation of cache resources among the renderers. Also | 134 // Recomputes the allocation of cache resources among the renderers. Also |
| 132 // informs the renderers of their new allocation. | 135 // informs the renderers of their new allocation. |
| 133 void ReviseAllocationStrategy(); | 136 void ReviseAllocationStrategy(); |
| 134 | 137 |
| 135 // Schedules a call to ReviseAllocationStrategy after a short delay. | 138 // Schedules a call to ReviseAllocationStrategy after a short delay. |
| 136 void ReviseAllocationStrategyLater(); | 139 void ReviseAllocationStrategyLater(); |
| 137 | 140 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 content::NotificationRegistrar registrar_; | 238 content::NotificationRegistrar registrar_; |
| 236 | 239 |
| 237 base::WeakPtrFactory<WebCacheManager> weak_factory_; | 240 base::WeakPtrFactory<WebCacheManager> weak_factory_; |
| 238 | 241 |
| 239 DISALLOW_COPY_AND_ASSIGN(WebCacheManager); | 242 DISALLOW_COPY_AND_ASSIGN(WebCacheManager); |
| 240 }; | 243 }; |
| 241 | 244 |
| 242 } // namespace web_cache | 245 } // namespace web_cache |
| 243 | 246 |
| 244 #endif // COMPONENTS_WEB_CACHE_BROWSER_WEB_CACHE_MANAGER_H_ | 247 #endif // COMPONENTS_WEB_CACHE_BROWSER_WEB_CACHE_MANAGER_H_ |
| OLD | NEW |