OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
7 | 7 |
8 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "chrome/browser/profile.h" | 40 #include "chrome/browser/profile.h" |
41 #include "chrome/browser/renderer_host/render_view_host.h" | 41 #include "chrome/browser/renderer_host/render_view_host.h" |
42 #include "chrome/browser/renderer_host/render_widget_helper.h" | 42 #include "chrome/browser/renderer_host/render_widget_helper.h" |
43 #include "chrome/browser/renderer_host/render_widget_host.h" | 43 #include "chrome/browser/renderer_host/render_widget_host.h" |
44 #include "chrome/browser/renderer_host/resource_message_filter.h" | 44 #include "chrome/browser/renderer_host/resource_message_filter.h" |
45 #include "chrome/browser/renderer_host/web_cache_manager.h" | 45 #include "chrome/browser/renderer_host/web_cache_manager.h" |
46 #include "chrome/browser/spellchecker.h" | 46 #include "chrome/browser/spellchecker.h" |
47 #include "chrome/browser/visitedlink_master.h" | 47 #include "chrome/browser/visitedlink_master.h" |
48 #include "chrome/common/chrome_switches.h" | 48 #include "chrome/common/chrome_switches.h" |
49 #include "chrome/common/child_process_info.h" | 49 #include "chrome/common/child_process_info.h" |
50 #include "chrome/common/child_process_host.h" | |
51 #include "chrome/common/chrome_descriptors.h" | 50 #include "chrome/common/chrome_descriptors.h" |
52 #include "chrome/common/logging_chrome.h" | 51 #include "chrome/common/logging_chrome.h" |
53 #include "chrome/common/notification_service.h" | 52 #include "chrome/common/notification_service.h" |
54 #include "chrome/common/process_watcher.h" | 53 #include "chrome/common/process_watcher.h" |
55 #include "chrome/common/render_messages.h" | 54 #include "chrome/common/render_messages.h" |
56 #include "chrome/common/result_codes.h" | 55 #include "chrome/common/result_codes.h" |
57 #include "chrome/renderer/render_process.h" | 56 #include "chrome/renderer/render_process.h" |
58 #include "chrome/renderer/render_thread.h" | 57 #include "chrome/renderer/render_thread.h" |
59 #include "chrome/installer/util/google_update_settings.h" | 58 #include "chrome/installer/util/google_update_settings.h" |
60 #include "grit/generated_resources.h" | 59 #include "grit/generated_resources.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // Go ahead and send whatever we already have buffered up. | 194 // Go ahead and send whatever we already have buffered up. |
196 Update(sender); | 195 Update(sender); |
197 } | 196 } |
198 | 197 |
199 private: | 198 private: |
200 bool reset_needed_; | 199 bool reset_needed_; |
201 bool has_receiver_; | 200 bool has_receiver_; |
202 VisitedLinkCommon::Fingerprints pending_; | 201 VisitedLinkCommon::Fingerprints pending_; |
203 }; | 202 }; |
204 | 203 |
| 204 |
| 205 // Used for a View_ID where the renderer has not been attached yet |
| 206 const int32 kInvalidViewID = -1; |
| 207 |
| 208 // Get the path to the renderer executable, which is the same as the |
| 209 // current executable. |
| 210 bool GetRendererPath(std::wstring* cmd_line) { |
| 211 return PathService::Get(base::FILE_EXE, cmd_line); |
| 212 } |
| 213 |
205 BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile) | 214 BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile) |
206 : RenderProcessHost(profile), | 215 : RenderProcessHost(profile), |
207 visible_widgets_(0), | 216 visible_widgets_(0), |
208 backgrounded_(true), | 217 backgrounded_(true), |
209 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( | 218 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( |
210 base::TimeDelta::FromSeconds(5), | 219 base::TimeDelta::FromSeconds(5), |
211 this, &BrowserRenderProcessHost::ClearTransportDIBCache)), | 220 this, &BrowserRenderProcessHost::ClearTransportDIBCache)), |
212 zygote_child_(false) { | 221 zygote_child_(false) { |
213 widget_helper_ = new RenderWidgetHelper(); | 222 widget_helper_ = new RenderWidgetHelper(); |
214 | 223 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 resource_message_filter, | 300 resource_message_filter, |
292 io_thread->message_loop(), true, | 301 io_thread->message_loop(), true, |
293 g_browser_process->shutdown_event())); | 302 g_browser_process->shutdown_event())); |
294 // As a preventive mesure, we DCHECK if someone sends a synchronous message | 303 // As a preventive mesure, we DCHECK if someone sends a synchronous message |
295 // with no time-out, which in the context of the browser process we should not | 304 // with no time-out, which in the context of the browser process we should not |
296 // be doing. | 305 // be doing. |
297 channel_->set_sync_messages_with_no_timeout_allowed(false); | 306 channel_->set_sync_messages_with_no_timeout_allowed(false); |
298 | 307 |
299 // Build command line for renderer, we have to quote the executable name to | 308 // Build command line for renderer, we have to quote the executable name to |
300 // deal with spaces. | 309 // deal with spaces. |
301 std::wstring renderer_path = ChildProcessHost::GetChildPath(); | 310 std::wstring renderer_path = |
| 311 browser_command_line.GetSwitchValue(switches::kBrowserSubprocessPath); |
302 if (renderer_path.empty()) { | 312 if (renderer_path.empty()) { |
303 // Need to reset the channel we created above or others might think the | 313 if (!GetRendererPath(&renderer_path)) { |
304 // connection is live. | 314 // Need to reset the channel we created above or others might think the |
305 channel_.reset(); | 315 // connection is live. |
306 return false; | 316 channel_.reset(); |
| 317 return false; |
| 318 } |
307 } | 319 } |
308 CommandLine cmd_line(renderer_path); | 320 CommandLine cmd_line(renderer_path); |
309 if (logging::DialogsAreSuppressed()) | 321 if (logging::DialogsAreSuppressed()) |
310 cmd_line.AppendSwitch(switches::kNoErrorDialogs); | 322 cmd_line.AppendSwitch(switches::kNoErrorDialogs); |
311 | 323 |
312 // propagate the following switches to the renderer command line | 324 // propagate the following switches to the renderer command line |
313 // (along with any associated values) if present in the browser command line | 325 // (along with any associated values) if present in the browser command line |
314 static const wchar_t* const switch_names[] = { | 326 static const wchar_t* const switch_names[] = { |
315 switches::kRendererAssertTest, | 327 switches::kRendererAssertTest, |
316 switches::kRendererCrashTest, | 328 switches::kRendererCrashTest, |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 profile()->GetExtensionMessageService()->RemoveEventListener(event_name, | 1006 profile()->GetExtensionMessageService()->RemoveEventListener(event_name, |
995 pid()); | 1007 pid()); |
996 } | 1008 } |
997 } | 1009 } |
998 | 1010 |
999 void BrowserRenderProcessHost::OnExtensionCloseChannel(int port_id) { | 1011 void BrowserRenderProcessHost::OnExtensionCloseChannel(int port_id) { |
1000 if (profile()->GetExtensionMessageService()) { | 1012 if (profile()->GetExtensionMessageService()) { |
1001 profile()->GetExtensionMessageService()->CloseChannel(port_id); | 1013 profile()->GetExtensionMessageService()->CloseChannel(port_id); |
1002 } | 1014 } |
1003 } | 1015 } |
OLD | NEW |