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/debugger | |
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/debugger')
-rw-r--r-- | chrome/browser/debugger/debugger_host_impl.cpp | 2 | ||||
-rw-r--r-- | chrome/browser/debugger/debugger_node.cc | 4 | ||||
-rw-r--r-- | chrome/browser/debugger/debugger_view.cc | 7 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_manager.cc | 20 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_manager.h | 2 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_view.cc | 7 | ||||
-rw-r--r-- | chrome/browser/debugger/inspectable_tab_proxy.cc | 4 |
7 files changed, 20 insertions, 26 deletions
diff --git a/chrome/browser/debugger/debugger_host_impl.cpp b/chrome/browser/debugger/debugger_host_impl.cpp index e22a391..1f98f4b8 100644 --- a/chrome/browser/debugger/debugger_host_impl.cpp +++ b/chrome/browser/debugger/debugger_host_impl.cpp @@ -16,7 +16,7 @@ class TabContentsReference : public NotificationObserver { public: TabContentsReference(TabContents *c) : navigation_controller_(NULL) { - navigation_controller_ = c->controller(); + navigation_controller_ = &c->controller(); NotificationService* service = NotificationService::current(); DCHECK(service); diff --git a/chrome/browser/debugger/debugger_node.cc b/chrome/browser/debugger/debugger_node.cc index c22bd7f..0beedce 100644 --- a/chrome/browser/debugger/debugger_node.cc +++ b/chrome/browser/debugger/debugger_node.cc @@ -291,12 +291,12 @@ v8::Handle<v8::Value> TabListNode::IndexGetter(uint32_t index, ///////////////////////////////////////////// TabNode::TabNode(TabContents *c) { - data_ = c->controller(); + data_ = &c->controller(); NotificationService* service = NotificationService::current(); DCHECK(service); service->AddObserver(this, NotificationType::TAB_CLOSING, - Source<NavigationController>(c->controller())); + Source<NavigationController>(&c->controller())); observing_ = true; } diff --git a/chrome/browser/debugger/debugger_view.cc b/chrome/browser/debugger/debugger_view.cc index 3a72171..0c9f6f8 100644 --- a/chrome/browser/debugger/debugger_view.cc +++ b/chrome/browser/debugger/debugger_view.cc @@ -99,14 +99,13 @@ void DebuggerView::OnInit() { Profile* profile = BrowserList::GetLastActive()->profile(); web_contents_ = new WebContents(profile, NULL, MSG_ROUTING_NONE, NULL); - web_contents_->SetupController(profile); web_contents_->set_delegate(this); web_container_->SetTabContents(web_contents_); web_contents_->render_view_host()->AllowDOMUIBindings(); GURL contents("chrome-ui://inspector/debugger.html"); - web_contents_->controller()->LoadURL(contents, GURL(), - PageTransition::START_PAGE); + web_contents_->controller().LoadURL(contents, GURL(), + PageTransition::START_PAGE); } void DebuggerView::OnShow() { @@ -115,7 +114,7 @@ void DebuggerView::OnShow() { void DebuggerView::OnClose() { web_container_->SetTabContents(NULL); - web_contents_->CloseContents(); + delete web_contents_; } void DebuggerView::OpenURLFromTab(TabContents* source, diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc index f048689..6afa7a3 100644 --- a/chrome/browser/debugger/devtools_manager.cc +++ b/chrome/browser/debugger/devtools_manager.cc @@ -35,22 +35,18 @@ void DevToolsManager::Observe(NotificationType type, return; } - NavigationController* controller = src->controller(); - bool active = (controller->tab_contents() == src.ptr()); - if (active) { - // Active tab contents disconnecting from its renderer means that the tab - // is closing. - client_host->InspectedTabClosing(); - UnregisterDevToolsClientHost(client_host, controller); - } + // Active tab contents disconnecting from its renderer means that the tab + // is closing. + client_host->InspectedTabClosing(); + UnregisterDevToolsClientHost(client_host, &src->controller()); } } DevToolsClientHost* DevToolsManager::GetDevToolsClientHostFor( const WebContents& web_contents) { - NavigationController* navigation_controller = web_contents.controller(); + const NavigationController& navigation_controller = web_contents.controller(); ClientHostMap::const_iterator it = - navcontroller_to_client_host_.find(navigation_controller); + navcontroller_to_client_host_.find(&navigation_controller); if (it != navcontroller_to_client_host_.end()) { return it->second; } @@ -58,11 +54,11 @@ DevToolsClientHost* DevToolsManager::GetDevToolsClientHostFor( } void DevToolsManager::RegisterDevToolsClientHostFor( - const WebContents& web_contents, + WebContents& web_contents, DevToolsClientHost* client_host) { DCHECK(!GetDevToolsClientHostFor(web_contents)); - NavigationController* navigation_controller = web_contents.controller(); + NavigationController* navigation_controller = &web_contents.controller(); navcontroller_to_client_host_[navigation_controller] = client_host; client_host_to_navcontroller_[client_host] = navigation_controller; client_host->set_close_listener(this); diff --git a/chrome/browser/debugger/devtools_manager.h b/chrome/browser/debugger/devtools_manager.h index fe6fc4f..77ffaf5 100644 --- a/chrome/browser/debugger/devtools_manager.h +++ b/chrome/browser/debugger/devtools_manager.h @@ -36,7 +36,7 @@ class DevToolsManager : public NotificationObserver, // Registers new DevToolsClientHost for |web_contents|. There must be no // other DevToolsClientHosts registered for the WebContents at the moment. - void RegisterDevToolsClientHostFor(const WebContents& web_contents, + void RegisterDevToolsClientHostFor(WebContents& web_contents, DevToolsClientHost* client_host); void ForwardToDevToolsAgent(const RenderViewHost& client_rvh, diff --git a/chrome/browser/debugger/devtools_view.cc b/chrome/browser/debugger/devtools_view.cc index 483f87f..179eb7e 100644 --- a/chrome/browser/debugger/devtools_view.cc +++ b/chrome/browser/debugger/devtools_view.cc @@ -50,7 +50,6 @@ void DevToolsView::Init() { Profile* profile = BrowserList::GetLastActive()->profile(); web_contents_ = new WebContents(profile, NULL, MSG_ROUTING_NONE, NULL); - web_contents_->SetupController(profile); web_contents_->set_delegate(this); web_container_->SetTabContents(web_contents_); web_contents_->render_view_host()->AllowDOMUIBindings(); @@ -59,8 +58,8 @@ void DevToolsView::Init() { GURL contents(std::string(chrome::kChromeUIDevToolsURL) + "devtools.html"); // this will call CreateRenderView to create renderer process - web_contents_->controller()->LoadURL(contents, GURL(), - PageTransition::START_PAGE); + web_contents_->controller().LoadURL(contents, GURL(), + PageTransition::START_PAGE); } void DevToolsView::OnWindowClosing() { @@ -70,7 +69,7 @@ void DevToolsView::OnWindowClosing() { web_container_->SetTabContents(NULL); // Destroy the tab and navigation controller. - web_contents_->CloseContents(); + delete web_contents_; web_contents_ = NULL; } } diff --git a/chrome/browser/debugger/inspectable_tab_proxy.cc b/chrome/browser/debugger/inspectable_tab_proxy.cc index e141bca..a329d6a 100644 --- a/chrome/browser/debugger/inspectable_tab_proxy.cc +++ b/chrome/browser/debugger/inspectable_tab_proxy.cc @@ -86,9 +86,9 @@ const InspectableTabProxy::ControllersMap& end = BrowserList::end(); it != end; ++it) { TabStripModel* model = (*it)->tabstrip_model(); for (int i = 0, size = model->count(); i < size; ++i) { - NavigationController* controller = + NavigationController& controller = model->GetTabContentsAt(i)->controller(); - controllers_map_[controller->session_id().id()] = controller; + controllers_map_[controller.session_id().id()] = &controller; } } } |