diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-26 13:10:41 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-26 13:10:41 +0000 |
commit | 4cc1c1f9a9d19b5988dc01ac4e6fc693b0e03ec1 (patch) | |
tree | 42c1c1fc46e44813c71c7611e1acac1b524b1090 /content/browser/debugger | |
parent | 9b59a69ff861f502b0cb17e0f2f990f068677ce5 (diff) | |
download | chromium_src-4cc1c1f9a9d19b5988dc01ac4e6fc693b0e03ec1.zip chromium_src-4cc1c1f9a9d19b5988dc01ac4e6fc693b0e03ec1.tar.gz chromium_src-4cc1c1f9a9d19b5988dc01ac4e6fc693b0e03ec1.tar.bz2 |
This reverts r119230 that broke few builders.
TBR=yurys
Review URL: https://chromiumcodereview.appspot.com/9234061
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119231 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/debugger')
-rw-r--r-- | content/browser/debugger/DEPS | 4 | ||||
-rw-r--r-- | content/browser/debugger/devtools_http_handler_impl.cc | 129 | ||||
-rw-r--r-- | content/browser/debugger/devtools_http_handler_impl.h | 2 | ||||
-rw-r--r-- | content/browser/debugger/devtools_netlog_observer.cc | 13 | ||||
-rw-r--r-- | content/browser/debugger/devtools_resources.gyp | 47 |
5 files changed, 51 insertions, 144 deletions
diff --git a/content/browser/debugger/DEPS b/content/browser/debugger/DEPS deleted file mode 100644 index 3e98aee..0000000 --- a/content/browser/debugger/DEPS +++ /dev/null @@ -1,4 +0,0 @@ -include_rules = [ - # Generated by the local devtools_resources.gyp:devtools_resources - "+grit/devtools_resources_map.h", -] diff --git a/content/browser/debugger/devtools_http_handler_impl.cc b/content/browser/debugger/devtools_http_handler_impl.cc index 4300ffe..6d0bc99 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,11 +26,8 @@ #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" -#include "grit/devtools_resources_map.h" #include "net/base/escape.h" #include "net/base/io_buffer.h" #include "net/server/http_server_request_info.h" @@ -82,52 +80,53 @@ 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* tab) { + TabContentsToIdMap::iterator it = tabcontents_to_id_.Get().find(tab); + if (it != tabcontents_to_id_.Get().end()) return it->second; - WebContentsIDHelper* wrapper = new WebContentsIDHelper(contents); + TabContentsIDHelper* wrapper = new TabContentsIDHelper(tab); 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_tabcontents_.Get().find(id); + if (it != id_to_tabcontents_.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_tabcontents_.Get()[id_] = tab; + tabcontents_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); + virtual void WebContentsDestroyed(WebContents* tab) OVERRIDE { + id_to_tabcontents_.Get().erase(id_); + tabcontents_to_id_.Get().erase(static_cast<TabContents*>(tab)); 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_tabcontents_; + typedef std::map<TabContents*, int> TabContentsToIdMap; + static base::LazyInstance<TabContentsToIdMap>::Leaky + tabcontents_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_tabcontents_ = LAZY_INSTANCE_INITIALIZER; +base::LazyInstance<TabContentsIDHelper::TabContentsToIdMap>::Leaky + TabContentsIDHelper::tabcontents_to_id_ = LAZY_INSTANCE_INITIALIZER; } // namespace @@ -160,33 +159,10 @@ void DevToolsHttpHandlerImpl::Stop() { base::Bind(&DevToolsHttpHandlerImpl::TeardownAndRelease, this)); } -static std::string PathWithoutParams(const std::string& path) { - size_t query_position = path.find("?"); - if (query_position != std::string::npos) - return path.substr(0, query_position); - return path; -} - -static std::string GetMimeType(const std::string& filename) { - if (EndsWith(filename, ".html", false)) { - return "text/html"; - } else if (EndsWith(filename, ".css", false)) { - return "text/css"; - } else if (EndsWith(filename, ".js", false)) { - return "application/javascript"; - } else if (EndsWith(filename, ".png", false)) { - return "image/png"; - } else if (EndsWith(filename, ".gif", false)) { - return "image/gif"; - } - NOTREACHED(); - return "text/plain"; -} - void DevToolsHttpHandlerImpl::OnHttpRequest( int connection_id, const net::HttpServerRequestInfo& info) { - if (info.path.find("/json") == 0) { + if (info.path == "/json") { // Pages discovery json request. BrowserThread::PostTask( BrowserThread::UI, @@ -198,12 +174,6 @@ void DevToolsHttpHandlerImpl::OnHttpRequest( return; } - if (info.path == "" || info.path == "/") { - std::string response = delegate_->GetDiscoveryPageHTML(); - server_->Send200(connection_id, response, "text/html; charset=UTF-8"); - return; - } - // Proxy static files from chrome-devtools://devtools/*. net::URLRequestContext* request_context = delegate_->GetURLRequestContext(); if (!request_context) { @@ -211,29 +181,16 @@ void DevToolsHttpHandlerImpl::OnHttpRequest( return; } + if (info.path == "" || info.path == "/") { + std::string response = delegate_->GetDiscoveryPageHTML(); + server_->Send200(connection_id, response, "text/html; charset=UTF-8"); + return; + } + net::URLRequest* request; if (info.path.find("/devtools/") == 0) { - // Serve front-end files from resource bundle. - std::string filename = PathWithoutParams(info.path.substr(10)); - - if (delegate_->BundlesFrontendResources()) { - for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { - if (filename == kDevtoolsResources[i].name) { - int resource_id = kDevtoolsResources[i].value; - base::StringPiece data = - content::GetContentClient()->GetDataResource(resource_id); - server_->Send200(connection_id, - data.as_string(), - GetMimeType(filename)); - return; - } - } - server_->Send404(connection_id); - return; - } - std::string base_url = delegate_->GetFrontendResourcesBaseURL(); - request = new net::URLRequest(GURL(base_url + filename), this); + request = new net::URLRequest(GURL("chrome-devtools:/" + info.path), this); } else if (info.path.find("/thumb/") == 0) { request = new net::URLRequest(GURL("chrome:/" + info.path), this); } else { @@ -336,7 +293,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())); @@ -401,15 +359,15 @@ void DevToolsHttpHandlerImpl::OnWebSocketRequestUI( return; } - WebContents* web_contents = WebContentsIDHelper::GetWebContents(id); - if (web_contents == NULL) { + TabContents* tab_contents = TabContentsIDHelper::GetTabContents(id); + if (tab_contents == NULL) { Send500(connection_id, "No such page id: " + page_id); return; } DevToolsManager* manager = DevToolsManager::GetInstance(); DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( - web_contents->GetRenderViewHost()); + tab_contents->GetRenderViewHost()); if (manager->GetDevToolsClientHostFor(agent)) { Send500(connection_id, "Page with given id is being inspected: " + page_id); return; @@ -509,15 +467,14 @@ void DevToolsHttpHandlerImpl::OnReadCompleted(net::URLRequest* request, DevToolsHttpHandlerImpl::DevToolsHttpHandlerImpl( const std::string& ip, int port, - const std::string& frontend_url, + const std::string& frontend_host, DevToolsHttpHandlerDelegate* delegate) : ip_(ip), port_(port), - overridden_frontend_url_(frontend_url), + overridden_frontend_url_(frontend_host), delegate_(delegate) { if (overridden_frontend_url_.empty()) overridden_frontend_url_ = "/devtools/devtools.html"; - AddRef(); } @@ -581,7 +538,7 @@ void DevToolsHttpHandlerImpl::Send404(int connection_id) { } void DevToolsHttpHandlerImpl::Send500(int connection_id, - const std::string& message) { + const std::string& message) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&net::HttpServer::Send500, server_.get(), connection_id, diff --git a/content/browser/debugger/devtools_http_handler_impl.h b/content/browser/debugger/devtools_http_handler_impl.h index 556ab06d..e9be675 100644 --- a/content/browser/debugger/devtools_http_handler_impl.h +++ b/content/browser/debugger/devtools_http_handler_impl.h @@ -18,6 +18,8 @@ #include "net/server/http_server.h" #include "net/url_request/url_request.h" +class TabContents; + namespace net { class URLRequestContext; } diff --git a/content/browser/debugger/devtools_netlog_observer.cc b/content/browser/debugger/devtools_netlog_observer.cc index a563a8d..98492b2 100644 --- a/content/browser/debugger/devtools_netlog_observer.cc +++ b/content/browser/debugger/devtools_netlog_observer.cc @@ -240,18 +240,17 @@ void DevToolsNetLogObserver::OnAddSocketEntry( void DevToolsNetLogObserver::Attach() { DCHECK(!instance_); - net::NetLog* net_log = content::GetContentClient()->browser()->GetNetLog(); - if (net_log) - instance_ = new DevToolsNetLogObserver(net_log); + + instance_ = new DevToolsNetLogObserver( + content::GetContentClient()->browser()->GetNetLog()); } void DevToolsNetLogObserver::Detach() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + DCHECK(instance_); - if (instance_) { - delete instance_; - instance_ = NULL; - } + delete instance_; + instance_ = NULL; } DevToolsNetLogObserver* DevToolsNetLogObserver::GetInstance() { diff --git a/content/browser/debugger/devtools_resources.gyp b/content/browser/debugger/devtools_resources.gyp deleted file mode 100644 index bacacac..0000000 --- a/content/browser/debugger/devtools_resources.gyp +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (c) 2012 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -{ - 'targets': [ - { - 'target_name': 'devtools_resources', - 'type': 'none', - 'dependencies': [ - '../../../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:generate_devtools_grd', - ], - 'variables': { - 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/webkit', - }, - 'actions': [ - { - 'action_name': 'devtools_resources', - # This can't use build/grit_action.gypi because the grd file - # is generated at build time, so the trick of using grit_info to get - # the real inputs/outputs at GYP time isn't possible. - 'variables': { - 'grit_cmd': ['python', '../../../tools/grit/grit.py'], - 'grit_grd_file': '<(SHARED_INTERMEDIATE_DIR)/devtools/devtools_resources.grd', - }, - 'inputs': [ - '<(grit_grd_file)', - '<!@pymod_do_main(grit_info --inputs)', - ], - 'outputs': [ - '<(grit_out_dir)/grit/devtools_resources.h', - '<(grit_out_dir)/devtools_resources.pak', - '<(grit_out_dir)/grit/devtools_resources_map.cc', - '<(grit_out_dir)/grit/devtools_resources_map.h', - ], - 'action': ['<@(grit_cmd)', - '-i', '<(grit_grd_file)', 'build', - '-o', '<(grit_out_dir)', - '-D', 'SHARED_INTERMEDIATE_DIR=<(SHARED_INTERMEDIATE_DIR)', - '<@(grit_defines)' ], - 'message': 'Generating resources from <(grit_grd_file)', - } - ], - 'includes': [ '../../../build/grit_target.gypi' ], - }, - ], -} |