diff options
author | apavlov@chromium.org <apavlov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 14:49:42 +0000 |
---|---|---|
committer | apavlov@chromium.org <apavlov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 14:49:42 +0000 |
commit | e44cdf31522aff26c27759b1a06ae6eef8b97257 (patch) | |
tree | cae278fccda2bec154ff08c9fd5d66eae943de90 /chrome | |
parent | 3e44697f8e0749d2acd1d3ee1431a27df2c94e74 (diff) | |
download | chromium_src-e44cdf31522aff26c27759b1a06ae6eef8b97257.zip chromium_src-e44cdf31522aff26c27759b1a06ae6eef8b97257.tar.gz chromium_src-e44cdf31522aff26c27759b1a06ae6eef8b97257.tar.bz2 |
Fix remote debugger detachment sequence according to the latest DevTools changes
Review URL: http://codereview.chromium.org/113765
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16740 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/debugger/debugger_remote_service.cc | 40 | ||||
-rw-r--r-- | chrome/browser/debugger/inspectable_tab_proxy.cc | 17 | ||||
-rw-r--r-- | chrome/browser/debugger/inspectable_tab_proxy.h | 5 |
3 files changed, 34 insertions, 28 deletions
diff --git a/chrome/browser/debugger/debugger_remote_service.cc b/chrome/browser/debugger/debugger_remote_service.cc index 7fffe4b..47f503e3 100644 --- a/chrome/browser/debugger/debugger_remote_service.cc +++ b/chrome/browser/debugger/debugger_remote_service.cc @@ -211,7 +211,7 @@ void DebuggerRemoteService::AttachToTab(const std::string& destination, return; } if (tab_uid == 0) { // single tab_uid - // We've been asked to open a new tab with URL. + // We've been asked to open a new tab with URL // TODO(apavlov): implement NOTIMPLEMENTED(); response->SetInteger(kResultWide, RESULT_UNKNOWN_TAB); @@ -224,20 +224,20 @@ void DebuggerRemoteService::AttachToTab(const std::string& destination, return; } RenderViewHost* target_host = tab_contents->render_view_host(); - if (g_browser_process->devtools_manager()->GetDevToolsClientHostFor( - target_host) == NULL) { - DevToolsClientHost* client_host = + DevToolsClientHost* client_host = + delegate_->inspectable_tab_proxy()->ClientHostForTabId(tab_uid); + if (client_host == NULL) { + client_host = delegate_->inspectable_tab_proxy()->NewClientHost(tab_uid, this); DevToolsManager* manager = g_browser_process->devtools_manager(); if (manager != NULL) { manager->RegisterDevToolsClientHostFor(target_host, client_host); - manager->ForwardToDevToolsAgent(client_host, DevToolsAgentMsg_Attach()); response->SetInteger(kResultWide, RESULT_OK); } else { response->SetInteger(kResultWide, RESULT_DEBUGGER_ERROR); } } else { - // DevToolsClientHost for this tab already registered + // DevToolsClientHost for this tab is already registered response->SetInteger(kResultWide, RESULT_ILLEGAL_TAB_STATE); } } @@ -257,28 +257,14 @@ void DebuggerRemoteService::DetachFromTab(const std::string& destination, return; } int result_code; - TabContents* tab_contents = ToTabContents(tab_uid); - if (tab_contents == NULL) { - // Unknown tab - result_code = RESULT_UNKNOWN_TAB; + DevToolsClientHostImpl* client_host = + delegate_->inspectable_tab_proxy()->ClientHostForTabId(tab_uid); + if (client_host != NULL) { + client_host->Close(); + result_code = RESULT_OK; } else { - DevToolsManager* manager = g_browser_process->devtools_manager(); - if (manager != NULL) { - DevToolsClientHost* client_host = - manager->GetDevToolsClientHostFor(tab_contents->render_view_host()); - if (client_host != NULL) { - manager->ForwardToDevToolsAgent( - client_host, DevToolsAgentMsg_Detach()); - client_host->InspectedTabClosing(); - result_code = RESULT_OK; - } else { - // No client host registered - result_code = RESULT_UNKNOWN_TAB; - } - } else { - // No DevToolsManager - result_code = RESULT_DEBUGGER_ERROR; - } + // No client host registered for |tab_uid|. + result_code = RESULT_UNKNOWN_TAB; } if (response != NULL) { response->SetInteger(kResultWide, result_code); diff --git a/chrome/browser/debugger/inspectable_tab_proxy.cc b/chrome/browser/debugger/inspectable_tab_proxy.cc index 097b817..0479716 100644 --- a/chrome/browser/debugger/inspectable_tab_proxy.cc +++ b/chrome/browser/debugger/inspectable_tab_proxy.cc @@ -16,9 +16,14 @@ #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/devtools_messages.h" +// The debugged tab has closed. void DevToolsClientHostImpl::InspectedTabClosing() { - static const std::string kEmptyUrl = ""; TabClosed(); + delete this; +} + +// The remote debugger has detached. +void DevToolsClientHostImpl::Close() { NotifyCloseListener(); delete this; } @@ -86,6 +91,16 @@ const InspectableTabProxy::ControllersMap& return controllers_map_; } +DevToolsClientHostImpl* InspectableTabProxy::ClientHostForTabId( + int32 id) { + InspectableTabProxy::IdToClientHostMap::const_iterator it = + id_to_client_host_map_.find(id); + if (it == id_to_client_host_map_.end()) { + return NULL; + } + return it->second; +} + DevToolsClientHost* InspectableTabProxy::NewClientHost( int32 id, DebuggerRemoteService* service) { diff --git a/chrome/browser/debugger/inspectable_tab_proxy.h b/chrome/browser/debugger/inspectable_tab_proxy.h index 104b957..88913d7 100644 --- a/chrome/browser/debugger/inspectable_tab_proxy.h +++ b/chrome/browser/debugger/inspectable_tab_proxy.h @@ -33,6 +33,9 @@ class InspectableTabProxy { // the map. const ControllersMap& controllers_map(); + // Returns a DevToolsClientHostImpl for the given tab |id|. + DevToolsClientHostImpl* ClientHostForTabId(int32 id); + // Creates a new DevToolsClientHost implementor instance. // |id| is the UID of the tab to debug. // |service| is the DebuggerRemoteService instance the DevToolsClient @@ -70,6 +73,8 @@ class DevToolsClientHostImpl : public DevToolsClientHost { return service_; } + void Close(); + // DevToolsClientHost interface virtual void InspectedTabClosing(); virtual void SendMessageToClient(const IPC::Message& msg); |