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 <stddef.h> | 11 #include <stddef.h> |
12 | 12 |
13 #include <list> | 13 #include <list> |
14 #include <map> | 14 #include <map> |
15 #include <set> | 15 #include <set> |
16 | 16 |
17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
18 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "components/web_cache/public/interfaces/web_cache.mojom.h" |
22 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
23 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
24 | 25 |
25 namespace base { | 26 namespace base { |
26 template<typename Type> | 27 template<typename Type> |
27 struct DefaultSingletonTraits; | 28 struct DefaultSingletonTraits; |
28 } // namespace base | 29 } // namespace base |
29 | 30 |
30 class PrefRegistrySimple; | 31 class PrefRegistrySimple; |
31 | 32 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 typedef std::map<int, RendererInfo> StatsMap; | 134 typedef std::map<int, RendererInfo> StatsMap; |
134 | 135 |
135 // An allocation is the number of bytes a specific renderer should use for | 136 // An allocation is the number of bytes a specific renderer should use for |
136 // its cache. | 137 // its cache. |
137 typedef std::pair<int,uint64_t> Allocation; | 138 typedef std::pair<int,uint64_t> Allocation; |
138 | 139 |
139 // An allocation strategy is a list of allocations specifying the resources | 140 // An allocation strategy is a list of allocations specifying the resources |
140 // each renderer is permitted to consume for its cache. | 141 // each renderer is permitted to consume for its cache. |
141 typedef std::list<Allocation> AllocationStrategy; | 142 typedef std::list<Allocation> AllocationStrategy; |
142 | 143 |
| 144 // The key is the unique id of every render process host. |
| 145 typedef std::map<int, mojom::WebCachePtr> WebCacheServicesMap; |
| 146 |
143 // This class is a singleton. Do not instantiate directly. | 147 // This class is a singleton. Do not instantiate directly. |
144 WebCacheManager(); | 148 WebCacheManager(); |
145 friend struct base::DefaultSingletonTraits<WebCacheManager>; | 149 friend struct base::DefaultSingletonTraits<WebCacheManager>; |
146 | 150 |
147 ~WebCacheManager() override; | 151 ~WebCacheManager() override; |
148 | 152 |
149 // Recomputes the allocation of cache resources among the renderers. Also | 153 // Recomputes the allocation of cache resources among the renderers. Also |
150 // informs the renderers of their new allocation. | 154 // informs the renderers of their new allocation. |
151 void ReviseAllocationStrategy(); | 155 void ReviseAllocationStrategy(); |
152 | 156 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // | 254 // |
251 // Active renderers are those renderers that have been active more recently | 255 // Active renderers are those renderers that have been active more recently |
252 // than they have been inactive. | 256 // than they have been inactive. |
253 std::set<int> active_renderers_; | 257 std::set<int> active_renderers_; |
254 // Inactive renderers are those renderers that have been inactive more | 258 // Inactive renderers are those renderers that have been inactive more |
255 // recently than they have been active. | 259 // recently than they have been active. |
256 std::set<int> inactive_renderers_; | 260 std::set<int> inactive_renderers_; |
257 | 261 |
258 content::NotificationRegistrar registrar_; | 262 content::NotificationRegistrar registrar_; |
259 | 263 |
| 264 // Maps every renderer_id with its corresponding mojom::WebCachePtr. |
| 265 WebCacheServicesMap web_cache_services_; |
| 266 |
260 base::WeakPtrFactory<WebCacheManager> weak_factory_; | 267 base::WeakPtrFactory<WebCacheManager> weak_factory_; |
261 | 268 |
262 DISALLOW_COPY_AND_ASSIGN(WebCacheManager); | 269 DISALLOW_COPY_AND_ASSIGN(WebCacheManager); |
263 }; | 270 }; |
264 | 271 |
265 } // namespace web_cache | 272 } // namespace web_cache |
266 | 273 |
267 #endif // COMPONENTS_WEB_CACHE_BROWSER_WEB_CACHE_MANAGER_H_ | 274 #endif // COMPONENTS_WEB_CACHE_BROWSER_WEB_CACHE_MANAGER_H_ |
OLD | NEW |