| 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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 // If we're about to be deleted, we can no longer trust that our profile is | 777 // If we're about to be deleted, we can no longer trust that our profile is |
| 778 // valid, so we ignore incoming messages. | 778 // valid, so we ignore incoming messages. |
| 779 if (deleting_soon_) | 779 if (deleting_soon_) |
| 780 return false; | 780 return false; |
| 781 | 781 |
| 782 mark_child_process_activity_time(); | 782 mark_child_process_activity_time(); |
| 783 if (msg.routing_id() == MSG_ROUTING_CONTROL) { | 783 if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
| 784 // Dispatch control messages. | 784 // Dispatch control messages. |
| 785 bool msg_is_ok = true; | 785 bool msg_is_ok = true; |
| 786 IPC_BEGIN_MESSAGE_MAP_EX(BrowserRenderProcessHost, msg, msg_is_ok) | 786 IPC_BEGIN_MESSAGE_MAP_EX(BrowserRenderProcessHost, msg, msg_is_ok) |
| 787 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, |
| 788 OnShutdownRequest) |
| 787 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdatedCacheStats, | 789 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdatedCacheStats, |
| 788 OnUpdatedCacheStats) | 790 OnUpdatedCacheStats) |
| 789 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, | 791 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, |
| 790 SuddenTerminationChanged) | 792 SuddenTerminationChanged) |
| 791 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, | 793 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, |
| 792 OnUserMetricsRecordAction) | 794 OnUserMetricsRecordAction) |
| 793 IPC_MESSAGE_UNHANDLED_ERROR() | 795 IPC_MESSAGE_UNHANDLED_ERROR() |
| 794 IPC_END_MESSAGE_MAP_EX() | 796 IPC_END_MESSAGE_MAP_EX() |
| 795 | 797 |
| 796 if (!msg_is_ok) { | 798 if (!msg_is_ok) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 816 return true; | 818 return true; |
| 817 } | 819 } |
| 818 return listener->OnMessageReceived(msg); | 820 return listener->OnMessageReceived(msg); |
| 819 } | 821 } |
| 820 | 822 |
| 821 void BrowserRenderProcessHost::OnChannelConnected(int32 peer_pid) { | 823 void BrowserRenderProcessHost::OnChannelConnected(int32 peer_pid) { |
| 822 #if defined(IPC_MESSAGE_LOG_ENABLED) | 824 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 823 Send(new ChildProcessMsg_SetIPCLoggingEnabled( | 825 Send(new ChildProcessMsg_SetIPCLoggingEnabled( |
| 824 IPC::Logging::GetInstance()->Enabled())); | 826 IPC::Logging::GetInstance()->Enabled())); |
| 825 #endif | 827 #endif |
| 828 |
| 829 // Make sure the child checks with us before exiting, so that we do not try |
| 830 // to schedule a new navigation in a swapped out and exiting renderer. |
| 831 Send(new ChildProcessMsg_AskBeforeShutdown()); |
| 826 } | 832 } |
| 827 | 833 |
| 828 void BrowserRenderProcessHost::OnChannelError() { | 834 void BrowserRenderProcessHost::OnChannelError() { |
| 829 // Our child process has died. If we didn't expect it, it's a crash. | 835 // Our child process has died. If we didn't expect it, it's a crash. |
| 830 // In any case, we need to let everyone know it's gone. | 836 // In any case, we need to let everyone know it's gone. |
| 831 // The OnChannelError notification can fire multiple times due to nested sync | 837 // The OnChannelError notification can fire multiple times due to nested sync |
| 832 // calls to a renderer. If we don't have a valid channel here it means we | 838 // calls to a renderer. If we don't have a valid channel here it means we |
| 833 // already handled the error. | 839 // already handled the error. |
| 834 if (!channel_.get()) | 840 if (!channel_.get()) |
| 835 return; | 841 return; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 exit_code)); | 877 exit_code)); |
| 872 iter.Advance(); | 878 iter.Advance(); |
| 873 } | 879 } |
| 874 | 880 |
| 875 ClearTransportDIBCache(); | 881 ClearTransportDIBCache(); |
| 876 | 882 |
| 877 // this object is not deleted at this point and may be reused later. | 883 // this object is not deleted at this point and may be reused later. |
| 878 // TODO(darin): clean this up | 884 // TODO(darin): clean this up |
| 879 } | 885 } |
| 880 | 886 |
| 887 void BrowserRenderProcessHost::OnShutdownRequest() { |
| 888 // Don't shutdown if there are pending RenderViews being swapped back in. |
| 889 if (pending_views_) |
| 890 return; |
| 891 |
| 892 // Notify any tabs that might have swapped out renderers from this process. |
| 893 // They should not attempt to swap them back in. |
| 894 NotificationService::current()->Notify( |
| 895 NotificationType::RENDERER_PROCESS_CLOSING, |
| 896 Source<RenderProcessHost>(this), NotificationService::NoDetails()); |
| 897 |
| 898 Send(new ChildProcessMsg_Shutdown()); |
| 899 } |
| 900 |
| 881 void BrowserRenderProcessHost::OnUpdatedCacheStats( | 901 void BrowserRenderProcessHost::OnUpdatedCacheStats( |
| 882 const WebCache::UsageStats& stats) { | 902 const WebCache::UsageStats& stats) { |
| 883 WebCacheManager::GetInstance()->ObserveStats(id(), stats); | 903 WebCacheManager::GetInstance()->ObserveStats(id(), stats); |
| 884 } | 904 } |
| 885 | 905 |
| 886 void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) { | 906 void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) { |
| 887 set_sudden_termination_allowed(enabled); | 907 set_sudden_termination_allowed(enabled); |
| 888 } | 908 } |
| 889 | 909 |
| 890 void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) { | 910 void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 while (!queued_messages_.empty()) { | 959 while (!queued_messages_.empty()) { |
| 940 Send(queued_messages_.front()); | 960 Send(queued_messages_.front()); |
| 941 queued_messages_.pop(); | 961 queued_messages_.pop(); |
| 942 } | 962 } |
| 943 } | 963 } |
| 944 | 964 |
| 945 void BrowserRenderProcessHost::OnUserMetricsRecordAction( | 965 void BrowserRenderProcessHost::OnUserMetricsRecordAction( |
| 946 const std::string& action) { | 966 const std::string& action) { |
| 947 UserMetrics::RecordComputedAction(action); | 967 UserMetrics::RecordComputedAction(action); |
| 948 } | 968 } |
| OLD | NEW |