Chromium Code Reviews| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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/chrome_descriptors.h" | 50 #include "chrome/common/chrome_descriptors.h" |
| 51 #include "chrome/common/logging_chrome.h" | 51 #include "chrome/common/logging_chrome.h" |
| 52 #include "chrome/common/notification_service.h" | 52 #include "chrome/common/notification_service.h" |
| 53 #include "chrome/common/process_watcher.h" | 53 #include "chrome/common/process_watcher.h" |
| 54 #include "chrome/common/render_messages.h" | 54 #include "chrome/common/render_messages.h" |
| 55 #include "chrome/common/result_codes.h" | 55 #include "chrome/common/result_codes.h" |
| 56 #include "chrome/renderer/render_process.h" | 56 #include "chrome/renderer/render_process.h" |
| 57 #include "chrome/renderer/render_thread.h" | |
| 57 #include "chrome/installer/util/google_update_settings.h" | 58 #include "chrome/installer/util/google_update_settings.h" |
| 58 #include "grit/generated_resources.h" | 59 #include "grit/generated_resources.h" |
| 59 | 60 |
| 60 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
| 61 #include "app/win_util.h" | 62 #include "app/win_util.h" |
| 62 #include "chrome/browser/sandbox_policy.h" | 63 #include "chrome/browser/sandbox_policy.h" |
| 63 #elif defined(OS_LINUX) | 64 #elif defined(OS_LINUX) |
| 64 #include "base/linux_util.h" | 65 #include "base/linux_util.h" |
| 65 #include "chrome/browser/zygote_host_linux.h" | 66 #include "chrome/browser/zygote_host_linux.h" |
| 66 #include "chrome/browser/renderer_host/render_crash_handler_host_linux.h" | 67 #include "chrome/browser/renderer_host/render_crash_handler_host_linux.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 85 ~RendererMainThread() { | 86 ~RendererMainThread() { |
| 86 Stop(); | 87 Stop(); |
| 87 } | 88 } |
| 88 | 89 |
| 89 protected: | 90 protected: |
| 90 virtual void Init() { | 91 virtual void Init() { |
| 91 #if defined(OS_WIN) | 92 #if defined(OS_WIN) |
| 92 CoInitialize(NULL); | 93 CoInitialize(NULL); |
| 93 #endif | 94 #endif |
| 94 | 95 |
| 95 render_process_ = new RenderProcess(channel_id_); | 96 render_process_ = new RenderProcess(); |
| 97 render_process_->set_main_thread(new RenderThread(channel_id_)); | |
| 96 // It's a little lame to manually set this flag. But the single process | 98 // It's a little lame to manually set this flag. But the single process |
| 97 // RendererThread will receive the WM_QUIT. We don't need to assert on | 99 // RendererThread will receive the WM_QUIT. We don't need to assert on |
| 98 // this thread, so just force the flag manually. | 100 // this thread, so just force the flag manually. |
| 99 // If we want to avoid this, we could create the InProcRendererThread | 101 // If we want to avoid this, we could create the InProcRendererThread |
| 100 // directly with _beginthreadex() rather than using the Thread class. | 102 // directly with _beginthreadex() rather than using the Thread class. |
| 101 base::Thread::SetThreadWasQuitProperly(true); | 103 base::Thread::SetThreadWasQuitProperly(true); |
| 102 } | 104 } |
| 103 | 105 |
| 104 virtual void CleanUp() { | 106 virtual void CleanUp() { |
| 105 delete render_process_; | 107 delete render_process_; |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 | 406 |
| 405 const std::wstring& profile_path = | 407 const std::wstring& profile_path = |
| 406 browser_command_line.GetSwitchValue(switches::kUserDataDir); | 408 browser_command_line.GetSwitchValue(switches::kUserDataDir); |
| 407 if (!profile_path.empty()) | 409 if (!profile_path.empty()) |
| 408 cmd_line.AppendSwitchWithValue(switches::kUserDataDir, | 410 cmd_line.AppendSwitchWithValue(switches::kUserDataDir, |
| 409 profile_path); | 411 profile_path); |
| 410 | 412 |
| 411 if (run_renderer_in_process()) { | 413 if (run_renderer_in_process()) { |
| 412 // Crank up a thread and run the initialization there. With the way that | 414 // Crank up a thread and run the initialization there. With the way that |
| 413 // messages flow between the browser and renderer, this thread is required | 415 // messages flow between the browser and renderer, this thread is required |
| 414 // to prevent a deadlock in single-process mode. When using multiple | 416 // to prevent a deadlock in single-process mode. Since the primordial |
| 415 // processes, the primordial thread in the renderer process has a message | 417 // thread in the renderer process runs the WebKit code and can sometimes |
| 416 // loop which is used for sending messages asynchronously to the io thread | 418 // blocking calls to the UI thread (i.e. this thread), they need to run on |
| 417 // in the browser process. If we don't create this thread, then the | 419 // separate threads. |
| 418 // RenderThread is both responsible for rendering and also for | |
| 419 // communicating IO. This can lead to deadlocks where the RenderThread is | |
| 420 // waiting for the IO to complete, while the browsermain is trying to pass | |
| 421 // an event to the RenderThread. | |
| 422 in_process_renderer_.reset(new RendererMainThread(channel_id)); | 420 in_process_renderer_.reset(new RendererMainThread(channel_id)); |
| 423 | 421 |
| 424 base::Thread::Options options; | 422 base::Thread::Options options; |
| 425 options.message_loop_type = MessageLoop::TYPE_IO; | 423 options.message_loop_type = MessageLoop::TYPE_UI; |
|
Evan Martin
2009/07/27 22:01:31
This seems to have broken --single-process on Linu
| |
| 426 in_process_renderer_->StartWithOptions(options); | 424 in_process_renderer_->StartWithOptions(options); |
| 427 } else { | 425 } else { |
| 428 base::ProcessHandle process = 0; | 426 base::ProcessHandle process = 0; |
| 429 #if defined(OS_WIN) | 427 #if defined(OS_WIN) |
| 430 process = sandbox::StartProcess(&cmd_line); | 428 process = sandbox::StartProcess(&cmd_line); |
| 431 #elif defined(OS_POSIX) | 429 #elif defined(OS_POSIX) |
| 432 #if defined(OS_LINUX) | 430 #if defined(OS_LINUX) |
| 433 if (!has_cmd_prefix) { | 431 if (!has_cmd_prefix) { |
| 434 base::GlobalDescriptors::Mapping mapping; | 432 base::GlobalDescriptors::Mapping mapping; |
| 435 const int ipcfd = channel_->GetClientFileDescriptor(); | 433 const int ipcfd = channel_->GetClientFileDescriptor(); |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 975 profile()->GetExtensionMessageService()->RemoveEventListener(event_name, | 973 profile()->GetExtensionMessageService()->RemoveEventListener(event_name, |
| 976 pid()); | 974 pid()); |
| 977 } | 975 } |
| 978 } | 976 } |
| 979 | 977 |
| 980 void BrowserRenderProcessHost::OnExtensionCloseChannel(int port_id) { | 978 void BrowserRenderProcessHost::OnExtensionCloseChannel(int port_id) { |
| 981 if (profile()->GetExtensionMessageService()) { | 979 if (profile()->GetExtensionMessageService()) { |
| 982 profile()->GetExtensionMessageService()->CloseChannel(port_id); | 980 profile()->GetExtensionMessageService()->CloseChannel(port_id); |
| 983 } | 981 } |
| 984 } | 982 } |
| OLD | NEW |