| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/renderer_host/browser_render_process_host.h" | 8 #include "content/browser/renderer_host/browser_render_process_host.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 } | 523 } |
| 524 | 524 |
| 525 void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( | 525 void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( |
| 526 const CommandLine& browser_cmd, | 526 const CommandLine& browser_cmd, |
| 527 CommandLine* renderer_cmd) const { | 527 CommandLine* renderer_cmd) const { |
| 528 // Propagate the following switches to the renderer command line (along | 528 // Propagate the following switches to the renderer command line (along |
| 529 // with any associated values) if present in the browser command line. | 529 // with any associated values) if present in the browser command line. |
| 530 static const char* const kSwitchNames[] = { | 530 static const char* const kSwitchNames[] = { |
| 531 // We propagate the Chrome Frame command line here as well in case the | 531 // We propagate the Chrome Frame command line here as well in case the |
| 532 // renderer is not run in the sandbox. | 532 // renderer is not run in the sandbox. |
| 533 switches::kAuditAllHandles, |
| 534 switches::kAuditHandles, |
| 533 switches::kChromeFrame, | 535 switches::kChromeFrame, |
| 534 switches::kDisable3DAPIs, | 536 switches::kDisable3DAPIs, |
| 535 switches::kDisableAcceleratedCompositing, | 537 switches::kDisableAcceleratedCompositing, |
| 536 switches::kDisableApplicationCache, | 538 switches::kDisableApplicationCache, |
| 537 switches::kDisableAudio, | 539 switches::kDisableAudio, |
| 538 switches::kDisableBreakpad, | 540 switches::kDisableBreakpad, |
| 539 switches::kDisableDataTransferItems, | 541 switches::kDisableDataTransferItems, |
| 540 switches::kDisableDatabases, | 542 switches::kDisableDatabases, |
| 541 switches::kDisableDesktopNotifications, | 543 switches::kDisableDesktopNotifications, |
| 542 switches::kDisableDeviceOrientation, | 544 switches::kDisableDeviceOrientation, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 // state that will be lost by not calling its unload handlers properly. | 651 // state that will be lost by not calling its unload handlers properly. |
| 650 if (!sudden_termination_allowed()) | 652 if (!sudden_termination_allowed()) |
| 651 return false; | 653 return false; |
| 652 | 654 |
| 653 child_process_launcher_.reset(); | 655 child_process_launcher_.reset(); |
| 654 ProcessDied(base::TERMINATION_STATUS_NORMAL_TERMINATION, 0, false); | 656 ProcessDied(base::TERMINATION_STATUS_NORMAL_TERMINATION, 0, false); |
| 655 fast_shutdown_started_ = true; | 657 fast_shutdown_started_ = true; |
| 656 return true; | 658 return true; |
| 657 } | 659 } |
| 658 | 660 |
| 661 void BrowserRenderProcessHost::DumpHandles() { |
| 662 #if defined(OS_WIN) |
| 663 Send(new ChildProcessMsg_DumpHandles()); |
| 664 return; |
| 665 #endif |
| 666 |
| 667 NOTIMPLEMENTED(); |
| 668 } |
| 669 |
| 659 // This is a platform specific function for mapping a transport DIB given its id | 670 // This is a platform specific function for mapping a transport DIB given its id |
| 660 TransportDIB* BrowserRenderProcessHost::MapTransportDIB( | 671 TransportDIB* BrowserRenderProcessHost::MapTransportDIB( |
| 661 TransportDIB::Id dib_id) { | 672 TransportDIB::Id dib_id) { |
| 662 #if defined(OS_WIN) | 673 #if defined(OS_WIN) |
| 663 // On Windows we need to duplicate the handle from the remote process | 674 // On Windows we need to duplicate the handle from the remote process |
| 664 HANDLE section = chrome::GetSectionFromProcess( | 675 HANDLE section = chrome::GetSectionFromProcess( |
| 665 dib_id.handle, GetHandle(), false /* read write */); | 676 dib_id.handle, GetHandle(), false /* read write */); |
| 666 return TransportDIB::Map(section); | 677 return TransportDIB::Map(section); |
| 667 #elif defined(OS_MACOSX) | 678 #elif defined(OS_MACOSX) |
| 668 // On OSX, the browser allocates all DIBs and keeps a file descriptor around | 679 // On OSX, the browser allocates all DIBs and keeps a file descriptor around |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 if (deleting_soon_ || fast_shutdown_started_) | 760 if (deleting_soon_ || fast_shutdown_started_) |
| 750 return false; | 761 return false; |
| 751 | 762 |
| 752 mark_child_process_activity_time(); | 763 mark_child_process_activity_time(); |
| 753 if (msg.routing_id() == MSG_ROUTING_CONTROL) { | 764 if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
| 754 // Dispatch control messages. | 765 // Dispatch control messages. |
| 755 bool msg_is_ok = true; | 766 bool msg_is_ok = true; |
| 756 IPC_BEGIN_MESSAGE_MAP_EX(BrowserRenderProcessHost, msg, msg_is_ok) | 767 IPC_BEGIN_MESSAGE_MAP_EX(BrowserRenderProcessHost, msg, msg_is_ok) |
| 757 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, | 768 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, |
| 758 OnShutdownRequest) | 769 OnShutdownRequest) |
| 770 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone, |
| 771 OnDumpHandlesDone) |
| 759 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, | 772 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, |
| 760 SuddenTerminationChanged) | 773 SuddenTerminationChanged) |
| 761 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, | 774 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, |
| 762 OnUserMetricsRecordAction) | 775 OnUserMetricsRecordAction) |
| 763 IPC_MESSAGE_HANDLER(ViewHostMsg_RevealFolderInOS, OnRevealFolderInOS) | 776 IPC_MESSAGE_HANDLER(ViewHostMsg_RevealFolderInOS, OnRevealFolderInOS) |
| 764 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) | 777 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) |
| 765 IPC_MESSAGE_UNHANDLED_ERROR() | 778 IPC_MESSAGE_UNHANDLED_ERROR() |
| 766 IPC_END_MESSAGE_MAP_EX() | 779 IPC_END_MESSAGE_MAP_EX() |
| 767 | 780 |
| 768 if (!msg_is_ok) { | 781 if (!msg_is_ok) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 | 907 |
| 895 // Notify any tabs that might have swapped out renderers from this process. | 908 // Notify any tabs that might have swapped out renderers from this process. |
| 896 // They should not attempt to swap them back in. | 909 // They should not attempt to swap them back in. |
| 897 NotificationService::current()->Notify( | 910 NotificationService::current()->Notify( |
| 898 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, | 911 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, |
| 899 Source<RenderProcessHost>(this), NotificationService::NoDetails()); | 912 Source<RenderProcessHost>(this), NotificationService::NoDetails()); |
| 900 | 913 |
| 901 Send(new ChildProcessMsg_Shutdown()); | 914 Send(new ChildProcessMsg_Shutdown()); |
| 902 } | 915 } |
| 903 | 916 |
| 917 void BrowserRenderProcessHost::OnDumpHandlesDone() { |
| 918 Cleanup(); |
| 919 } |
| 920 |
| 904 void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) { | 921 void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) { |
| 905 set_sudden_termination_allowed(enabled); | 922 set_sudden_termination_allowed(enabled); |
| 906 } | 923 } |
| 907 | 924 |
| 908 void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) { | 925 void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) { |
| 909 // Note: we always set the backgrounded_ value. If the process is NULL | 926 // Note: we always set the backgrounded_ value. If the process is NULL |
| 910 // (and hence hasn't been created yet), we will set the process priority | 927 // (and hence hasn't been created yet), we will set the process priority |
| 911 // later when we create the process. | 928 // later when we create the process. |
| 912 backgrounded_ = backgrounded; | 929 backgrounded_ = backgrounded; |
| 913 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) | 930 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 void BrowserRenderProcessHost::OnRevealFolderInOS(const FilePath& path) { | 989 void BrowserRenderProcessHost::OnRevealFolderInOS(const FilePath& path) { |
| 973 // Only honor the request if appropriate persmissions are granted. | 990 // Only honor the request if appropriate persmissions are granted. |
| 974 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(id(), path)) | 991 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(id(), path)) |
| 975 content::GetContentClient()->browser()->OpenItem(path); | 992 content::GetContentClient()->browser()->OpenItem(path); |
| 976 } | 993 } |
| 977 | 994 |
| 978 void BrowserRenderProcessHost::OnSavedPageAsMHTML(int job_id, bool success) { | 995 void BrowserRenderProcessHost::OnSavedPageAsMHTML(int job_id, bool success) { |
| 979 content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> | 996 content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> |
| 980 MHTMLGenerated(job_id, success); | 997 MHTMLGenerated(job_id, success); |
| 981 } | 998 } |
| OLD | NEW |