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/allocator/allocator_extension.h" | 9 #include "base/allocator/allocator_extension.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // hasn't been done already. | 113 // hasn't been done already. |
114 HistoryService* history_service = | 114 HistoryService* history_service = |
115 HistoryServiceFactory::GetForProfileWithoutCreating(profiles[i]); | 115 HistoryServiceFactory::GetForProfileWithoutCreating(profiles[i]); |
116 if (history_service) | 116 if (history_service) |
117 history_service->UnloadBackend(); | 117 history_service->UnloadBackend(); |
118 | 118 |
119 // Unload all web databases (freeing memory used to cache sqlite). | 119 // Unload all web databases (freeing memory used to cache sqlite). |
120 WebDataServiceWrapper* wds_wrapper = | 120 WebDataServiceWrapper* wds_wrapper = |
121 WebDataServiceFactory::GetForProfileIfExists( | 121 WebDataServiceFactory::GetForProfileIfExists( |
122 profiles[i], Profile::EXPLICIT_ACCESS); | 122 profiles[i], Profile::EXPLICIT_ACCESS); |
123 if (wds_wrapper && wds_wrapper->GetWebData()) | 123 if (wds_wrapper && wds_wrapper->GetWebData().get()) |
124 wds_wrapper->GetWebData()->UnloadDatabase(); | 124 wds_wrapper->GetWebData()->UnloadDatabase(); |
125 | 125 |
126 BrowserContext::PurgeMemory(profiles[i]); | 126 BrowserContext::PurgeMemory(profiles[i]); |
127 } | 127 } |
128 | 128 |
129 BrowserThread::PostTask( | 129 BrowserThread::PostTask( |
130 BrowserThread::IO, FROM_HERE, | 130 BrowserThread::IO, FROM_HERE, |
131 base::Bind(&PurgeMemoryIOHelper::PurgeMemoryOnIOThread, | 131 base::Bind(&PurgeMemoryIOHelper::PurgeMemoryOnIOThread, |
132 purge_memory_io_helper.get())); | 132 purge_memory_io_helper.get())); |
133 | 133 |
(...skipping 20 matching lines...) Expand all Loading... |
154 content::RenderProcessHost::AllHostsIterator()); | 154 content::RenderProcessHost::AllHostsIterator()); |
155 !i.IsAtEnd(); i.Advance()) | 155 !i.IsAtEnd(); i.Advance()) |
156 PurgeRendererForHost(i.GetCurrentValue()); | 156 PurgeRendererForHost(i.GetCurrentValue()); |
157 } | 157 } |
158 | 158 |
159 // static | 159 // static |
160 void MemoryPurger::PurgeRendererForHost(content::RenderProcessHost* host) { | 160 void MemoryPurger::PurgeRendererForHost(content::RenderProcessHost* host) { |
161 // Direct the renderer to free everything it can. | 161 // Direct the renderer to free everything it can. |
162 host->Send(new ChromeViewMsg_PurgeMemory()); | 162 host->Send(new ChromeViewMsg_PurgeMemory()); |
163 } | 163 } |
OLD | NEW |