| 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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 is_extension_process_ ? 2 : 1); | 805 is_extension_process_ ? 2 : 1); |
| 806 } | 806 } |
| 807 | 807 |
| 808 if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { | 808 if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { |
| 809 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", | 809 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", |
| 810 is_extension_process_ ? 2 : 1); | 810 is_extension_process_ ? 2 : 1); |
| 811 } | 811 } |
| 812 | 812 |
| 813 RendererClosedDetails details(status, exit_code, is_extension_process_); | 813 RendererClosedDetails details(status, exit_code, is_extension_process_); |
| 814 NotificationService::current()->Notify( | 814 NotificationService::current()->Notify( |
| 815 NotificationType::RENDERER_PROCESS_CLOSED, | 815 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 816 Source<RenderProcessHost>(this), | 816 Source<RenderProcessHost>(this), |
| 817 Details<RendererClosedDetails>(&details)); | 817 Details<RendererClosedDetails>(&details)); |
| 818 | 818 |
| 819 child_process_launcher_.reset(); | 819 child_process_launcher_.reset(); |
| 820 channel_.reset(); | 820 channel_.reset(); |
| 821 | 821 |
| 822 IDMap<IPC::Channel::Listener>::iterator iter(&listeners_); | 822 IDMap<IPC::Channel::Listener>::iterator iter(&listeners_); |
| 823 while (!iter.IsAtEnd()) { | 823 while (!iter.IsAtEnd()) { |
| 824 iter.GetCurrentValue()->OnMessageReceived( | 824 iter.GetCurrentValue()->OnMessageReceived( |
| 825 ViewHostMsg_RenderViewGone(iter.GetCurrentKey(), | 825 ViewHostMsg_RenderViewGone(iter.GetCurrentKey(), |
| 826 static_cast<int>(status), | 826 static_cast<int>(status), |
| 827 exit_code)); | 827 exit_code)); |
| 828 iter.Advance(); | 828 iter.Advance(); |
| 829 } | 829 } |
| 830 | 830 |
| 831 ClearTransportDIBCache(); | 831 ClearTransportDIBCache(); |
| 832 | 832 |
| 833 // this object is not deleted at this point and may be reused later. | 833 // this object is not deleted at this point and may be reused later. |
| 834 // TODO(darin): clean this up | 834 // TODO(darin): clean this up |
| 835 } | 835 } |
| 836 | 836 |
| 837 void BrowserRenderProcessHost::OnShutdownRequest() { | 837 void BrowserRenderProcessHost::OnShutdownRequest() { |
| 838 // Don't shutdown if there are pending RenderViews being swapped back in. | 838 // Don't shutdown if there are pending RenderViews being swapped back in. |
| 839 if (pending_views_) | 839 if (pending_views_) |
| 840 return; | 840 return; |
| 841 | 841 |
| 842 // Notify any tabs that might have swapped out renderers from this process. | 842 // Notify any tabs that might have swapped out renderers from this process. |
| 843 // They should not attempt to swap them back in. | 843 // They should not attempt to swap them back in. |
| 844 NotificationService::current()->Notify( | 844 NotificationService::current()->Notify( |
| 845 NotificationType::RENDERER_PROCESS_CLOSING, | 845 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, |
| 846 Source<RenderProcessHost>(this), NotificationService::NoDetails()); | 846 Source<RenderProcessHost>(this), NotificationService::NoDetails()); |
| 847 | 847 |
| 848 Send(new ChildProcessMsg_Shutdown()); | 848 Send(new ChildProcessMsg_Shutdown()); |
| 849 } | 849 } |
| 850 | 850 |
| 851 void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) { | 851 void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) { |
| 852 set_sudden_termination_allowed(enabled); | 852 set_sudden_termination_allowed(enabled); |
| 853 } | 853 } |
| 854 | 854 |
| 855 void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) { | 855 void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 Send(new ViewMsg_SetNextPageID(max_page_id_ + 1)); | 889 Send(new ViewMsg_SetNextPageID(max_page_id_ + 1)); |
| 890 | 890 |
| 891 // NOTE: This needs to be before sending queued messages because | 891 // NOTE: This needs to be before sending queued messages because |
| 892 // ExtensionService uses this notification to initialize the renderer process | 892 // ExtensionService uses this notification to initialize the renderer process |
| 893 // with state that must be there before any JavaScript executes. | 893 // with state that must be there before any JavaScript executes. |
| 894 // | 894 // |
| 895 // The queued messages contain such things as "navigate". If this notification | 895 // The queued messages contain such things as "navigate". If this notification |
| 896 // was after, we can end up executing JavaScript before the initialization | 896 // was after, we can end up executing JavaScript before the initialization |
| 897 // happens. | 897 // happens. |
| 898 NotificationService::current()->Notify( | 898 NotificationService::current()->Notify( |
| 899 NotificationType::RENDERER_PROCESS_CREATED, | 899 content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 900 Source<RenderProcessHost>(this), NotificationService::NoDetails()); | 900 Source<RenderProcessHost>(this), NotificationService::NoDetails()); |
| 901 | 901 |
| 902 while (!queued_messages_.empty()) { | 902 while (!queued_messages_.empty()) { |
| 903 Send(queued_messages_.front()); | 903 Send(queued_messages_.front()); |
| 904 queued_messages_.pop(); | 904 queued_messages_.pop(); |
| 905 } | 905 } |
| 906 } | 906 } |
| 907 | 907 |
| 908 void BrowserRenderProcessHost::OnUserMetricsRecordAction( | 908 void BrowserRenderProcessHost::OnUserMetricsRecordAction( |
| 909 const std::string& action) { | 909 const std::string& action) { |
| 910 UserMetrics::RecordComputedAction(action); | 910 UserMetrics::RecordComputedAction(action); |
| 911 } | 911 } |
| 912 | 912 |
| 913 void BrowserRenderProcessHost::OnRevealFolderInOS(const FilePath& path) { | 913 void BrowserRenderProcessHost::OnRevealFolderInOS(const FilePath& path) { |
| 914 // Only honor the request if appropriate persmissions are granted. | 914 // Only honor the request if appropriate persmissions are granted. |
| 915 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(id(), path)) | 915 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(id(), path)) |
| 916 content::GetContentClient()->browser()->RevealFolderInOS(path); | 916 content::GetContentClient()->browser()->RevealFolderInOS(path); |
| 917 } | 917 } |
| OLD | NEW |