diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-18 18:09:36 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-18 18:09:36 +0000 |
commit | 59b49a66c3cd959fcf9d7b4bd9c6d88c70b39919 (patch) | |
tree | da55718682e3a4d7da3c6f3d70870eee0542d0b9 /chrome/browser/renderer_host | |
parent | d940627c90386df7844092dae635ed2f20535f28 (diff) | |
download | chromium_src-59b49a66c3cd959fcf9d7b4bd9c6d88c70b39919.zip chromium_src-59b49a66c3cd959fcf9d7b4bd9c6d88c70b39919.tar.gz chromium_src-59b49a66c3cd959fcf9d7b4bd9c6d88c70b39919.tar.bz2 |
Fix the ownership model of TabContents and NavigationController. Previously the
NavigationController owned the TabContents, and there were extra steps required
at creation and destruction to clean everything up properly.
NavigationController is now a member of TabContents, and there is no setup or
tear down necessary other than the constructor and destructor. I could remove
the tab contents creation in the NavigationController, as well as all the
weird destruction code in WebContents which got moved to the destructor.
I made the controller getter return a reference since the ownership is clear
and there is no possibility of NULL. This required changing a lot of tiles, but
many of them were simplified since they no longer have to NULL check.
Review URL: http://codereview.chromium.org/69043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14005 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
4 files changed, 7 insertions, 10 deletions
diff --git a/chrome/browser/renderer_host/render_view_host_unittest.cc b/chrome/browser/renderer_host/render_view_host_unittest.cc index 9e91318..b70293a 100644 --- a/chrome/browser/renderer_host/render_view_host_unittest.cc +++ b/chrome/browser/renderer_host/render_view_host_unittest.cc @@ -12,6 +12,6 @@ class RenderViewHostTest : public RenderViewHostTestHarness { // See RenderViewHost::OnMsgNavigate for a discussion. TEST_F(RenderViewHostTest, FilterAbout) { rvh()->SendNavigate(1, GURL("about:cache")); - ASSERT_TRUE(controller()->GetActiveEntry()); - EXPECT_EQ(GURL("about:blank"), controller()->GetActiveEntry()->url()); + ASSERT_TRUE(controller().GetActiveEntry()); + EXPECT_EQ(GURL("about:blank"), controller().GetActiveEntry()->url()); } diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index db852b4..5a211d4 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -1293,7 +1293,7 @@ class NotificationTask : public Task { // Issue the notification. NotificationService::current()->Notify( type_, - Source<NavigationController>(tab_contents->controller()), + Source<NavigationController>(&tab_contents->controller()), Details<ResourceRequestDetails>(details_.get())); } } diff --git a/chrome/browser/renderer_host/test_render_view_host.cc b/chrome/browser/renderer_host/test_render_view_host.cc index abc5699..4255393 100644 --- a/chrome/browser/renderer_host/test_render_view_host.cc +++ b/chrome/browser/renderer_host/test_render_view_host.cc @@ -70,7 +70,7 @@ BackingStore* TestRenderWidgetHostView::AllocBackingStore( } void RenderViewHostTestHarness::NavigateAndCommit(const GURL& url) { - controller()->LoadURL(url, GURL(), 0); + controller().LoadURL(url, GURL(), 0); rvh()->SendNavigate(process()->max_page_id() + 1, url); } @@ -87,11 +87,8 @@ void RenderViewHostTestHarness::SetUp() { } void RenderViewHostTestHarness::TearDown() { - if (contents_) { - contents_->CloseContents(); - contents_ = NULL; - } - controller_ = NULL; + if (contents_) + delete contents_; // Make sure that we flush any messages related to WebContents destruction // before we destroy the profile. diff --git a/chrome/browser/renderer_host/test_render_view_host.h b/chrome/browser/renderer_host/test_render_view_host.h index 63e6da6..cdcf325 100644 --- a/chrome/browser/renderer_host/test_render_view_host.h +++ b/chrome/browser/renderer_host/test_render_view_host.h @@ -184,7 +184,7 @@ class RenderViewHostTestHarness : public testing::Test { controller_(NULL) {} virtual ~RenderViewHostTestHarness() {} - NavigationController* controller() { + NavigationController& controller() { return contents_->controller(); } |