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

Unified Diff: services/tracing/trace_data_sink.cc

Issue 952413002: The tracing service sometimes creates corrupt data (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « mojo/common/data_pipe_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/tracing/trace_data_sink.cc
diff --git a/services/tracing/trace_data_sink.cc b/services/tracing/trace_data_sink.cc
index eadeb570940578e57f5181c989933fe8bf14c957..088efc376a901c599fef0b29e47d3df7622e182e 100644
--- a/services/tracing/trace_data_sink.cc
+++ b/services/tracing/trace_data_sink.cc
@@ -5,6 +5,7 @@
#include "services/tracing/trace_data_sink.h"
#include "base/logging.h"
+#include "mojo/common/data_pipe_utils.h"
namespace tracing {
namespace {
@@ -12,18 +13,11 @@ namespace {
const char kStart[] = "{\"traceEvents\":[";
const char kEnd[] = "]}";
-void Write(const mojo::ScopedDataPipeProducerHandle& pipe,
- const char* string,
- uint32_t num_bytes) {
- CHECK_EQ(MOJO_RESULT_OK,
- mojo::WriteDataRaw(pipe.get(), string, &num_bytes,
- MOJO_WRITE_DATA_FLAG_ALL_OR_NONE));
-}
-}
+} // namespace
TraceDataSink::TraceDataSink(mojo::ScopedDataPipeProducerHandle pipe)
: pipe_(pipe.Pass()), empty_(true) {
- Write(pipe_, kStart, strlen(kStart));
+ mojo::common::BlockingCopyFromString(kStart, pipe_);
jamesr 2015/02/26 00:25:22 since we're calling this 3 times could you put a u
abarth-chromium 2015/02/26 02:54:12 Will do. Thanks!
}
TraceDataSink::~TraceDataSink() {
@@ -34,13 +28,13 @@ TraceDataSink::~TraceDataSink() {
void TraceDataSink::AddChunk(const std::string& json) {
if (!empty_)
- Write(pipe_, ",", 1);
+ mojo::common::BlockingCopyFromString(",", pipe_);
empty_ = false;
- Write(pipe_, json.data(), json.length());
+ mojo::common::BlockingCopyFromString(json, pipe_);
}
void TraceDataSink::Flush() {
- Write(pipe_, kEnd, strlen(kEnd));
+ mojo::common::BlockingCopyFromString(kEnd, pipe_);
pipe_.reset();
}
« no previous file with comments | « mojo/common/data_pipe_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698