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..7f4a7d20e8581b7bf915f7c8c1f7fdd34af99291 100644 |
--- a/content/browser/debugger/devtools_http_handler_impl.cc |
+++ b/content/browser/debugger/devtools_http_handler_impl.cc |
@@ -308,6 +308,18 @@ void DevToolsHttpHandlerImpl::OnHttpRequest( |
return; |
} |
+ if (info.path.find("/trace/") == 0) { |
+ // 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 +590,41 @@ 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); |
pfeldman
2012/12/12 17:45:22
This discovery handler is supposed to be used with
|
+ 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"); |