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

Side by Side Diff: src/libplatform/tracing/trace-writer.cc

Issue 2367603002: [tracing] Support ConvertableToTraceFormat argument type. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project 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 "src/libplatform/tracing/trace-writer.h" 5 #include "src/libplatform/tracing/trace-writer.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/trace_event/common/trace_event_common.h" 9 #include "base/trace_event/common/trace_event_common.h"
10 #include "include/v8-platform.h"
10 #include "src/base/platform/platform.h" 11 #include "src/base/platform/platform.h"
11 12
12 namespace v8 { 13 namespace v8 {
13 namespace platform { 14 namespace platform {
14 namespace tracing { 15 namespace tracing {
15 16
16 // Writes the given string to a stream, taking care to escape characters 17 // Writes the given string to a stream, taking care to escape characters
17 // when necessary. 18 // when necessary.
18 V8_INLINE static void WriteJSONStringToStream(const char* str, 19 V8_INLINE static void WriteJSONStringToStream(const char* str,
19 std::ostream& stream) { 20 std::ostream& stream) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 stream_ << "\"" << value.as_pointer << "\""; 100 stream_ << "\"" << value.as_pointer << "\"";
100 break; 101 break;
101 case TRACE_VALUE_TYPE_STRING: 102 case TRACE_VALUE_TYPE_STRING:
102 case TRACE_VALUE_TYPE_COPY_STRING: 103 case TRACE_VALUE_TYPE_COPY_STRING:
103 if (value.as_string == nullptr) { 104 if (value.as_string == nullptr) {
104 stream_ << "\"NULL\""; 105 stream_ << "\"NULL\"";
105 } else { 106 } else {
106 WriteJSONStringToStream(value.as_string, stream_); 107 WriteJSONStringToStream(value.as_string, stream_);
107 } 108 }
108 break; 109 break;
110 case TRACE_VALUE_TYPE_CONVERTABLE: {
111 std::unique_ptr<v8::ConvertableToTraceFormat> convertable_arg(
112 reinterpret_cast<v8::ConvertableToTraceFormat*>(
113 static_cast<intptr_t>(value.as_uint)));
114 std::string arg_stringified;
115 convertable_arg->AppendAsTraceFormat(&arg_stringified);
116 stream_ << arg_stringified;
117 break;
118 }
109 default: 119 default:
110 UNREACHABLE(); 120 UNREACHABLE();
111 break; 121 break;
112 } 122 }
113 } 123 }
114 124
115 JSONTraceWriter::JSONTraceWriter(std::ostream& stream) : stream_(stream) { 125 JSONTraceWriter::JSONTraceWriter(std::ostream& stream) : stream_(stream) {
116 stream_ << "{\"traceEvents\":["; 126 stream_ << "{\"traceEvents\":[";
117 } 127 }
118 128
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 164
155 void JSONTraceWriter::Flush() {} 165 void JSONTraceWriter::Flush() {}
156 166
157 TraceWriter* TraceWriter::CreateJSONTraceWriter(std::ostream& stream) { 167 TraceWriter* TraceWriter::CreateJSONTraceWriter(std::ostream& stream) {
158 return new JSONTraceWriter(stream); 168 return new JSONTraceWriter(stream);
159 } 169 }
160 170
161 } // namespace tracing 171 } // namespace tracing
162 } // namespace platform 172 } // namespace platform
163 } // namespace v8 173 } // namespace v8
OLDNEW
« no previous file with comments | « include/v8-platform.h ('k') | src/tracing/trace-event.h » ('j') | src/tracing/trace-event.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698