| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/services/tracing/trace_data_sink.h" | 5 #include "mojo/services/tracing/trace_data_sink.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "mojo/common/data_pipe_utils.h" | 10 #include "mojo/common/data_pipe_utils.h" |
| 9 | 11 |
| 10 using mojo::common::BlockingCopyFromString; | 12 using mojo::common::BlockingCopyFromString; |
| 11 | 13 |
| 12 namespace tracing { | 14 namespace tracing { |
| 13 | 15 |
| 14 TraceDataSink::TraceDataSink(mojo::ScopedDataPipeProducerHandle pipe) | 16 TraceDataSink::TraceDataSink(mojo::ScopedDataPipeProducerHandle pipe) |
| 15 : pipe_(pipe.Pass()), empty_(true) { | 17 : pipe_(std::move(pipe)), empty_(true) {} |
| 16 } | |
| 17 | 18 |
| 18 TraceDataSink::~TraceDataSink() { | 19 TraceDataSink::~TraceDataSink() { |
| 19 if (pipe_.is_valid()) | 20 if (pipe_.is_valid()) |
| 20 pipe_.reset(); | 21 pipe_.reset(); |
| 21 DCHECK(!pipe_.is_valid()); | 22 DCHECK(!pipe_.is_valid()); |
| 22 } | 23 } |
| 23 | 24 |
| 24 void TraceDataSink::AddChunk(const std::string& json) { | 25 void TraceDataSink::AddChunk(const std::string& json) { |
| 25 if (!empty_) | 26 if (!empty_) |
| 26 BlockingCopyFromString(",", pipe_); | 27 BlockingCopyFromString(",", pipe_); |
| 27 empty_ = false; | 28 empty_ = false; |
| 28 BlockingCopyFromString(json, pipe_); | 29 BlockingCopyFromString(json, pipe_); |
| 29 } | 30 } |
| 30 | 31 |
| 31 } // namespace tracing | 32 } // namespace tracing |
| OLD | NEW |