| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ce48936 commit 6b58746
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,9 +37,7 @@ void NodeTraceWriter::WriteSuffix() { | |||
| 37 | 37 | { | |
| 38 | 38 | Mutex::ScopedLock scoped_lock(stream_mutex_); | |
| 39 | 39 | if (total_traces_ > 0) { | |
| 40 | - total_traces_ = 0; // so we don't write it again in FlushPrivate | ||
| 41 | - // Appends "]}" to stream_. | ||
| 42 | - delete json_trace_writer_; | ||
| 40 | + total_traces_ = kTracesPerFile; // Act as if we reached the file limit. | ||
| 43 | 41 | should_flush = true; | |
| 44 | 42 | } | |
| 45 | 43 | } | |
@@ -111,7 +109,7 @@ void NodeTraceWriter::AppendTraceEvent(TraceObject* trace_event) { | |||
| 111 | 109 | // to a state where we can start writing trace events to it. | |
| 112 | 110 | // Repeatedly constructing and destroying json_trace_writer_ allows | |
| 113 | 111 | // us to use V8's JSON writer instead of implementing our own. | |
| 114 | - json_trace_writer_ = TraceWriter::CreateJSONTraceWriter(stream_); | ||
| 112 | + json_trace_writer_.reset(TraceWriter::CreateJSONTraceWriter(stream_)); | ||
| 115 | 113 | } | |
| 116 | 114 | ++total_traces_; | |
| 117 | 115 | json_trace_writer_->AppendTraceEvent(trace_event); | |
@@ -126,7 +124,7 @@ void NodeTraceWriter::FlushPrivate() { | |||
| 126 | 124 | total_traces_ = 0; | |
| 127 | 125 | // Destroying the member JSONTraceWriter object appends "]}" to | |
| 128 | 126 | // stream_ - in other words, ending a JSON file. | |
| 129 | - delete json_trace_writer_; | ||
| 127 | + json_trace_writer_.reset(); | ||
| 130 | 128 | } | |
| 131 | 129 | // str() makes a copy of the contents of the stream. | |
| 132 | 130 | str = stream_.str(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,7 +63,7 @@ class NodeTraceWriter : public AsyncTraceWriter { | |||
| 63 | 63 | int file_num_ = 0; | |
| 64 | 64 | const std::string& log_file_pattern_; | |
| 65 | 65 | std::ostringstream stream_; | |
| 66 | - TraceWriter* json_trace_writer_ = nullptr; | ||
| 66 | + std::unique_ptr<TraceWriter> json_trace_writer_; | ||
| 67 | 67 | bool exited_ = false; | |
| 68 | 68 | }; | |
| 69 | 69 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments