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

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

Issue 10006037: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed compile Created 8 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/bind.h" 9 #include "base/bind.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/history/history.h" 12 #include "chrome/browser/history/history.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 14 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
15 #include "chrome/browser/ui/browser_list.h" 15 #include "chrome/browser/ui/browser_list.h"
16 #include "chrome/browser/webdata/web_data_service.h" 16 #include "chrome/browser/webdata/web_data_service.h"
17 #include "chrome/browser/webdata/web_data_service_factory.h"
17 #include "chrome/common/render_messages.h" 18 #include "chrome/common/render_messages.h"
18 #include "content/public/browser/render_process_host.h" 19 #include "content/public/browser/render_process_host.h"
19 #include "content/public/browser/render_widget_host.h" 20 #include "content/public/browser/render_widget_host.h"
20 #include "content/public/browser/resource_context.h" 21 #include "content/public/browser/resource_context.h"
21 #include "net/proxy/proxy_resolver.h" 22 #include "net/proxy/proxy_resolver.h"
22 #include "net/proxy/proxy_service.h" 23 #include "net/proxy/proxy_service.h"
23 #include "net/url_request/url_request_context.h" 24 #include "net/url_request/url_request_context.h"
24 #include "net/url_request/url_request_context_getter.h" 25 #include "net/url_request/url_request_context_getter.h"
25 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" 26 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h"
26 27
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 104
104 // Unload all history backends (freeing memory used to cache sqlite). 105 // Unload all history backends (freeing memory used to cache sqlite).
105 // Spinning up the history service is expensive, so we avoid doing it if it 106 // Spinning up the history service is expensive, so we avoid doing it if it
106 // hasn't been done already. 107 // hasn't been done already.
107 HistoryService* history_service = 108 HistoryService* history_service =
108 profiles[i]->GetHistoryServiceWithoutCreating(); 109 profiles[i]->GetHistoryServiceWithoutCreating();
109 if (history_service) 110 if (history_service)
110 history_service->UnloadBackend(); 111 history_service->UnloadBackend();
111 112
112 // Unload all web databases (freeing memory used to cache sqlite). 113 // Unload all web databases (freeing memory used to cache sqlite).
113 WebDataService* web_data_service = 114 scoped_refptr<WebDataService> web_data_service =
114 profiles[i]->GetWebDataServiceWithoutCreating(); 115 WebDataServiceFactory::GetForProfileIfExists(
115 if (web_data_service) 116 profiles[i], Profile::EXPLICIT_ACCESS);
117 if (web_data_service.get())
116 web_data_service->UnloadDatabase(); 118 web_data_service->UnloadDatabase();
117 119
118 BrowserContext::PurgeMemory(profiles[i]); 120 BrowserContext::PurgeMemory(profiles[i]);
119 } 121 }
120 122
121 BrowserThread::PostTask( 123 BrowserThread::PostTask(
122 BrowserThread::IO, FROM_HERE, 124 BrowserThread::IO, FROM_HERE,
123 base::Bind(&PurgeMemoryIOHelper::PurgeMemoryOnIOThread, 125 base::Bind(&PurgeMemoryIOHelper::PurgeMemoryOnIOThread,
124 purge_memory_io_helper.get())); 126 purge_memory_io_helper.get()));
125 127
(...skipping 22 matching lines...) Expand all
148 content::RenderProcessHost::AllHostsIterator()); 150 content::RenderProcessHost::AllHostsIterator());
149 !i.IsAtEnd(); i.Advance()) 151 !i.IsAtEnd(); i.Advance())
150 PurgeRendererForHost(i.GetCurrentValue()); 152 PurgeRendererForHost(i.GetCurrentValue());
151 } 153 }
152 154
153 // static 155 // static
154 void MemoryPurger::PurgeRendererForHost(content::RenderProcessHost* host) { 156 void MemoryPurger::PurgeRendererForHost(content::RenderProcessHost* host) {
155 // Direct the renderer to free everything it can. 157 // Direct the renderer to free everything it can.
156 host->Send(new ChromeViewMsg_PurgeMemory()); 158 host->Send(new ChromeViewMsg_PurgeMemory());
157 } 159 }
OLDNEW
« no previous file with comments | « chrome/browser/managed_mode_unittest.cc ('k') | chrome/browser/password_manager/password_store_default_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698