Chromium Code Reviews| Index: content/browser/debugger/devtools_http_handler_impl.cc |
| diff --git a/content/browser/debugger/devtools_http_handler_impl.cc b/content/browser/debugger/devtools_http_handler_impl.cc |
| index 377ec1c164bb0714f4e2194ae7ca6f7f813f4818..2a3db35c3dd0070691af5586fe76637a38ef107c 100644 |
| --- a/content/browser/debugger/devtools_http_handler_impl.cc |
| +++ b/content/browser/debugger/devtools_http_handler_impl.cc |
| @@ -19,6 +19,8 @@ |
| #include "base/threading/thread.h" |
| #include "base/utf_string_conversions.h" |
| #include "base/values.h" |
| +#include "content/browser/debugger/devtools_browser_target.h" |
| +#include "content/browser/debugger/devtools_trace_domain_handler.h" |
| #include "content/browser/web_contents/web_contents_impl.h" |
| #include "content/common/devtools_messages.h" |
| #include "content/public/browser/browser_thread.h" |
| @@ -308,6 +310,18 @@ void DevToolsHttpHandlerImpl::OnHttpRequest( |
| return; |
| } |
| + if (info.path.find("/trace/") == 0) { |
|
pfeldman
2012/12/12 20:17:12
nuke
bulach
2012/12/13 17:36:23
Done.
|
| + // Trace request. |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, |
| + FROM_HERE, |
| + base::Bind(&DevToolsHttpHandlerImpl::OnTraceRequestUI, |
| + this, |
| + connection_id, |
| + info)); |
| + return; |
| + } |
| + |
| if (info.path == "" || info.path == "/") { |
| // Discovery page request. |
| BrowserThread::PostTask( |
| @@ -578,6 +592,43 @@ void DevToolsHttpHandlerImpl::OnThumbnailRequestUI( |
| Send404(connection_id); |
| } |
| +void DevToolsHttpHandlerImpl::OnTraceRequestUI( |
| + int connection_id, |
| + const net::HttpServerRequestInfo& info) { |
| +/* |
| + std::string prefix = "/trace/"; |
| + size_t pos = info.path.find(prefix); |
| + if (pos != 0) { |
| + Send404(connection_id); |
| + return; |
| + } |
| + |
| + std::string command = info.path.substr(prefix.length()); |
| + |
| + std::string response("ok"); |
| + if (command == "start") { |
| + // TODO(bulach): capture categories somehow. |
| + std::string categories; |
| + devtools_trace_handler_.BeginTracing(categories); |
| + } else if (command == "stop") |
| + devtools_trace_handler_.EndTracingAsync(); |
| + else if (command == "has_completed") { |
| + response = devtools_trace_handler_.has_completed() ? |
| + "ok" : "pending"; |
| + } else if (command == "get") { |
| + if (devtools_trace_handler_.has_completed()) { |
| + Send200( |
| + connection_id, devtools_trace_handler_.GetAndResetTrace(), |
| + "binary/octet-stream"); |
| + return; |
| + } |
| + Send404(connection_id); |
| + return; |
| + } |
| + Send200(connection_id, response, "text/html; charset=UTF-8"); |
| +*/ |
| +} |
| + |
| void DevToolsHttpHandlerImpl::OnDiscoveryPageRequestUI(int connection_id) { |
| std::string response = delegate_->GetDiscoveryPageHTML(); |
| Send200(connection_id, response, "text/html; charset=UTF-8"); |
| @@ -589,14 +640,24 @@ void DevToolsHttpHandlerImpl::OnWebSocketRequestUI( |
| if (!thread_.get()) |
| return; |
| - std::string prefix = "/devtools/page/"; |
| - size_t pos = request.path.find(prefix); |
| + std::string browser_prefix = "/devtools/browser/"; |
|
pfeldman
2012/12/12 20:17:12
No need for the trailing slash here
bulach
2012/12/13 17:36:23
Done.
|
| + size_t browser_pos = request.path.find(browser_prefix); |
| + if (browser_pos == 0) { |
| + browser_target_.reset(new DevToolsBrowserTarget(connection_id)); |
| + browser_target_->RegisterHandler(new DevToolsTraceDomainHandler()); |
| + AcceptWebSocket(connection_id, request); |
| + return; |
| + } |
| + |
| + |
| + std::string page_prefix = "/devtools/page/"; |
| + size_t pos = request.path.find(page_prefix); |
| if (pos != 0) { |
| Send404(connection_id); |
| return; |
| } |
| - std::string page_id = request.path.substr(prefix.length()); |
| + std::string page_id = request.path.substr(page_prefix.length()); |
| RenderViewHost* rvh = binding_->ForIdentifier(page_id); |
| if (!rvh) { |
| Send500(connection_id, "No such target id: " + page_id); |
| @@ -631,6 +692,11 @@ void DevToolsHttpHandlerImpl::OnWebSocketMessageUI( |
| if (it == connection_to_client_host_ui_.end()) |
| return; |
| + if (browser_target_ && connection_id == browser_target_->connection_id()) { |
| + browser_target_->OnWebSocketMessage(connection_id, data, this); |
| + return; |
| + } |
| + |
| DevToolsManager* manager = DevToolsManager::GetInstance(); |
| manager->DispatchOnInspectorBackend(it->second, data); |
| } |