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 // 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 148 } |
149 | 149 |
150 BrowserRenderProcessHost::~BrowserRenderProcessHost() { | 150 BrowserRenderProcessHost::~BrowserRenderProcessHost() { |
151 // Some tests hold BrowserRenderProcessHost in a scoped_ptr, so we must call | 151 // Some tests hold BrowserRenderProcessHost in a scoped_ptr, so we must call |
152 // Unregister here as well as in response to Release(). | 152 // Unregister here as well as in response to Release(). |
153 Unregister(); | 153 Unregister(); |
154 | 154 |
155 // We may have some unsent messages at this point, but that's OK. | 155 // We may have some unsent messages at this point, but that's OK. |
156 channel_.reset(); | 156 channel_.reset(); |
157 | 157 |
| 158 // Destroy the AudioRendererHost properly. |
| 159 if (audio_renderer_host_.get()) |
| 160 audio_renderer_host_->Destroy(); |
| 161 |
158 if (process_.handle() && !run_renderer_in_process()) { | 162 if (process_.handle() && !run_renderer_in_process()) { |
159 ProcessWatcher::EnsureProcessTerminated(process_.handle()); | 163 ProcessWatcher::EnsureProcessTerminated(process_.handle()); |
160 } | 164 } |
161 | 165 |
162 profile()->GetPrefs()->RemovePrefObserver(prefs::kBlockPopups, this); | 166 profile()->GetPrefs()->RemovePrefObserver(prefs::kBlockPopups, this); |
163 | 167 |
164 NotificationService::current()->RemoveObserver(this, | 168 NotificationService::current()->RemoveObserver(this, |
165 NotificationType::USER_SCRIPTS_LOADED, NotificationService::AllSources()); | 169 NotificationType::USER_SCRIPTS_LOADED, NotificationService::AllSources()); |
166 } | 170 } |
167 | 171 |
(...skipping 20 matching lines...) Expand all Loading... |
188 | 192 |
189 bool BrowserRenderProcessHost::Init() { | 193 bool BrowserRenderProcessHost::Init() { |
190 // calling Init() more than once does nothing, this makes it more convenient | 194 // calling Init() more than once does nothing, this makes it more convenient |
191 // for the view host which may not be sure in some cases | 195 // for the view host which may not be sure in some cases |
192 if (channel_.get()) | 196 if (channel_.get()) |
193 return true; | 197 return true; |
194 | 198 |
195 // run the IPC channel on the shared IO thread. | 199 // run the IPC channel on the shared IO thread. |
196 base::Thread* io_thread = g_browser_process->io_thread(); | 200 base::Thread* io_thread = g_browser_process->io_thread(); |
197 | 201 |
| 202 // Construct the AudioRendererHost with the IO thread. |
| 203 audio_renderer_host_ = |
| 204 new AudioRendererHost(io_thread->message_loop()); |
| 205 |
198 scoped_refptr<ResourceMessageFilter> resource_message_filter = | 206 scoped_refptr<ResourceMessageFilter> resource_message_filter = |
199 new ResourceMessageFilter(g_browser_process->resource_dispatcher_host(), | 207 new ResourceMessageFilter(g_browser_process->resource_dispatcher_host(), |
| 208 audio_renderer_host_.get(), |
200 PluginService::GetInstance(), | 209 PluginService::GetInstance(), |
201 g_browser_process->print_job_manager(), | 210 g_browser_process->print_job_manager(), |
202 host_id(), | 211 host_id(), |
203 profile(), | 212 profile(), |
204 widget_helper_, | 213 widget_helper_, |
205 profile()->GetSpellChecker()); | 214 profile()->GetSpellChecker()); |
206 | 215 |
207 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 216 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
208 | 217 |
209 // setup IPC channel | 218 // setup IPC channel |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 // child processes determine the pid of the parent. | 818 // child processes determine the pid of the parent. |
810 // Build the channel ID. This is composed of a unique identifier for the | 819 // Build the channel ID. This is composed of a unique identifier for the |
811 // parent browser process, an identifier for the renderer/plugin instance, | 820 // parent browser process, an identifier for the renderer/plugin instance, |
812 // and a random component. We use a random component so that a hacked child | 821 // and a random component. We use a random component so that a hacked child |
813 // process can't cause denial of service by causing future named pipe creation | 822 // process can't cause denial of service by causing future named pipe creation |
814 // to fail. | 823 // to fail. |
815 return StringPrintf(L"%d.%x.%d", | 824 return StringPrintf(L"%d.%x.%d", |
816 base::GetCurrentProcId(), instance, | 825 base::GetCurrentProcId(), instance, |
817 base::RandInt(0, std::numeric_limits<int>::max())); | 826 base::RandInt(0, std::numeric_limits<int>::max())); |
818 } | 827 } |
OLD | NEW |