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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" | 65 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" |
66 #include "content/browser/renderer_host/text_input_client_message_filter.h" | 66 #include "content/browser/renderer_host/text_input_client_message_filter.h" |
67 #include "content/browser/resolve_proxy_msg_helper.h" | 67 #include "content/browser/resolve_proxy_msg_helper.h" |
68 #include "content/browser/speech/speech_input_dispatcher_host.h" | 68 #include "content/browser/speech/speech_input_dispatcher_host.h" |
69 #include "content/browser/trace_message_filter.h" | 69 #include "content/browser/trace_message_filter.h" |
70 #include "content/browser/user_metrics.h" | 70 #include "content/browser/user_metrics.h" |
71 #include "content/browser/worker_host/worker_message_filter.h" | 71 #include "content/browser/worker_host/worker_message_filter.h" |
72 #include "content/common/child_process_info.h" | 72 #include "content/common/child_process_info.h" |
73 #include "content/common/child_process_messages.h" | 73 #include "content/common/child_process_messages.h" |
74 #include "content/common/gpu/gpu_messages.h" | 74 #include "content/common/gpu/gpu_messages.h" |
75 #include "content/common/notification_service.h" | 75 #include "content/public/browser/notification_service.h" |
76 #include "content/common/process_watcher.h" | 76 #include "content/common/process_watcher.h" |
77 #include "content/common/resource_messages.h" | 77 #include "content/common/resource_messages.h" |
78 #include "content/common/result_codes.h" | 78 #include "content/common/result_codes.h" |
79 #include "content/common/view_messages.h" | 79 #include "content/common/view_messages.h" |
80 #include "content/public/browser/content_browser_client.h" | 80 #include "content/public/browser/content_browser_client.h" |
81 #include "content/public/common/content_switches.h" | 81 #include "content/public/common/content_switches.h" |
82 #include "content/renderer/render_process_impl.h" | 82 #include "content/renderer/render_process_impl.h" |
83 #include "content/renderer/render_thread_impl.h" | 83 #include "content/renderer/render_thread_impl.h" |
84 #include "ipc/ipc_logging.h" | 84 #include "ipc/ipc_logging.h" |
85 #include "ipc/ipc_platform_file.h" | 85 #include "ipc/ipc_platform_file.h" |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 | 863 |
864 void BrowserRenderProcessHost::ProcessDied( | 864 void BrowserRenderProcessHost::ProcessDied( |
865 base::TerminationStatus status, int exit_code, bool was_alive) { | 865 base::TerminationStatus status, int exit_code, bool was_alive) { |
866 // Our child process has died. If we didn't expect it, it's a crash. | 866 // Our child process has died. If we didn't expect it, it's a crash. |
867 // In any case, we need to let everyone know it's gone. | 867 // In any case, we need to let everyone know it's gone. |
868 // The OnChannelError notification can fire multiple times due to nested sync | 868 // The OnChannelError notification can fire multiple times due to nested sync |
869 // calls to a renderer. If we don't have a valid channel here it means we | 869 // calls to a renderer. If we don't have a valid channel here it means we |
870 // already handled the error. | 870 // already handled the error. |
871 | 871 |
872 RendererClosedDetails details(status, exit_code, was_alive); | 872 RendererClosedDetails details(status, exit_code, was_alive); |
873 NotificationService::current()->Notify( | 873 content::NotificationService::current()->Notify( |
874 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 874 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
875 content::Source<RenderProcessHost>(this), | 875 content::Source<RenderProcessHost>(this), |
876 content::Details<RendererClosedDetails>(&details)); | 876 content::Details<RendererClosedDetails>(&details)); |
877 | 877 |
878 child_process_launcher_.reset(); | 878 child_process_launcher_.reset(); |
879 channel_.reset(); | 879 channel_.reset(); |
880 | 880 |
881 IDMap<IPC::Channel::Listener>::iterator iter(&listeners_); | 881 IDMap<IPC::Channel::Listener>::iterator iter(&listeners_); |
882 while (!iter.IsAtEnd()) { | 882 while (!iter.IsAtEnd()) { |
883 iter.GetCurrentValue()->OnMessageReceived( | 883 iter.GetCurrentValue()->OnMessageReceived( |
884 ViewHostMsg_RenderViewGone(iter.GetCurrentKey(), | 884 ViewHostMsg_RenderViewGone(iter.GetCurrentKey(), |
885 static_cast<int>(status), | 885 static_cast<int>(status), |
886 exit_code)); | 886 exit_code)); |
887 iter.Advance(); | 887 iter.Advance(); |
888 } | 888 } |
889 | 889 |
890 ClearTransportDIBCache(); | 890 ClearTransportDIBCache(); |
891 | 891 |
892 // this object is not deleted at this point and may be reused later. | 892 // this object is not deleted at this point and may be reused later. |
893 // TODO(darin): clean this up | 893 // TODO(darin): clean this up |
894 } | 894 } |
895 | 895 |
896 void BrowserRenderProcessHost::OnShutdownRequest() { | 896 void BrowserRenderProcessHost::OnShutdownRequest() { |
897 // Don't shutdown if there are pending RenderViews being swapped back in. | 897 // Don't shutdown if there are pending RenderViews being swapped back in. |
898 if (pending_views_) | 898 if (pending_views_) |
899 return; | 899 return; |
900 | 900 |
901 // Notify any tabs that might have swapped out renderers from this process. | 901 // Notify any tabs that might have swapped out renderers from this process. |
902 // They should not attempt to swap them back in. | 902 // They should not attempt to swap them back in. |
903 NotificationService::current()->Notify( | 903 content::NotificationService::current()->Notify( |
904 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, | 904 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, |
905 content::Source<RenderProcessHost>(this), | 905 content::Source<RenderProcessHost>(this), |
906 NotificationService::NoDetails()); | 906 content::NotificationService::NoDetails()); |
907 | 907 |
908 Send(new ChildProcessMsg_Shutdown()); | 908 Send(new ChildProcessMsg_Shutdown()); |
909 } | 909 } |
910 | 910 |
911 void BrowserRenderProcessHost::OnDumpHandlesDone() { | 911 void BrowserRenderProcessHost::OnDumpHandlesDone() { |
912 Cleanup(); | 912 Cleanup(); |
913 } | 913 } |
914 | 914 |
915 void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) { | 915 void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) { |
916 set_sudden_termination_allowed(enabled); | 916 set_sudden_termination_allowed(enabled); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 if (max_page_id_ != -1) | 958 if (max_page_id_ != -1) |
959 Send(new ViewMsg_SetNextPageID(max_page_id_ + 1)); | 959 Send(new ViewMsg_SetNextPageID(max_page_id_ + 1)); |
960 | 960 |
961 // NOTE: This needs to be before sending queued messages because | 961 // NOTE: This needs to be before sending queued messages because |
962 // ExtensionService uses this notification to initialize the renderer process | 962 // ExtensionService uses this notification to initialize the renderer process |
963 // with state that must be there before any JavaScript executes. | 963 // with state that must be there before any JavaScript executes. |
964 // | 964 // |
965 // The queued messages contain such things as "navigate". If this notification | 965 // The queued messages contain such things as "navigate". If this notification |
966 // was after, we can end up executing JavaScript before the initialization | 966 // was after, we can end up executing JavaScript before the initialization |
967 // happens. | 967 // happens. |
968 NotificationService::current()->Notify( | 968 content::NotificationService::current()->Notify( |
969 content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 969 content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
970 content::Source<RenderProcessHost>(this), | 970 content::Source<RenderProcessHost>(this), |
971 NotificationService::NoDetails()); | 971 content::NotificationService::NoDetails()); |
972 | 972 |
973 while (!queued_messages_.empty()) { | 973 while (!queued_messages_.empty()) { |
974 Send(queued_messages_.front()); | 974 Send(queued_messages_.front()); |
975 queued_messages_.pop(); | 975 queued_messages_.pop(); |
976 } | 976 } |
977 } | 977 } |
978 | 978 |
979 void BrowserRenderProcessHost::OnUserMetricsRecordAction( | 979 void BrowserRenderProcessHost::OnUserMetricsRecordAction( |
980 const std::string& action) { | 980 const std::string& action) { |
981 UserMetrics::RecordComputedAction(action); | 981 UserMetrics::RecordComputedAction(action); |
982 } | 982 } |
983 | 983 |
984 void BrowserRenderProcessHost::OnRevealFolderInOS(const FilePath& path) { | 984 void BrowserRenderProcessHost::OnRevealFolderInOS(const FilePath& path) { |
985 // Only honor the request if appropriate persmissions are granted. | 985 // Only honor the request if appropriate persmissions are granted. |
986 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(id(), path)) | 986 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(id(), path)) |
987 content::GetContentClient()->browser()->OpenItem(path); | 987 content::GetContentClient()->browser()->OpenItem(path); |
988 } | 988 } |
989 | 989 |
990 void BrowserRenderProcessHost::OnSavedPageAsMHTML(int job_id, int64 data_size) { | 990 void BrowserRenderProcessHost::OnSavedPageAsMHTML(int job_id, int64 data_size) { |
991 content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> | 991 content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> |
992 MHTMLGenerated(job_id, data_size); | 992 MHTMLGenerated(job_id, data_size); |
993 } | 993 } |
OLD | NEW |