Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(805)

Side by Side Diff: chrome/browser/memory_purger.cc

Issue 13928035: WIP Component build of autofill Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make windows compiling Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 // Unload all history backends (freeing memory used to cache sqlite). 111 // Unload all history backends (freeing memory used to cache sqlite).
112 // Spinning up the history service is expensive, so we avoid doing it if it 112 // Spinning up the history service is expensive, so we avoid doing it if it
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 scoped_refptr<WebDataService> wds =
121 WebDataServiceFactory::GetForProfileIfExists( 121 WebDataServiceFactory::GetWebDataServiceForProfileIfExists(profiles[i]);
122 profiles[i], Profile::EXPLICIT_ACCESS); 122 if (wds)
123 if (wds_wrapper && wds_wrapper->GetWebData()) 123 wds->UnloadDatabase();
124 wds_wrapper->GetWebData()->UnloadDatabase();
125 124
126 BrowserContext::PurgeMemory(profiles[i]); 125 BrowserContext::PurgeMemory(profiles[i]);
127 } 126 }
128 127
129 BrowserThread::PostTask( 128 BrowserThread::PostTask(
130 BrowserThread::IO, FROM_HERE, 129 BrowserThread::IO, FROM_HERE,
131 base::Bind(&PurgeMemoryIOHelper::PurgeMemoryOnIOThread, 130 base::Bind(&PurgeMemoryIOHelper::PurgeMemoryOnIOThread,
132 purge_memory_io_helper.get())); 131 purge_memory_io_helper.get()));
133 132
134 // TODO(pkasting): 133 // TODO(pkasting):
(...skipping 19 matching lines...) Expand all
154 content::RenderProcessHost::AllHostsIterator()); 153 content::RenderProcessHost::AllHostsIterator());
155 !i.IsAtEnd(); i.Advance()) 154 !i.IsAtEnd(); i.Advance())
156 PurgeRendererForHost(i.GetCurrentValue()); 155 PurgeRendererForHost(i.GetCurrentValue());
157 } 156 }
158 157
159 // static 158 // static
160 void MemoryPurger::PurgeRendererForHost(content::RenderProcessHost* host) { 159 void MemoryPurger::PurgeRendererForHost(content::RenderProcessHost* host) {
161 // Direct the renderer to free everything it can. 160 // Direct the renderer to free everything it can.
162 host->Send(new ChromeViewMsg_PurgeMemory()); 161 host->Send(new ChromeViewMsg_PurgeMemory());
163 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698