Chromium Code Reviews| 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(); |
| } |