From 03c47326b78cb675b084efa829f350e45d5272d9 Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Mon, 29 Jun 2009 17:25:27 +0000 Subject: Let RenderProcessHost provide a method HasConnection() instead of exposing channel(). Motivation: Currently, components that are using RenderProcessHost are checking its liveness by null testing on channel(). I'd like to write unittests for those components, but to mock out RenderProcessHost instances, I have to also mock out the instance returned by RenderProcessHost::channel(), but there's no interface class prepared. SyncChannel is directly used in RenderProcessHost. Instead of dependency injection, I can let mock objects return invalid pointer such as 0x1, but its bad test design. Rather than that, I'd like to introduce HasConnection() method and override it to return true. In fact, most of those components are not accessing channel()'s methods directry. They're just checking channel() is null or not, and to issue IPCs, they are calling Send method. So, it's OK to hide channel pointer from users, I think. Original review: http://codereview.chromium.org/147077 Patch by tyoshino@google.com git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19493 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/tab_contents/render_view_host_delegate_helper.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'chrome/browser/tab_contents/render_view_host_delegate_helper.cc') diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc index b8c4c0e..9a7a7c00 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc @@ -62,7 +62,7 @@ TabContents* RenderViewHostDelegateViewHelper::GetCreatedWindow(int route_id) { pending_contents_.erase(route_id); if (!new_tab_contents->render_view_host()->view() || - !new_tab_contents->process()->channel()) { + !new_tab_contents->process()->HasConnection()) { // The view has gone away or the renderer crashed. Nothing to do. return NULL; } @@ -85,7 +85,7 @@ RenderWidgetHostView* RenderViewHostDelegateViewHelper::GetCreatedWidget( pending_widget_views_.erase(route_id); RenderWidgetHost* widget_host = widget_host_view->GetRenderWidgetHost(); - if (!widget_host->process()->channel()) { + if (!widget_host->process()->HasConnection()) { // The view has gone away or the renderer crashed. Nothing to do. return NULL; } -- cgit v1.1