| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/browser.h" | 5 #include "chrome/browser/browser.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 /////////////////////////////////////////////////////////////////////////////// | 89 /////////////////////////////////////////////////////////////////////////////// |
| 90 | 90 |
| 91 // A task to reduce the working set of the plugins. | 91 // A task to reduce the working set of the plugins. |
| 92 class ReducePluginsWorkingSetTask : public Task { | 92 class ReducePluginsWorkingSetTask : public Task { |
| 93 public: | 93 public: |
| 94 virtual void Run() { | 94 virtual void Run() { |
| 95 for (PluginProcessHostIterator iter; !iter.Done(); ++iter) { | 95 for (PluginProcessHostIterator iter; !iter.Done(); ++iter) { |
| 96 PluginProcessHost* plugin = const_cast<PluginProcessHost*>(*iter); | 96 PluginProcessHost* plugin = const_cast<PluginProcessHost*>(*iter); |
| 97 DCHECK(plugin->process()); | 97 DCHECK(plugin->process()); |
| 98 Process process(plugin->process()); | 98 base::Process process(plugin->process()); |
| 99 process.ReduceWorkingSet(); | 99 process.ReduceWorkingSet(); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 // A browser task to run when the user is not using the browser. | 104 // A browser task to run when the user is not using the browser. |
| 105 // In our case, we're trying to be nice to the operating system and release | 105 // In our case, we're trying to be nice to the operating system and release |
| 106 // memory not in use. | 106 // memory not in use. |
| 107 class BrowserIdleTimer : public base::IdleTimer { | 107 class BrowserIdleTimer : public base::IdleTimer { |
| 108 public: | 108 public: |
| 109 BrowserIdleTimer() | 109 BrowserIdleTimer() |
| 110 : base::IdleTimer(TimeDelta::FromSeconds(kBrowserReleaseMemoryInterval), | 110 : base::IdleTimer(TimeDelta::FromSeconds(kBrowserReleaseMemoryInterval), |
| 111 false) { | 111 false) { |
| 112 } | 112 } |
| 113 | 113 |
| 114 virtual void OnIdle() { | 114 virtual void OnIdle() { |
| 115 // We're idle. Release browser and renderer unused pages. | 115 // We're idle. Release browser and renderer unused pages. |
| 116 | 116 |
| 117 // Handle the Browser. | 117 // Handle the Browser. |
| 118 Process process(GetCurrentProcess()); | 118 base::Process process(GetCurrentProcess()); |
| 119 process.ReduceWorkingSet(); | 119 process.ReduceWorkingSet(); |
| 120 | 120 |
| 121 // Handle the Renderer(s). | 121 // Handle the Renderer(s). |
| 122 RenderProcessHost::iterator renderer_iter; | 122 RenderProcessHost::iterator renderer_iter; |
| 123 for (renderer_iter = RenderProcessHost::begin(); renderer_iter != | 123 for (renderer_iter = RenderProcessHost::begin(); renderer_iter != |
| 124 RenderProcessHost::end(); renderer_iter++) { | 124 RenderProcessHost::end(); renderer_iter++) { |
| 125 Process process(renderer_iter->second->process()); | 125 base::Process process = renderer_iter->second->process(); |
| 126 process.ReduceWorkingSet(); | 126 process.ReduceWorkingSet(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 // Handle the Plugin(s). We need to iterate through the plugin processes | 129 // Handle the Plugin(s). We need to iterate through the plugin processes |
| 130 // on the IO thread because that thread manages the plugin process | 130 // on the IO thread because that thread manages the plugin process |
| 131 // collection. | 131 // collection. |
| 132 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 132 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
| 133 new ReducePluginsWorkingSetTask()); | 133 new ReducePluginsWorkingSetTask()); |
| 134 } | 134 } |
| 135 }; | 135 }; |
| (...skipping 2336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2472 | 2472 |
| 2473 // We need to register the window position pref. | 2473 // We need to register the window position pref. |
| 2474 std::wstring window_pref(prefs::kBrowserWindowPlacement); | 2474 std::wstring window_pref(prefs::kBrowserWindowPlacement); |
| 2475 window_pref.append(L"_"); | 2475 window_pref.append(L"_"); |
| 2476 window_pref.append(app_name); | 2476 window_pref.append(app_name); |
| 2477 PrefService* prefs = g_browser_process->local_state(); | 2477 PrefService* prefs = g_browser_process->local_state(); |
| 2478 DCHECK(prefs); | 2478 DCHECK(prefs); |
| 2479 | 2479 |
| 2480 prefs->RegisterDictionaryPref(window_pref.c_str()); | 2480 prefs->RegisterDictionaryPref(window_pref.c_str()); |
| 2481 } | 2481 } |
| OLD | NEW |