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

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

Issue 199105: Continue with the FreeBSD port - this version builds and links, though... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "chrome/common/result_codes.h" 56 #include "chrome/common/result_codes.h"
57 #include "chrome/renderer/render_process.h" 57 #include "chrome/renderer/render_process.h"
58 #include "chrome/renderer/render_thread.h" 58 #include "chrome/renderer/render_thread.h"
59 #include "chrome/installer/util/google_update_settings.h" 59 #include "chrome/installer/util/google_update_settings.h"
60 #include "grit/generated_resources.h" 60 #include "grit/generated_resources.h"
61 #include "ipc/ipc_switches.h" 61 #include "ipc/ipc_switches.h"
62 62
63 #if defined(OS_WIN) 63 #if defined(OS_WIN)
64 #include "app/win_util.h" 64 #include "app/win_util.h"
65 #include "chrome/browser/sandbox_policy.h" 65 #include "chrome/browser/sandbox_policy.h"
66 #elif defined(OS_LINUX) 66 #elif defined(OS_LINUX) || defined(OS_FREEBSD)
67 #include "base/linux_util.h" 67 #include "base/linux_util.h"
68 #include "chrome/browser/zygote_host_linux.h" 68 #include "chrome/browser/zygote_host_linux.h"
69 #include "chrome/browser/renderer_host/render_crash_handler_host_linux.h" 69 #include "chrome/browser/renderer_host/render_crash_handler_host_linux.h"
70 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h" 70 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h"
71 #endif 71 #endif
72 72
73 using WebKit::WebCache; 73 using WebKit::WebCache;
74 74
75 #include "third_party/skia/include/core/SkBitmap.h" 75 #include "third_party/skia/include/core/SkBitmap.h"
76 76
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 // We may have some unsent messages at this point, but that's OK. 232 // We may have some unsent messages at this point, but that's OK.
233 channel_.reset(); 233 channel_.reset();
234 234
235 // Destroy the AudioRendererHost properly. 235 // Destroy the AudioRendererHost properly.
236 if (audio_renderer_host_.get()) 236 if (audio_renderer_host_.get())
237 audio_renderer_host_->Destroy(); 237 audio_renderer_host_->Destroy();
238 238
239 if (process_.handle() && !run_renderer_in_process()) { 239 if (process_.handle() && !run_renderer_in_process()) {
240 if (zygote_child_) { 240 if (zygote_child_) {
241 #if defined(OS_LINUX) 241 #if defined(OS_LINUX) || defined(OS_FREEBSD)
242 Singleton<ZygoteHost>()->EnsureProcessTerminated(process_.handle()); 242 Singleton<ZygoteHost>()->EnsureProcessTerminated(process_.handle());
243 #endif 243 #endif
244 } else { 244 } else {
245 ProcessWatcher::EnsureProcessTerminated(process_.handle()); 245 ProcessWatcher::EnsureProcessTerminated(process_.handle());
246 } 246 }
247 } 247 }
248 248
249 ClearTransportDIBCache(); 249 ClearTransportDIBCache();
250 } 250 }
251 251
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 if (run_renderer_in_process()) { 390 if (run_renderer_in_process()) {
391 // Crank up a thread and run the initialization there. With the way that 391 // Crank up a thread and run the initialization there. With the way that
392 // messages flow between the browser and renderer, this thread is required 392 // messages flow between the browser and renderer, this thread is required
393 // to prevent a deadlock in single-process mode. Since the primordial 393 // to prevent a deadlock in single-process mode. Since the primordial
394 // thread in the renderer process runs the WebKit code and can sometimes 394 // thread in the renderer process runs the WebKit code and can sometimes
395 // make blocking calls to the UI thread (i.e. this thread), they need to run 395 // make blocking calls to the UI thread (i.e. this thread), they need to run
396 // on separate threads. 396 // on separate threads.
397 in_process_renderer_.reset(new RendererMainThread(channel_id)); 397 in_process_renderer_.reset(new RendererMainThread(channel_id));
398 398
399 base::Thread::Options options; 399 base::Thread::Options options;
400 #if !defined(OS_LINUX) 400 #if !defined(USE_X11)
401 // In-process plugins require this to be a UI message loop. 401 // In-process plugins require this to be a UI message loop.
402 options.message_loop_type = MessageLoop::TYPE_UI; 402 options.message_loop_type = MessageLoop::TYPE_UI;
403 #else 403 #else
404 // We can't have multiple UI loops on Linux, so we don't support 404 // We can't have multiple UI loops on X, so we don't support
405 // in-process plugins. 405 // in-process plugins.
406 options.message_loop_type = MessageLoop::TYPE_DEFAULT; 406 options.message_loop_type = MessageLoop::TYPE_DEFAULT;
407 #endif 407 #endif
408 in_process_renderer_->StartWithOptions(options); 408 in_process_renderer_->StartWithOptions(options);
409 } else { 409 } else {
410 base::ProcessHandle process = 0; 410 base::ProcessHandle process = 0;
411 #if defined(OS_WIN) 411 #if defined(OS_WIN)
412 process = sandbox::StartProcess(&cmd_line); 412 process = sandbox::StartProcess(&cmd_line);
413 #elif defined(OS_POSIX) 413 #elif defined(OS_POSIX)
414 #if defined(OS_LINUX) 414 #if defined(OS_LINUX) || defined(OS_FREEBSD)
415 if (!has_cmd_prefix) { 415 if (!has_cmd_prefix) {
416 base::GlobalDescriptors::Mapping mapping; 416 base::GlobalDescriptors::Mapping mapping;
417 const int ipcfd = channel_->GetClientFileDescriptor(); 417 const int ipcfd = channel_->GetClientFileDescriptor();
418 mapping.push_back(std::pair<uint32_t, int>(kPrimaryIPCChannel, ipcfd)); 418 mapping.push_back(std::pair<uint32_t, int>(kPrimaryIPCChannel, ipcfd));
419 const int crash_signal_fd = 419 const int crash_signal_fd =
420 Singleton<RenderCrashHandlerHostLinux>()->GetDeathSignalSocket(); 420 Singleton<RenderCrashHandlerHostLinux>()->GetDeathSignalSocket();
421 if (crash_signal_fd >= 0) { 421 if (crash_signal_fd >= 0) {
422 mapping.push_back(std::pair<uint32_t, int>(kCrashDumpSignal, 422 mapping.push_back(std::pair<uint32_t, int>(kCrashDumpSignal,
423 crash_signal_fd)); 423 crash_signal_fd));
424 } 424 }
425 process = Singleton<ZygoteHost>()->ForkRenderer(cmd_line.argv(), mapping); 425 process = Singleton<ZygoteHost>()->ForkRenderer(cmd_line.argv(), mapping);
426 zygote_child_ = true; 426 zygote_child_ = true;
427 } else { 427 } else {
428 #endif // defined(OS_LINUX) 428 #endif // defined(OS_LINUX)
429 // NOTE: This code is duplicated with plugin_process_host.cc, but 429 // NOTE: This code is duplicated with plugin_process_host.cc, but
430 // there's not a good place to de-duplicate it. 430 // there's not a good place to de-duplicate it.
431 base::file_handle_mapping_vector fds_to_map; 431 base::file_handle_mapping_vector fds_to_map;
432 const int ipcfd = channel_->GetClientFileDescriptor(); 432 const int ipcfd = channel_->GetClientFileDescriptor();
433 fds_to_map.push_back(std::make_pair(ipcfd, kPrimaryIPCChannel + 3)); 433 fds_to_map.push_back(std::make_pair(ipcfd, kPrimaryIPCChannel + 3));
434 #if defined(OS_LINUX) 434 #if defined(OS_LINUX) || defined(OS_FREEBSD)
435 const int crash_signal_fd = 435 const int crash_signal_fd =
436 Singleton<RenderCrashHandlerHostLinux>()->GetDeathSignalSocket(); 436 Singleton<RenderCrashHandlerHostLinux>()->GetDeathSignalSocket();
437 if (crash_signal_fd >= 0) { 437 if (crash_signal_fd >= 0) {
438 fds_to_map.push_back(std::make_pair(crash_signal_fd, 438 fds_to_map.push_back(std::make_pair(crash_signal_fd,
439 kCrashDumpSignal + 3)); 439 kCrashDumpSignal + 3));
440 } 440 }
441 const int sandbox_fd = 441 const int sandbox_fd =
442 Singleton<RenderSandboxHostLinux>()->GetRendererSocket(); 442 Singleton<RenderSandboxHostLinux>()->GetRendererSocket();
443 fds_to_map.push_back(std::make_pair(sandbox_fd, kSandboxIPCChannel + 3)); 443 fds_to_map.push_back(std::make_pair(sandbox_fd, kSandboxIPCChannel + 3));
444 #endif // defined(OS_LINUX) 444 #endif // defined(OS_LINUX)
445 base::LaunchApp(cmd_line.argv(), fds_to_map, false, &process); 445 base::LaunchApp(cmd_line.argv(), fds_to_map, false, &process);
446 zygote_child_ = false; 446 zygote_child_ = false;
447 #if defined(OS_LINUX) 447 #if defined(OS_LINUX) || defined(OS_FREEBSD)
448 } 448 }
449 #endif // defined(OS_LINUX) 449 #endif // defined(OS_LINUX)
450 #endif // defined(OS_WIN) 450 #endif // defined(OS_WIN)
451 451
452 if (!process) { 452 if (!process) {
453 channel_.reset(); 453 channel_.reset();
454 return false; 454 return false;
455 } 455 }
456 process_.set_handle(process); 456 process_.set_handle(process);
457 } 457 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 TransportDIB::Id dib_id) { 654 TransportDIB::Id dib_id) {
655 #if defined(OS_WIN) 655 #if defined(OS_WIN)
656 // On Windows we need to duplicate the handle from the remote process 656 // On Windows we need to duplicate the handle from the remote process
657 HANDLE section = win_util::GetSectionFromProcess( 657 HANDLE section = win_util::GetSectionFromProcess(
658 dib_id.handle, GetRendererProcessHandle(), false /* read write */); 658 dib_id.handle, GetRendererProcessHandle(), false /* read write */);
659 return TransportDIB::Map(section); 659 return TransportDIB::Map(section);
660 #elif defined(OS_MACOSX) 660 #elif defined(OS_MACOSX)
661 // On OSX, the browser allocates all DIBs and keeps a file descriptor around 661 // On OSX, the browser allocates all DIBs and keeps a file descriptor around
662 // for each. 662 // for each.
663 return widget_helper_->MapTransportDIB(dib_id); 663 return widget_helper_->MapTransportDIB(dib_id);
664 #elif defined(OS_LINUX) 664 #elif defined(USE_X11)
665 return TransportDIB::Map(dib_id); 665 return TransportDIB::Map(dib_id);
666 #endif // defined(OS_LINUX) 666 #endif // defined(USE_X11)
667 } 667 }
668 668
669 TransportDIB* BrowserRenderProcessHost::GetTransportDIB( 669 TransportDIB* BrowserRenderProcessHost::GetTransportDIB(
670 TransportDIB::Id dib_id) { 670 TransportDIB::Id dib_id) {
671 const std::map<TransportDIB::Id, TransportDIB*>::iterator 671 const std::map<TransportDIB::Id, TransportDIB*>::iterator
672 i = cached_dibs_.find(dib_id); 672 i = cached_dibs_.find(dib_id);
673 if (i != cached_dibs_.end()) { 673 if (i != cached_dibs_.end()) {
674 cached_dibs_cleaner_.Reset(); 674 cached_dibs_cleaner_.Reset();
675 return i->second; 675 return i->second;
676 } 676 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 void BrowserRenderProcessHost::OnChannelError() { 809 void BrowserRenderProcessHost::OnChannelError() {
810 // Our child process has died. If we didn't expect it, it's a crash. 810 // Our child process has died. If we didn't expect it, it's a crash.
811 // In any case, we need to let everyone know it's gone. 811 // In any case, we need to let everyone know it's gone.
812 812
813 DCHECK(process_.handle()); 813 DCHECK(process_.handle());
814 DCHECK(channel_.get()); 814 DCHECK(channel_.get());
815 815
816 bool child_exited; 816 bool child_exited;
817 bool did_crash; 817 bool did_crash;
818 if (zygote_child_) { 818 if (zygote_child_) {
819 #if defined(OS_LINUX) 819 #if defined(OS_LINUX) || defined(OS_FREEBSD)
820 did_crash = Singleton<ZygoteHost>()->DidProcessCrash( 820 did_crash = Singleton<ZygoteHost>()->DidProcessCrash(
821 process_.handle(), &child_exited); 821 process_.handle(), &child_exited);
822 #else 822 #else
823 NOTREACHED(); 823 NOTREACHED();
824 did_crash = true; 824 did_crash = true;
825 #endif 825 #endif
826 } else { 826 } else {
827 did_crash = base::DidProcessCrash(&child_exited, process_.handle()); 827 did_crash = base::DidProcessCrash(&child_exited, process_.handle());
828 } 828 }
829 829
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 profile()->GetExtensionMessageService()->RemoveEventListener( 959 profile()->GetExtensionMessageService()->RemoveEventListener(
960 event_name, id()); 960 event_name, id());
961 } 961 }
962 } 962 }
963 963
964 void BrowserRenderProcessHost::OnExtensionCloseChannel(int port_id) { 964 void BrowserRenderProcessHost::OnExtensionCloseChannel(int port_id) {
965 if (profile()->GetExtensionMessageService()) { 965 if (profile()->GetExtensionMessageService()) {
966 profile()->GetExtensionMessageService()->CloseChannel(port_id); 966 profile()->GetExtensionMessageService()->CloseChannel(port_id);
967 } 967 }
968 } 968 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/backing_store_x.cc ('k') | chrome/browser/renderer_host/resource_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698