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

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

Issue 24017: More refactoring of PluginProcessHost (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/memory_details.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/idle_timer.h" 8 #include "base/idle_timer.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "chrome/app/chrome_dll_resource.h" 11 #include "chrome/app/chrome_dll_resource.h"
12 #include "chrome/browser/bookmarks/bookmark_model.h" 12 #include "chrome/browser/bookmarks/bookmark_model.h"
13 #include "chrome/browser/browser_list.h" 13 #include "chrome/browser/browser_list.h"
14 #include "chrome/browser/browser_shutdown.h" 14 #include "chrome/browser/browser_shutdown.h"
15 #include "chrome/browser/location_bar.h" 15 #include "chrome/browser/location_bar.h"
16 #include "chrome/browser/metrics/user_metrics.h" 16 #include "chrome/browser/metrics/user_metrics.h"
17 #include "chrome/browser/profile.h" 17 #include "chrome/browser/profile.h"
18 #include "chrome/browser/sessions/session_service.h" 18 #include "chrome/browser/sessions/session_service.h"
19 #include "chrome/browser/sessions/session_types.h" 19 #include "chrome/browser/sessions/session_types.h"
20 #include "chrome/browser/sessions/tab_restore_service.h" 20 #include "chrome/browser/sessions/tab_restore_service.h"
21 #include "chrome/browser/tab_contents/navigation_controller.h" 21 #include "chrome/browser/tab_contents/navigation_controller.h"
22 #include "chrome/browser/tab_contents/navigation_entry.h" 22 #include "chrome/browser/tab_contents/navigation_entry.h"
23 #include "chrome/browser/tab_contents/site_instance.h" 23 #include "chrome/browser/tab_contents/site_instance.h"
24 #include "chrome/browser/tab_contents/tab_contents_type.h" 24 #include "chrome/browser/tab_contents/tab_contents_type.h"
25 #include "chrome/browser/tab_contents/web_contents.h" 25 #include "chrome/browser/tab_contents/web_contents.h"
26 #include "chrome/common/child_process_info.h"
26 #include "chrome/common/chrome_constants.h" 27 #include "chrome/common/chrome_constants.h"
27 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/l10n_util.h" 29 #include "chrome/common/l10n_util.h"
29 #include "chrome/common/notification_service.h" 30 #include "chrome/common/notification_service.h"
30 #include "chrome/common/page_transition_types.h" 31 #include "chrome/common/page_transition_types.h"
31 #include "chrome/common/pref_names.h" 32 #include "chrome/common/pref_names.h"
32 #include "chrome/common/pref_service.h" 33 #include "chrome/common/pref_service.h"
33 #ifdef CHROME_PERSONALIZATION 34 #ifdef CHROME_PERSONALIZATION
34 #include "chrome/personalization/personalization.h" 35 #include "chrome/personalization/personalization.h"
35 #endif 36 #endif
(...skipping 16 matching lines...) Expand all
52 #include "chrome/browser/browser_window.h" 53 #include "chrome/browser/browser_window.h"
53 #include "chrome/browser/cert_store.h" 54 #include "chrome/browser/cert_store.h"
54 #include "chrome/browser/character_encoding.h" 55 #include "chrome/browser/character_encoding.h"
55 #include "chrome/browser/debugger/debugger_window.h" 56 #include "chrome/browser/debugger/debugger_window.h"
56 #include "chrome/browser/dock_info.h" 57 #include "chrome/browser/dock_info.h"
57 #include "chrome/browser/dom_ui/new_tab_ui.h" 58 #include "chrome/browser/dom_ui/new_tab_ui.h"
58 #include "chrome/browser/download/save_package.h" 59 #include "chrome/browser/download/save_package.h"
59 #include "chrome/browser/history_tab_ui.h" 60 #include "chrome/browser/history_tab_ui.h"
60 #include "chrome/browser/options_window.h" 61 #include "chrome/browser/options_window.h"
61 #include "chrome/browser/net/url_fixer_upper.h" 62 #include "chrome/browser/net/url_fixer_upper.h"
62 #include "chrome/browser/plugin_process_host.h"
63 #include "chrome/browser/plugin_service.h"
64 #include "chrome/browser/ssl/ssl_error_info.h" 63 #include "chrome/browser/ssl/ssl_error_info.h"
65 #include "chrome/browser/status_bubble.h" 64 #include "chrome/browser/status_bubble.h"
66 #include "chrome/browser/tab_contents/interstitial_page.h" 65 #include "chrome/browser/tab_contents/interstitial_page.h"
67 #include "chrome/browser/tab_contents/web_contents_view.h" 66 #include "chrome/browser/tab_contents/web_contents_view.h"
68 #include "chrome/browser/task_manager.h" 67 #include "chrome/browser/task_manager.h"
69 #include "chrome/browser/user_data_manager.h" 68 #include "chrome/browser/user_data_manager.h"
70 #include "chrome/browser/view_ids.h" 69 #include "chrome/browser/view_ids.h"
71 #include "chrome/browser/views/download_tab_view.h" 70 #include "chrome/browser/views/download_tab_view.h"
72 #include "chrome/browser/views/location_bar_view.h" 71 #include "chrome/browser/views/location_bar_view.h"
73 #include "chrome/browser/window_sizer.h" 72 #include "chrome/browser/window_sizer.h"
(...skipping 11 matching lines...) Expand all
85 84
86 // Idle time before helping prune memory consumption. 85 // Idle time before helping prune memory consumption.
87 static const int kBrowserReleaseMemoryInterval = 30; // In seconds. 86 static const int kBrowserReleaseMemoryInterval = 30; // In seconds.
88 87
89 // How much horizontal and vertical offset there is between newly opened 88 // How much horizontal and vertical offset there is between newly opened
90 // windows. 89 // windows.
91 static const int kWindowTilePixels = 20; 90 static const int kWindowTilePixels = 20;
92 91
93 /////////////////////////////////////////////////////////////////////////////// 92 ///////////////////////////////////////////////////////////////////////////////
94 93
95 // A task to reduce the working set of the plugins. 94 // A task to reduce the working set of the child processes that live on the IO
96 class ReducePluginsWorkingSetTask : public Task { 95 // thread (i.e. plugins, workers).
96 class ReduceChildProcessesWorkingSetTask : public Task {
97 public: 97 public:
98 virtual void Run() { 98 virtual void Run() {
99 #if defined(OS_WIN) 99 #if defined(OS_WIN)
100 for (PluginProcessHostIterator iter; !iter.Done(); ++iter) { 100 for (ChildProcessInfo::Iterator iter; !iter.Done(); ++iter) {
101 ChildProcessInfo* child = const_cast<PluginProcessHost*>(*iter); 101 DCHECK(iter->process().handle());
102 DCHECK(child->process().handle()); 102 iter->process().ReduceWorkingSet();
103 child->process().ReduceWorkingSet();
104 } 103 }
105 #endif 104 #endif
106 } 105 }
107 }; 106 };
108 107
109 // A browser task to run when the user is not using the browser. 108 // A browser task to run when the user is not using the browser.
110 // In our case, we're trying to be nice to the operating system and release 109 // In our case, we're trying to be nice to the operating system and release
111 // memory not in use. 110 // memory not in use.
112 class BrowserIdleTimer : public base::IdleTimer { 111 class BrowserIdleTimer : public base::IdleTimer {
113 public: 112 public:
(...skipping 11 matching lines...) Expand all
125 process.ReduceWorkingSet(); 124 process.ReduceWorkingSet();
126 125
127 // Handle the Renderer(s). 126 // Handle the Renderer(s).
128 RenderProcessHost::iterator renderer_iter; 127 RenderProcessHost::iterator renderer_iter;
129 for (renderer_iter = RenderProcessHost::begin(); renderer_iter != 128 for (renderer_iter = RenderProcessHost::begin(); renderer_iter !=
130 RenderProcessHost::end(); renderer_iter++) { 129 RenderProcessHost::end(); renderer_iter++) {
131 base::Process process = renderer_iter->second->process(); 130 base::Process process = renderer_iter->second->process();
132 process.ReduceWorkingSet(); 131 process.ReduceWorkingSet();
133 } 132 }
134 133
135 // Handle the Plugin(s). We need to iterate through the plugin processes 134 // Handle the child processe. We need to iterate through them on the IO
136 // on the IO thread because that thread manages the plugin process 135 // thread because that thread manages the child process collection.
137 // collection.
138 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 136 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
139 new ReducePluginsWorkingSetTask()); 137 new ReduceChildProcessesWorkingSetTask());
140 #endif 138 #endif
141 } 139 }
142 }; 140 };
143 141
144 /////////////////////////////////////////////////////////////////////////////// 142 ///////////////////////////////////////////////////////////////////////////////
145 143
146 struct Browser::UIUpdate { 144 struct Browser::UIUpdate {
147 UIUpdate(const TabContents* src, unsigned flags) 145 UIUpdate(const TabContents* src, unsigned flags)
148 : source(src), 146 : source(src),
149 changed_flags(flags) { 147 changed_flags(flags) {
(...skipping 2272 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 2420
2423 // We need to register the window position pref. 2421 // We need to register the window position pref.
2424 std::wstring window_pref(prefs::kBrowserWindowPlacement); 2422 std::wstring window_pref(prefs::kBrowserWindowPlacement);
2425 window_pref.append(L"_"); 2423 window_pref.append(L"_");
2426 window_pref.append(app_name); 2424 window_pref.append(app_name);
2427 PrefService* prefs = g_browser_process->local_state(); 2425 PrefService* prefs = g_browser_process->local_state();
2428 DCHECK(prefs); 2426 DCHECK(prefs);
2429 2427
2430 prefs->RegisterDictionaryPref(window_pref.c_str()); 2428 prefs->RegisterDictionaryPref(window_pref.c_str());
2431 } 2429 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/memory_details.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698