diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-12 18:36:03 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-12 18:36:03 +0000 |
commit | f3abf10c215c3d281ee52a18a97a004a6d6c6dfd (patch) | |
tree | 03781eb460ac881b84b68eea0819b14a1543dde7 /content | |
parent | 333b1de96adffbde36931f68a0ee9f099d9dd8f3 (diff) | |
download | chromium_src-f3abf10c215c3d281ee52a18a97a004a6d6c6dfd.zip chromium_src-f3abf10c215c3d281ee52a18a97a004a6d6c6dfd.tar.gz chromium_src-f3abf10c215c3d281ee52a18a97a004a6d6c6dfd.tar.bz2 |
Reset RPH's channel.
This is important for shutdown ordering to make sure the objects hanging off the channel get deleted before objects they reference (like data in ResourceContext) go away.
BUG=91398
TEST=none
Review URL: http://codereview.chromium.org/7796029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100730 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
3 files changed, 14 insertions, 10 deletions
diff --git a/content/browser/renderer_host/render_process_host.cc b/content/browser/renderer_host/render_process_host.cc index e34a600..ec097de 100644 --- a/content/browser/renderer_host/render_process_host.cc +++ b/content/browser/renderer_host/render_process_host.cc @@ -114,6 +114,10 @@ RenderProcessHost::~RenderProcessHost() { all_hosts.Remove(id()); } +bool RenderProcessHost::HasConnection() const { + return channel_.get() != NULL; +} + void RenderProcessHost::Attach(IPC::Channel::Listener* listener, int routing_id) { VLOG_IF(1, g_log_bug53991) << "AddListener: (" << this << "): " << routing_id; @@ -136,6 +140,12 @@ void RenderProcessHost::Release(int listener_id) { Source<RenderProcessHost>(this), NotificationService::NoDetails()); MessageLoop::current()->DeleteSoon(FROM_HERE, this); deleting_soon_ = true; + // It's important not to wait for the DeleteTask to delete the channel + // proxy. Kill it off now. That way, in case the profile is going away, the + // rest of the objects attached to this RenderProcessHost start going + // away first, since deleting the channel proxy will post a + // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. + channel_.reset(); // Remove ourself from the list of renderer processes so that we can't be // reused in between now and when the Delete task runs. diff --git a/content/browser/renderer_host/render_process_host.h b/content/browser/renderer_host/render_process_host.h index 569d55c..2262024 100644 --- a/content/browser/renderer_host/render_process_host.h +++ b/content/browser/renderer_host/render_process_host.h @@ -82,8 +82,8 @@ class RenderProcessHost : public IPC::Channel::Sender, int id() const { return id_; } // Returns true iff channel_ has been set to non-NULL. Use this for checking - // if there is connection or not. - bool HasConnection() { return channel_.get() != NULL; } + // if there is connection or not. Virtual for mocking out for tests. + virtual bool HasConnection() const; bool sudden_termination_allowed() const { return sudden_termination_allowed_; diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc index b2e65346..6b9397c 100644 --- a/content/browser/renderer_host/render_widget_host_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_unittest.cc @@ -37,16 +37,8 @@ class RenderWidgetHostProcess : public MockRenderProcessHost { current_update_buf_(NULL), update_msg_should_reply_(false), update_msg_reply_flags_(0) { - // DANGER! This is a hack. The RenderWidgetHost checks the channel to see - // if the process is still alive, but it doesn't actually dereference it. - // An IPC::ChannelProxy is nontrivial, so we just fake it here. If you end up - // crashing by dereferencing 1, then you'll have to make a real channel. - channel_.reset(reinterpret_cast<IPC::ChannelProxy*>(0x1)); } ~RenderWidgetHostProcess() { - // We don't want to actually delete the channel, since it's not a real - // pointer. - ignore_result(channel_.release()); delete current_update_buf_; } @@ -60,6 +52,8 @@ class RenderWidgetHostProcess : public MockRenderProcessHost { // Fills the given update parameters with resonable default values. void InitUpdateRectParams(ViewHostMsg_UpdateRect_Params* params); + virtual bool HasConnection() const { return true; } + protected: virtual bool WaitForUpdateMsg(int render_widget_id, const base::TimeDelta& max_delay, |