diff options
author | kaznacheev@chromium.org <kaznacheev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-01 14:19:58 +0000 |
---|---|---|
committer | kaznacheev@chromium.org <kaznacheev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-01 14:19:58 +0000 |
commit | 94305ee92331cd6bf4ad0dbceb7a1ee2cc87d54b (patch) | |
tree | 8e2be64ca0367faddbf3dd79a5ca1fc026669918 /chrome/browser/devtools | |
parent | 7b7b2ef63c9dd5825a2174a7caebcd283d968604 (diff) | |
download | chromium_src-94305ee92331cd6bf4ad0dbceb7a1ee2cc87d54b.zip chromium_src-94305ee92331cd6bf4ad0dbceb7a1ee2cc87d54b.tar.gz chromium_src-94305ee92331cd6bf4ad0dbceb7a1ee2cc87d54b.tar.bz2 |
Remove redundant DevToolsManager methods and clean up its clients.
BUG=None
TBR=jam
Review URL: https://chromiumcodereview.appspot.com/13305002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191609 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/devtools')
-rw-r--r-- | chrome/browser/devtools/devtools_adb_bridge.cc | 6 | ||||
-rw-r--r-- | chrome/browser/devtools/devtools_sanity_browsertest.cc | 8 | ||||
-rw-r--r-- | chrome/browser/devtools/devtools_window.cc | 43 | ||||
-rw-r--r-- | chrome/browser/devtools/devtools_window.h | 3 |
4 files changed, 22 insertions, 38 deletions
diff --git a/chrome/browser/devtools/devtools_adb_bridge.cc b/chrome/browser/devtools/devtools_adb_bridge.cc index eddf865..1aa2548 100644 --- a/chrome/browser/devtools/devtools_adb_bridge.cc +++ b/chrome/browser/devtools/devtools_adb_bridge.cc @@ -329,11 +329,7 @@ class AgentHostDelegate : public base::RefCountedThreadSafe<AgentHostDelegate>, if (!value || !value->GetAsDictionary(&dvalue)) return; - content::DevToolsManager* manager = content::DevToolsManager::GetInstance(); - content::DevToolsClientHost* client_host = - manager->GetDevToolsClientHostFor(proxy_->GetAgentHost()); - if (client_host) - client_host->DispatchOnInspectorFrontend(message); + proxy_->DispatchOnClientHost(message); } void OnSocketClosed(int result) { diff --git a/chrome/browser/devtools/devtools_sanity_browsertest.cc b/chrome/browser/devtools/devtools_sanity_browsertest.cc index f21f828..53a8318 100644 --- a/chrome/browser/devtools/devtools_sanity_browsertest.cc +++ b/chrome/browser/devtools/devtools_sanity_browsertest.cc @@ -152,13 +152,9 @@ class DevToolsSanityTest : public InProcessBrowserTest { void CloseDevToolsWindow() { DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); - // UnregisterDevToolsClientHostFor may destroy window_ so store the browser - // first. + // CloseAllClientHosts may destroy window_ so store the browser first. Browser* browser = window_->browser(); - scoped_refptr<DevToolsAgentHost> agent( - DevToolsAgentHost::GetOrCreateFor(inspected_rvh_)); - devtools_manager->UnregisterDevToolsClientHostFor(agent); - + devtools_manager->CloseAllClientHosts(); // Wait only when DevToolsWindow has a browser. For docked DevTools, this // is NULL and we skip the wait. if (browser) diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc index 692c833..46d30cd 100644 --- a/chrome/browser/devtools/devtools_window.cc +++ b/chrome/browser/devtools/devtools_window.cc @@ -140,9 +140,7 @@ DevToolsWindow* DevToolsWindow::GetDockedInstanceForInspectedTab( return NULL; scoped_refptr<DevToolsAgentHost> agent(DevToolsAgentHost::GetOrCreateFor( inspected_web_contents->GetRenderViewHost())); - DevToolsManager* manager = DevToolsManager::GetInstance(); - DevToolsClientHost* client_host = manager->GetDevToolsClientHostFor(agent); - DevToolsWindow* window = AsDevToolsWindow(client_host); + DevToolsWindow* window = FindDevToolsWindow(agent); return window && window->IsDocked() ? window : NULL; } @@ -155,15 +153,10 @@ bool DevToolsWindow::IsDevToolsWindow(RenderViewHost* window_rvh) { DevToolsWindow* DevToolsWindow::OpenDevToolsWindowForWorker( Profile* profile, DevToolsAgentHost* worker_agent) { - DevToolsWindow* window; - DevToolsClientHost* client = content::DevToolsManager::GetInstance()-> - GetDevToolsClientHostFor(worker_agent); - if (client) { - window = AsDevToolsWindow(client); - if (!window) - return NULL; - } else { + DevToolsWindow* window = FindDevToolsWindow(worker_agent); + if (!window) { window = DevToolsWindow::CreateDevToolsWindowForWorker(profile); + // Will disconnect the current client host if there is one. DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( worker_agent, window->frontend_host_.get()); @@ -293,6 +286,10 @@ content::WebContents* DevToolsWindow::GetInspectedWebContents() { } void DevToolsWindow::InspectedContentsClosing() { + Hide(); +} + +void DevToolsWindow::Hide() { if (IsDocked()) { // Update dev tools to reflect removed dev tools window. BrowserWindow* inspected_window = GetInspectedBrowserWindow(); @@ -714,20 +711,14 @@ DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( scoped_refptr<DevToolsAgentHost> agent( DevToolsAgentHost::GetOrCreateFor(inspected_rvh)); DevToolsManager* manager = DevToolsManager::GetInstance(); - DevToolsClientHost* host = manager->GetDevToolsClientHostFor(agent); - DevToolsWindow* window = AsDevToolsWindow(host); - if (host && !window) { - // Break remote debugging / extension debugging session. - host->ReplacedWithAnotherClient(); - manager->UnregisterDevToolsClientHostFor(agent); - } - + DevToolsWindow* window = FindDevToolsWindow(agent); bool do_open = force_open; if (!window) { Profile* profile = Profile::FromBrowserContext( inspected_rvh->GetProcess()->GetBrowserContext()); DevToolsDockSide dock_side = GetDockSideFromPrefs(profile); window = Create(profile, inspected_rvh, dock_side, false); + // Will disconnect the current client host if there is one. manager->RegisterDevToolsClientHostFor(agent, window->frontend_host_.get()); do_open = true; } @@ -740,20 +731,20 @@ DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( if (!window->IsDocked() || do_open) window->Show(action); else - manager->UnregisterDevToolsClientHostFor(agent); + window->CloseWindow(); return window; } // static -DevToolsWindow* DevToolsWindow::AsDevToolsWindow( - DevToolsClientHost* client_host) { - if (!client_host || g_instances == NULL) - return NULL; +DevToolsWindow* DevToolsWindow::FindDevToolsWindow( + DevToolsAgentHost* agent_host) { + DevToolsManager* manager = DevToolsManager::GetInstance(); DevToolsWindowList& instances = g_instances.Get(); for (DevToolsWindowList::iterator it = instances.begin(); it != instances.end(); ++it) { - if ((*it)->frontend_host_.get() == client_host) + if (manager->GetDevToolsAgentHostFor((*it)->frontend_host_.get()) == + agent_host) return *it; } return NULL; @@ -798,7 +789,7 @@ void DevToolsWindow::ChangeAttachedWindowHeight(unsigned height) { void DevToolsWindow::CloseWindow() { DCHECK(IsDocked()); DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_.get()); - InspectedContentsClosing(); + Hide(); } void DevToolsWindow::MoveWindow(int x, int y) { diff --git a/chrome/browser/devtools/devtools_window.h b/chrome/browser/devtools/devtools_window.h index a15ef66..ed035bd 100644 --- a/chrome/browser/devtools/devtools_window.h +++ b/chrome/browser/devtools/devtools_window.h @@ -130,6 +130,7 @@ class DevToolsWindow : private content::NotificationObserver, BrowserWindow* GetInspectedBrowserWindow(); bool IsInspectedBrowserPopupOrPanel(); void UpdateFrontendDockSide(); + void Hide(); // Overridden from content::NotificationObserver. virtual void Observe(int type, @@ -171,7 +172,7 @@ class DevToolsWindow : private content::NotificationObserver, const content::FileChooserParams& params) OVERRIDE; virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; - static DevToolsWindow* AsDevToolsWindow(content::DevToolsClientHost*); + static DevToolsWindow* FindDevToolsWindow(content::DevToolsAgentHost*); static DevToolsWindow* AsDevToolsWindow(content::RenderViewHost*); // content::DevToolsFrontendHostDelegate overrides. |