Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Unified Diff: sky/tools/debugger/prompt/prompt.cc

Issue 853943005: Make tracing work on Android (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: nits Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/tools/debugger/prompt/prompt.cc
diff --git a/sky/tools/debugger/prompt/prompt.cc b/sky/tools/debugger/prompt/prompt.cc
index e31233646fc425d13dc37ae15af43e14869b2a3a..28c5297e841c4d72fd8816ebf06d0cebf79e1976 100644
--- a/sky/tools/debugger/prompt/prompt.cc
+++ b/sky/tools/debugger/prompt/prompt.cc
@@ -2,7 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <algorithm>
+
#include "base/bind.h"
+#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
@@ -16,11 +19,17 @@
#include "net/socket/tcp_server_socket.h"
#include "services/tracing/tracing.mojom.h"
#include "sky/tools/debugger/debugger.mojom.h"
+#include "sky/tools/debugger/prompt/trace_collector.h"
namespace sky {
namespace debugger {
+namespace {
+
+const size_t kMinSendBufferSize = 1024 * 1024;
+}
-class Prompt : public mojo::ApplicationDelegate, public net::HttpServer::Delegate {
+class Prompt : public mojo::ApplicationDelegate,
+ public net::HttpServer::Delegate {
public:
Prompt()
: is_tracing_(false),
@@ -98,6 +107,8 @@ class Prompt : public mojo::ApplicationDelegate, public net::HttpServer::Delegat
}
void Respond(int connection_id, std::string response) {
+ web_server_->SetSendBufferSize(
eseidel 2015/01/16 00:07:25 You should expain why you're donig this in a comme
abarth-chromium 2015/01/16 00:31:53 Done.
+ connection_id, std::max(kMinSendBufferSize, response.length()));
web_server_->Send200(connection_id, response, "text/plain");
}
@@ -138,16 +149,25 @@ class Prompt : public mojo::ApplicationDelegate, public net::HttpServer::Delegat
}
void ToggleTracing(int connection_id) {
- std::string response;
- if (is_tracing_) {
- response = "Stopping trace (writing to sky_viewer.trace)\n";
+ bool was_tracing = is_tracing_;
+ is_tracing_ = !is_tracing_;
+
+ if (was_tracing) {
tracing_->StopAndFlush();
- } else {
- response = "Starting trace (type 'trace' to stop tracing)\n";
- tracing_->Start(mojo::String("sky_viewer"), mojo::String("*"));
+ trace_collector_->GetTrace(base::Bind(
+ &Prompt::OnTraceAvailable, base::Unretained(this), connection_id));
+ return;
}
- is_tracing_ = !is_tracing_;
- Respond(connection_id, response);
+
+ mojo::DataPipe pipe;
+ tracing_->Start(pipe.producer_handle.Pass(), mojo::String("*"));
+ trace_collector_.reset(new TraceCollector(pipe.consumer_handle.Pass()));
+ Respond(connection_id, "Starting trace (type 'trace' to stop tracing)\n");
+ }
+
+ void OnTraceAvailable(int connection_id, std::string trace) {
+ trace_collector_.reset();
+ Respond(connection_id, trace);
}
bool is_tracing_;
@@ -158,6 +178,8 @@ class Prompt : public mojo::ApplicationDelegate, public net::HttpServer::Delegat
scoped_ptr<net::HttpServer> web_server_;
uint32_t command_port_;
+ scoped_ptr<TraceCollector> trace_collector_;
+
DISALLOW_COPY_AND_ASSIGN(Prompt);
};

Powered by Google App Engine
This is Rietveld 408576698