| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 PurgeRenderers(); | 78 PurgeRenderers(); |
| 79 | 79 |
| 80 // TODO(pkasting): | 80 // TODO(pkasting): |
| 81 // * Tell the plugin processes to release their free memory? Other stuff? | 81 // * Tell the plugin processes to release their free memory? Other stuff? |
| 82 // * Enumerate what other processes exist and what to do for them. | 82 // * Enumerate what other processes exist and what to do for them. |
| 83 } | 83 } |
| 84 | 84 |
| 85 // static | 85 // static |
| 86 void MemoryPurger::PurgeBrowser() { | 86 void MemoryPurger::PurgeBrowser() { |
| 87 // Dump the backing stores. | 87 // Dump the backing stores. |
| 88 RenderWidgetHost::RemoveAllBackingStores(); | 88 content::RenderWidgetHost::RemoveAllBackingStores(); |
| 89 | 89 |
| 90 // Per-profile cleanup. | 90 // Per-profile cleanup. |
| 91 scoped_refptr<PurgeMemoryIOHelper> purge_memory_io_helper( | 91 scoped_refptr<PurgeMemoryIOHelper> purge_memory_io_helper( |
| 92 new PurgeMemoryIOHelper()); | 92 new PurgeMemoryIOHelper()); |
| 93 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 93 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 94 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); | 94 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); |
| 95 for (size_t i = 0; i < profiles.size(); ++i) { | 95 for (size_t i = 0; i < profiles.size(); ++i) { |
| 96 purge_memory_io_helper->AddRequestContextGetter( | 96 purge_memory_io_helper->AddRequestContextGetter( |
| 97 make_scoped_refptr(profiles[i]->GetRequestContext())); | 97 make_scoped_refptr(profiles[i]->GetRequestContext())); |
| 98 | 98 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 content::RenderProcessHost::AllHostsIterator()); | 146 content::RenderProcessHost::AllHostsIterator()); |
| 147 !i.IsAtEnd(); i.Advance()) | 147 !i.IsAtEnd(); i.Advance()) |
| 148 PurgeRendererForHost(i.GetCurrentValue()); | 148 PurgeRendererForHost(i.GetCurrentValue()); |
| 149 } | 149 } |
| 150 | 150 |
| 151 // static | 151 // static |
| 152 void MemoryPurger::PurgeRendererForHost(content::RenderProcessHost* host) { | 152 void MemoryPurger::PurgeRendererForHost(content::RenderProcessHost* host) { |
| 153 // Direct the renderer to free everything it can. | 153 // Direct the renderer to free everything it can. |
| 154 host->Send(new ChromeViewMsg_PurgeMemory()); | 154 host->Send(new ChromeViewMsg_PurgeMemory()); |
| 155 } | 155 } |
| OLD | NEW |