OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 #include "content/common/child_process_messages.h" | 110 #include "content/common/child_process_messages.h" |
111 #include "content/common/gpu/gpu_messages.h" | 111 #include "content/common/gpu/gpu_messages.h" |
112 #include "content/common/resource_messages.h" | 112 #include "content/common/resource_messages.h" |
113 #include "content/common/view_messages.h" | 113 #include "content/common/view_messages.h" |
114 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" | 114 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" |
115 #include "content/public/browser/browser_context.h" | 115 #include "content/public/browser/browser_context.h" |
116 #include "content/public/browser/content_browser_client.h" | 116 #include "content/public/browser/content_browser_client.h" |
117 #include "content/public/browser/notification_service.h" | 117 #include "content/public/browser/notification_service.h" |
118 #include "content/public/browser/notification_types.h" | 118 #include "content/public/browser/notification_types.h" |
119 #include "content/public/browser/render_process_host_factory.h" | 119 #include "content/public/browser/render_process_host_factory.h" |
| 120 #include "content/public/browser/render_process_host_observer.h" |
120 #include "content/public/browser/render_widget_host.h" | 121 #include "content/public/browser/render_widget_host.h" |
121 #include "content/public/browser/render_widget_host_iterator.h" | 122 #include "content/public/browser/render_widget_host_iterator.h" |
122 #include "content/public/browser/resource_context.h" | 123 #include "content/public/browser/resource_context.h" |
123 #include "content/public/browser/user_metrics.h" | 124 #include "content/public/browser/user_metrics.h" |
124 #include "content/public/common/content_constants.h" | 125 #include "content/public/common/content_constants.h" |
125 #include "content/public/common/content_switches.h" | 126 #include "content/public/common/content_switches.h" |
126 #include "content/public/common/process_type.h" | 127 #include "content/public/common/process_type.h" |
127 #include "content/public/common/result_codes.h" | 128 #include "content/public/common/result_codes.h" |
128 #include "content/public/common/url_constants.h" | 129 #include "content/public/common/url_constants.h" |
129 #include "gpu/command_buffer/service/gpu_switches.h" | 130 #include "gpu/command_buffer/service/gpu_switches.h" |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 // We wait to close the channels until the child process has finished | 766 // We wait to close the channels until the child process has finished |
766 // dumping handles and sends us ChildProcessHostMsg_DumpHandlesDone. | 767 // dumping handles and sends us ChildProcessHostMsg_DumpHandlesDone. |
767 return; | 768 return; |
768 } | 769 } |
769 #endif | 770 #endif |
770 // Keep the one renderer thread around forever in single process mode. | 771 // Keep the one renderer thread around forever in single process mode. |
771 if (!run_renderer_in_process()) | 772 if (!run_renderer_in_process()) |
772 Cleanup(); | 773 Cleanup(); |
773 } | 774 } |
774 | 775 |
| 776 void RenderProcessHostImpl::AddObserver(RenderProcessHostObserver* observer) { |
| 777 observers_.AddObserver(observer); |
| 778 } |
| 779 |
| 780 void RenderProcessHostImpl::RemoveObserver( |
| 781 RenderProcessHostObserver* observer) { |
| 782 observers_.RemoveObserver(observer); |
| 783 } |
| 784 |
775 bool RenderProcessHostImpl::WaitForBackingStoreMsg( | 785 bool RenderProcessHostImpl::WaitForBackingStoreMsg( |
776 int render_widget_id, | 786 int render_widget_id, |
777 const base::TimeDelta& max_delay, | 787 const base::TimeDelta& max_delay, |
778 IPC::Message* msg) { | 788 IPC::Message* msg) { |
779 // The post task to this thread with the process id could be in queue, and we | 789 // The post task to this thread with the process id could be in queue, and we |
780 // don't want to dispatch a message before then since it will need the handle. | 790 // don't want to dispatch a message before then since it will need the handle. |
781 if (child_process_launcher_.get() && child_process_launcher_->IsStarting()) | 791 if (child_process_launcher_.get() && child_process_launcher_->IsStarting()) |
782 return false; | 792 return false; |
783 | 793 |
784 return widget_helper_->WaitForBackingStoreMsg(render_widget_id, | 794 return widget_helper_->WaitForBackingStoreMsg(render_widget_id, |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 } | 1364 } |
1355 | 1365 |
1356 bool RenderProcessHostImpl::IgnoreInputEvents() const { | 1366 bool RenderProcessHostImpl::IgnoreInputEvents() const { |
1357 return ignore_input_events_; | 1367 return ignore_input_events_; |
1358 } | 1368 } |
1359 | 1369 |
1360 void RenderProcessHostImpl::Cleanup() { | 1370 void RenderProcessHostImpl::Cleanup() { |
1361 // When no other owners of this object, we can delete ourselves | 1371 // When no other owners of this object, we can delete ourselves |
1362 if (listeners_.IsEmpty()) { | 1372 if (listeners_.IsEmpty()) { |
1363 DCHECK_EQ(0, pending_views_); | 1373 DCHECK_EQ(0, pending_views_); |
| 1374 FOR_EACH_OBSERVER(RenderProcessHostObserver, |
| 1375 observers_, |
| 1376 RenderProcessHostDestroyed(this)); |
1364 NotificationService::current()->Notify( | 1377 NotificationService::current()->Notify( |
1365 NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 1378 NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
1366 Source<RenderProcessHost>(this), | 1379 Source<RenderProcessHost>(this), |
1367 NotificationService::NoDetails()); | 1380 NotificationService::NoDetails()); |
1368 | 1381 |
1369 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1382 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
1370 deleting_soon_ = true; | 1383 deleting_soon_ = true; |
1371 // It's important not to wait for the DeleteTask to delete the channel | 1384 // It's important not to wait for the DeleteTask to delete the channel |
1372 // proxy. Kill it off now. That way, in case the profile is going away, the | 1385 // proxy. Kill it off now. That way, in case the profile is going away, the |
1373 // rest of the objects attached to this RenderProcessHost start going | 1386 // rest of the objects attached to this RenderProcessHost start going |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1844 // Skip widgets in other processes. | 1857 // Skip widgets in other processes. |
1845 if (widget->GetProcess()->GetID() != GetID()) | 1858 if (widget->GetProcess()->GetID() != GetID()) |
1846 continue; | 1859 continue; |
1847 | 1860 |
1848 RenderViewHost* rvh = RenderViewHost::From(widget); | 1861 RenderViewHost* rvh = RenderViewHost::From(widget); |
1849 rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences()); | 1862 rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences()); |
1850 } | 1863 } |
1851 } | 1864 } |
1852 | 1865 |
1853 } // namespace content | 1866 } // namespace content |
OLD | NEW |