OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 10 #include <algorithm> |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 290 |
291 accessibility_enabled_ = is_accessibility_enabled; | 291 accessibility_enabled_ = is_accessibility_enabled; |
292 | 292 |
293 // It is possible for an extension process to be reused for non-extension | 293 // It is possible for an extension process to be reused for non-extension |
294 // content, e.g. if an extension calls window.open. | 294 // content, e.g. if an extension calls window.open. |
295 extension_process_ = extension_process_ || is_extensions_process; | 295 extension_process_ = extension_process_ || is_extensions_process; |
296 | 296 |
297 // run the IPC channel on the shared IO thread. | 297 // run the IPC channel on the shared IO thread. |
298 base::Thread* io_thread = g_browser_process->io_thread(); | 298 base::Thread* io_thread = g_browser_process->io_thread(); |
299 | 299 |
300 // Construct the AudioRendererHost with the IO thread. | |
301 audio_renderer_host_ = new AudioRendererHost(); | |
302 | |
303 scoped_refptr<ResourceMessageFilter> resource_message_filter( | |
304 new ResourceMessageFilter(g_browser_process->resource_dispatcher_host(), | |
305 id(), | |
306 audio_renderer_host_.get(), | |
307 PluginService::GetInstance(), | |
308 g_browser_process->print_job_manager(), | |
309 profile(), | |
310 widget_helper_)); | |
311 | |
312 CommandLine::StringType renderer_prefix; | 300 CommandLine::StringType renderer_prefix; |
313 #if defined(OS_POSIX) | 301 #if defined(OS_POSIX) |
314 // A command prefix is something prepended to the command line of the spawned | 302 // A command prefix is something prepended to the command line of the spawned |
315 // process. It is supported only on POSIX systems. | 303 // process. It is supported only on POSIX systems. |
316 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 304 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
317 renderer_prefix = | 305 renderer_prefix = |
318 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 306 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
319 #endif // defined(OS_POSIX) | 307 #endif // defined(OS_POSIX) |
320 | 308 |
321 // Find the renderer before creating the channel so if this fails early we | 309 // Find the renderer before creating the channel so if this fails early we |
322 // return without creating the channel. | 310 // return without creating the channel. |
323 FilePath renderer_path = | 311 FilePath renderer_path = |
324 ChildProcessHost::GetChildPath(renderer_prefix.empty()); | 312 ChildProcessHost::GetChildPath(renderer_prefix.empty()); |
325 if (renderer_path.empty()) | 313 if (renderer_path.empty()) |
326 return false; | 314 return false; |
327 | 315 |
328 // Setup the IPC channel. | 316 // Setup the IPC channel. |
329 const std::string channel_id = | 317 const std::string channel_id = |
330 ChildProcessInfo::GenerateRandomChannelID(this); | 318 ChildProcessInfo::GenerateRandomChannelID(this); |
331 channel_.reset( | 319 channel_.reset( |
332 new IPC::SyncChannel(channel_id, IPC::Channel::MODE_SERVER, this, | 320 new IPC::SyncChannel(channel_id, IPC::Channel::MODE_SERVER, this, |
333 resource_message_filter, | |
334 io_thread->message_loop(), true, | 321 io_thread->message_loop(), true, |
335 g_browser_process->shutdown_event())); | 322 g_browser_process->shutdown_event())); |
336 // As a preventive mesure, we DCHECK if someone sends a synchronous message | 323 // As a preventive mesure, we DCHECK if someone sends a synchronous message |
337 // with no time-out, which in the context of the browser process we should not | 324 // with no time-out, which in the context of the browser process we should not |
338 // be doing. | 325 // be doing. |
339 channel_->set_sync_messages_with_no_timeout_allowed(false); | 326 channel_->set_sync_messages_with_no_timeout_allowed(false); |
340 | 327 |
341 scoped_refptr<PepperFileMessageFilter> pepper_file_message_filter( | 328 CreateMessageFilters(); |
342 new PepperFileMessageFilter(id(), profile())); | |
343 channel_->AddFilter(pepper_file_message_filter); | |
344 | 329 |
345 if (run_renderer_in_process()) { | 330 if (run_renderer_in_process()) { |
346 // Crank up a thread and run the initialization there. With the way that | 331 // Crank up a thread and run the initialization there. With the way that |
347 // messages flow between the browser and renderer, this thread is required | 332 // messages flow between the browser and renderer, this thread is required |
348 // to prevent a deadlock in single-process mode. Since the primordial | 333 // to prevent a deadlock in single-process mode. Since the primordial |
349 // thread in the renderer process runs the WebKit code and can sometimes | 334 // thread in the renderer process runs the WebKit code and can sometimes |
350 // make blocking calls to the UI thread (i.e. this thread), they need to run | 335 // make blocking calls to the UI thread (i.e. this thread), they need to run |
351 // on separate threads. | 336 // on separate threads. |
352 in_process_renderer_.reset(new RendererMainThread(channel_id)); | 337 in_process_renderer_.reset(new RendererMainThread(channel_id)); |
353 | 338 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 #endif | 370 #endif |
386 cmd_line, | 371 cmd_line, |
387 this)); | 372 this)); |
388 | 373 |
389 fast_shutdown_started_ = false; | 374 fast_shutdown_started_ = false; |
390 } | 375 } |
391 | 376 |
392 return true; | 377 return true; |
393 } | 378 } |
394 | 379 |
| 380 void BrowserRenderProcessHost::CreateMessageFilters() { |
| 381 // Construct the AudioRendererHost with the IO thread. |
| 382 audio_renderer_host_ = new AudioRendererHost(); |
| 383 |
| 384 scoped_refptr<ResourceMessageFilter> resource_message_filter( |
| 385 new ResourceMessageFilter(g_browser_process->resource_dispatcher_host(), |
| 386 id(), |
| 387 audio_renderer_host_.get(), |
| 388 PluginService::GetInstance(), |
| 389 g_browser_process->print_job_manager(), |
| 390 profile(), |
| 391 widget_helper_)); |
| 392 channel_->AddFilter(resource_message_filter); |
| 393 |
| 394 scoped_refptr<PepperFileMessageFilter> pepper_file_message_filter( |
| 395 new PepperFileMessageFilter(id(), profile())); |
| 396 channel_->AddFilter(pepper_file_message_filter); |
| 397 } |
| 398 |
395 int BrowserRenderProcessHost::GetNextRoutingID() { | 399 int BrowserRenderProcessHost::GetNextRoutingID() { |
396 return widget_helper_->GetNextRoutingID(); | 400 return widget_helper_->GetNextRoutingID(); |
397 } | 401 } |
398 | 402 |
399 void BrowserRenderProcessHost::CancelResourceRequests(int render_widget_id) { | 403 void BrowserRenderProcessHost::CancelResourceRequests(int render_widget_id) { |
400 widget_helper_->CancelResourceRequests(render_widget_id); | 404 widget_helper_->CancelResourceRequests(render_widget_id); |
401 } | 405 } |
402 | 406 |
403 void BrowserRenderProcessHost::CrossSiteClosePageACK( | 407 void BrowserRenderProcessHost::CrossSiteClosePageACK( |
404 const ViewMsg_ClosePage_Params& params) { | 408 const ViewMsg_ClosePage_Params& params) { |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 IPC::InvalidPlatformFileForTransit(), | 1178 IPC::InvalidPlatformFileForTransit(), |
1175 std::vector<std::string>(), | 1179 std::vector<std::string>(), |
1176 std::string(), | 1180 std::string(), |
1177 false)); | 1181 false)); |
1178 } | 1182 } |
1179 } | 1183 } |
1180 | 1184 |
1181 void BrowserRenderProcessHost::EnableAutoSpellCorrect(bool enable) { | 1185 void BrowserRenderProcessHost::EnableAutoSpellCorrect(bool enable) { |
1182 Send(new ViewMsg_SpellChecker_EnableAutoSpellCorrect(enable)); | 1186 Send(new ViewMsg_SpellChecker_EnableAutoSpellCorrect(enable)); |
1183 } | 1187 } |
OLD | NEW |