OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory_purger.h" | 5 #include "chrome/browser/memory_purger.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 PurgeMemoryIOHelper() { | 39 PurgeMemoryIOHelper() { |
40 safe_browsing_service_ = g_browser_process->safe_browsing_service(); | 40 safe_browsing_service_ = g_browser_process->safe_browsing_service(); |
41 } | 41 } |
42 | 42 |
43 void AddRequestContextGetter( | 43 void AddRequestContextGetter( |
44 scoped_refptr<net::URLRequestContextGetter> request_context_getter); | 44 scoped_refptr<net::URLRequestContextGetter> request_context_getter); |
45 | 45 |
46 void PurgeMemoryOnIOThread(); | 46 void PurgeMemoryOnIOThread(); |
47 | 47 |
48 private: | 48 private: |
| 49 friend class base::RefCountedThreadSafe<PurgeMemoryIOHelper>; |
| 50 |
| 51 virtual ~PurgeMemoryIOHelper() {} |
| 52 |
49 typedef scoped_refptr<net::URLRequestContextGetter> RequestContextGetter; | 53 typedef scoped_refptr<net::URLRequestContextGetter> RequestContextGetter; |
| 54 std::vector<RequestContextGetter> request_context_getters_; |
50 | 55 |
51 std::vector<RequestContextGetter> request_context_getters_; | |
52 scoped_refptr<SafeBrowsingService> safe_browsing_service_; | 56 scoped_refptr<SafeBrowsingService> safe_browsing_service_; |
53 | 57 |
54 DISALLOW_COPY_AND_ASSIGN(PurgeMemoryIOHelper); | 58 DISALLOW_COPY_AND_ASSIGN(PurgeMemoryIOHelper); |
55 }; | 59 }; |
56 | 60 |
57 void PurgeMemoryIOHelper::AddRequestContextGetter( | 61 void PurgeMemoryIOHelper::AddRequestContextGetter( |
58 scoped_refptr<net::URLRequestContextGetter> request_context_getter) { | 62 scoped_refptr<net::URLRequestContextGetter> request_context_getter) { |
59 request_context_getters_.push_back(request_context_getter); | 63 request_context_getters_.push_back(request_context_getter); |
60 } | 64 } |
61 | 65 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 content::RenderProcessHost::AllHostsIterator()); | 152 content::RenderProcessHost::AllHostsIterator()); |
149 !i.IsAtEnd(); i.Advance()) | 153 !i.IsAtEnd(); i.Advance()) |
150 PurgeRendererForHost(i.GetCurrentValue()); | 154 PurgeRendererForHost(i.GetCurrentValue()); |
151 } | 155 } |
152 | 156 |
153 // static | 157 // static |
154 void MemoryPurger::PurgeRendererForHost(content::RenderProcessHost* host) { | 158 void MemoryPurger::PurgeRendererForHost(content::RenderProcessHost* host) { |
155 // Direct the renderer to free everything it can. | 159 // Direct the renderer to free everything it can. |
156 host->Send(new ChromeViewMsg_PurgeMemory()); | 160 host->Send(new ChromeViewMsg_PurgeMemory()); |
157 } | 161 } |
OLD | NEW |