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 CHROME_BROWSER_RENDERER_HOST_WEB_CACHE_MANAGER_H_ | 8 #ifndef COMPONENTS_WEB_CACHE_BROWSER_WEB_CACHE_MANAGER_H_ |
9 #define CHROME_BROWSER_RENDERER_HOST_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 template<typename Type> | 24 template<typename Type> |
25 struct DefaultSingletonTraits; | 25 struct DefaultSingletonTraits; |
26 class PrefRegistrySimple; | 26 class PrefRegistrySimple; |
27 | 27 |
28 namespace web_cache { | |
29 | |
28 class WebCacheManager : public content::NotificationObserver { | 30 class WebCacheManager : public content::NotificationObserver { |
29 friend class WebCacheManagerTest; | 31 friend class WebCacheManagerTest; |
30 FRIEND_TEST_ALL_PREFIXES(WebCacheManagerBrowserTest, CrashOnceOnly); | 32 FRIEND_TEST_ALL_PREFIXES(WebCacheManagerBrowserTest, CrashOnceOnly); |
erikwright (departed)
2014/09/10 18:06:55
nit remove this friend declaration for the browser
| |
33 FRIEND_TEST_ALL_PREFIXES( | |
34 WebCacheManagerTest, | |
35 RemoveRendererBeforeCallingObserveActivityShouldNotCrashTest); | |
31 | 36 |
32 public: | 37 public: |
33 static void RegisterPrefs(PrefRegistrySimple* registry); | |
34 | |
35 // Gets the singleton WebCacheManager object. The first time this method | 38 // Gets the singleton WebCacheManager object. The first time this method |
36 // is called, a WebCacheManager object is constructed and returned. | 39 // is called, a WebCacheManager object is constructed and returned. |
37 // Subsequent calls will return the same object. | 40 // Subsequent calls will return the same object. |
38 static WebCacheManager* GetInstance(); | 41 static WebCacheManager* GetInstance(); |
39 | 42 |
40 // When a render process is created, it registers itself with the cache | 43 // When a render process is created, it registers itself with the cache |
41 // manager host, causing the renderer to be allocated cache resources. | 44 // manager host, causing the renderer to be allocated cache resources. |
42 void Add(int renderer_id); | 45 void Add(int renderer_id); |
43 | 46 |
44 // When a render process ends, it removes itself from the cache manager host, | 47 // When a render process ends, it removes itself from the cache manager host, |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 // recently than they have been active. | 215 // recently than they have been active. |
213 std::set<int> inactive_renderers_; | 216 std::set<int> inactive_renderers_; |
214 | 217 |
215 base::WeakPtrFactory<WebCacheManager> weak_factory_; | 218 base::WeakPtrFactory<WebCacheManager> weak_factory_; |
216 | 219 |
217 content::NotificationRegistrar registrar_; | 220 content::NotificationRegistrar registrar_; |
218 | 221 |
219 DISALLOW_COPY_AND_ASSIGN(WebCacheManager); | 222 DISALLOW_COPY_AND_ASSIGN(WebCacheManager); |
220 }; | 223 }; |
221 | 224 |
222 #endif // CHROME_BROWSER_RENDERER_HOST_WEB_CACHE_MANAGER_H_ | 225 } // namespace web_cache |
226 | |
227 #endif // COMPONENTS_WEB_CACHE_BROWSER_WEB_CACHE_MANAGER_H_ | |
OLD | NEW |