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 #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/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 void PurgeMemoryIOHelper::PurgeMemoryOnIOThread() { | 58 void PurgeMemoryIOHelper::PurgeMemoryOnIOThread() { |
59 // Ask ProxyServices to purge any memory they can (generally garbage in the | 59 // Ask ProxyServices to purge any memory they can (generally garbage in the |
60 // wrapped ProxyResolver's JS engine). | 60 // wrapped ProxyResolver's JS engine). |
61 for (RequestContextGetters::const_iterator i( | 61 for (RequestContextGetters::const_iterator i( |
62 request_context_getters_.begin()); | 62 request_context_getters_.begin()); |
63 i != request_context_getters_.end(); ++i) | 63 i != request_context_getters_.end(); ++i) |
64 (*i)->GetURLRequestContext()->proxy_service()->PurgeMemory(); | 64 (*i)->GetURLRequestContext()->proxy_service()->PurgeMemory(); |
65 | 65 |
66 // The appcache and safe browsing services listen for this notification. | 66 // The appcache and safe browsing services listen for this notification. |
67 NotificationService::current()->Notify( | 67 NotificationService::current()->Notify( |
68 NotificationType::PURGE_MEMORY, | 68 content::NOTIFICATION_PURGE_MEMORY, |
69 Source<void>(NULL), | 69 Source<void>(NULL), |
70 NotificationService::NoDetails()); | 70 NotificationService::NoDetails()); |
71 } | 71 } |
72 | 72 |
73 // ----------------------------------------------------------------------------- | 73 // ----------------------------------------------------------------------------- |
74 | 74 |
75 // static | 75 // static |
76 void MemoryPurger::PurgeAll() { | 76 void MemoryPurger::PurgeAll() { |
77 PurgeBrowser(); | 77 PurgeBrowser(); |
78 PurgeRenderers(); | 78 PurgeRenderers(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); | 147 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); |
148 !i.IsAtEnd(); i.Advance()) | 148 !i.IsAtEnd(); i.Advance()) |
149 PurgeRendererForHost(i.GetCurrentValue()); | 149 PurgeRendererForHost(i.GetCurrentValue()); |
150 } | 150 } |
151 | 151 |
152 // static | 152 // static |
153 void MemoryPurger::PurgeRendererForHost(RenderProcessHost* host) { | 153 void MemoryPurger::PurgeRendererForHost(RenderProcessHost* host) { |
154 // Direct the renderer to free everything it can. | 154 // Direct the renderer to free everything it can. |
155 host->Send(new ViewMsg_PurgeMemory()); | 155 host->Send(new ViewMsg_PurgeMemory()); |
156 } | 156 } |
OLD | NEW |