diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-27 07:53:57 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-27 07:53:57 +0000 |
commit | ee75b899c35b74a40603b4699c31eecf7f391c62 (patch) | |
tree | 3a86730fb749574f80cd0f041368781d379f4285 /content/browser/debugger | |
parent | f7831bddd10b07de8f6ffba5be384ed8f61bed93 (diff) | |
download | chromium_src-ee75b899c35b74a40603b4699c31eecf7f391c62.zip chromium_src-ee75b899c35b74a40603b4699c31eecf7f391c62.tar.gz chromium_src-ee75b899c35b74a40603b4699c31eecf7f391c62.tar.bz2 |
DevTools: add remote debugging capabilities to content_shell.
BUG=97465
TEST=
Review URL: https://chromiumcodereview.appspot.com/9288023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119408 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/debugger')
-rw-r--r-- | content/browser/debugger/devtools_http_handler_impl.cc | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/content/browser/debugger/devtools_http_handler_impl.cc b/content/browser/debugger/devtools_http_handler_impl.cc index 349bacc..3016b87c 100644 --- a/content/browser/debugger/devtools_http_handler_impl.cc +++ b/content/browser/debugger/devtools_http_handler_impl.cc @@ -17,6 +17,7 @@ #include "base/threading/thread.h" #include "base/utf_string_conversions.h" #include "base/values.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/common/devtools_messages.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/devtools_agent_host_registry.h" @@ -25,7 +26,6 @@ #include "content/public/browser/devtools_manager.h" #include "content/public/browser/favicon_status.h" #include "content/public/browser/navigation_entry.h" -#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/common/content_client.h" #include "googleurl/src/gurl.h" @@ -82,52 +82,52 @@ class DevToolsClientHostImpl : public DevToolsClientHost { static int next_id = 1; -class WebContentsIDHelper : public content::WebContentsObserver { +class TabContentsIDHelper : public content::WebContentsObserver { public: - static int GetID(WebContents* contents) { - WebContentsToIdMap::iterator it = web_contents_to_id_.Get().find(contents); - if (it != web_contents_to_id_.Get().end()) + static int GetID(TabContents* contents) { + TabContentsToIdMap::iterator it = tab_contents_to_id_.Get().find(contents); + if (it != tab_contents_to_id_.Get().end()) return it->second; - WebContentsIDHelper* wrapper = new WebContentsIDHelper(contents); + TabContentsIDHelper* wrapper = new TabContentsIDHelper(contents); return wrapper->id_; } - static WebContents* GetWebContents(int id) { - IdToWebContentsMap::iterator it = id_to_web_contents_.Get().find(id); - if (it != id_to_web_contents_.Get().end()) + static TabContents* GetTabContents(int id) { + IdToTabContentsMap::iterator it = id_to_tab_contents_.Get().find(id); + if (it != id_to_tab_contents_.Get().end()) return it->second; return NULL; } private: - explicit WebContentsIDHelper(WebContents* tab) + explicit TabContentsIDHelper(TabContents* tab) : content::WebContentsObserver(tab), id_(next_id++) { - id_to_web_contents_.Get()[id_] = tab; - web_contents_to_id_.Get()[tab] = id_; + id_to_tab_contents_.Get()[id_] = tab; + tab_contents_to_id_.Get()[tab] = id_; } - virtual ~WebContentsIDHelper() {} + virtual ~TabContentsIDHelper() {} virtual void WebContentsDestroyed(WebContents* contents) OVERRIDE { - id_to_web_contents_.Get().erase(id_); - web_contents_to_id_.Get().erase(contents); + id_to_tab_contents_.Get().erase(id_); + tab_contents_to_id_.Get().erase((static_cast<TabContents*>(contents))); delete this; } int id_; - typedef std::map<int, WebContents*> IdToWebContentsMap; - static base::LazyInstance<IdToWebContentsMap>::Leaky - id_to_web_contents_; - typedef std::map<WebContents*, int> WebContentsToIdMap; - static base::LazyInstance<WebContentsToIdMap>::Leaky - web_contents_to_id_; + typedef std::map<int, TabContents*> IdToTabContentsMap; + static base::LazyInstance<IdToTabContentsMap>::Leaky + id_to_tab_contents_; + typedef std::map<TabContents*, int> TabContentsToIdMap; + static base::LazyInstance<TabContentsToIdMap>::Leaky + tab_contents_to_id_; }; -base::LazyInstance<WebContentsIDHelper::IdToWebContentsMap>::Leaky - WebContentsIDHelper::id_to_web_contents_ = LAZY_INSTANCE_INITIALIZER; -base::LazyInstance<WebContentsIDHelper::WebContentsToIdMap>::Leaky - WebContentsIDHelper::web_contents_to_id_ = LAZY_INSTANCE_INITIALIZER; +base::LazyInstance<TabContentsIDHelper::IdToTabContentsMap>::Leaky + TabContentsIDHelper::id_to_tab_contents_ = LAZY_INSTANCE_INITIALIZER; +base::LazyInstance<TabContentsIDHelper::TabContentsToIdMap>::Leaky + TabContentsIDHelper::tab_contents_to_id_ = LAZY_INSTANCE_INITIALIZER; } // namespace @@ -341,7 +341,8 @@ static PageList GeneratePageList( DevToolsClientHost* client_host = DevToolsManager::GetInstance()-> GetDevToolsClientHostFor(agent); PageInfo page_info; - page_info.id = WebContentsIDHelper::GetID(web_contents); + page_info.id = TabContentsIDHelper::GetID( + static_cast<TabContents*>(web_contents)); page_info.attached = client_host != NULL; page_info.url = entry->GetURL().spec(); page_info.title = UTF16ToUTF8(net::EscapeForHTML(entry->GetTitle())); @@ -406,7 +407,7 @@ void DevToolsHttpHandlerImpl::OnWebSocketRequestUI( return; } - WebContents* web_contents = WebContentsIDHelper::GetWebContents(id); + TabContents* web_contents = TabContentsIDHelper::GetTabContents(id); if (web_contents == NULL) { Send500(connection_id, "No such page id: " + page_id); return; |