15
15
#include " v8-platform.h" // NOLINT(build/include_directory)
16
16
17
17
namespace perfetto {
18
- namespace trace_processor {
19
- class TraceProcessorStorage ;
20
- }
21
18
class TracingSession ;
22
19
}
23
20
@@ -31,6 +28,7 @@ namespace platform {
31
28
namespace tracing {
32
29
33
30
class TraceEventListener ;
31
+ class JSONTraceEventListener ;
34
32
35
33
const int kTraceMaxNumArgs = 2 ;
36
34
@@ -199,9 +197,6 @@ class V8_PLATFORM_EXPORT TraceConfig {
199
197
200
198
TraceConfig () : enable_systrace_(false ), enable_argument_filter_(false ) {}
201
199
TraceRecordMode GetTraceRecordMode () const { return record_mode_; }
202
- const StringList& GetEnabledCategories () const {
203
- return included_categories_;
204
- }
205
200
bool IsSystraceEnabled () const { return enable_systrace_; }
206
201
bool IsArgumentFilterEnabled () const { return enable_argument_filter_; }
207
202
@@ -234,17 +229,6 @@ class V8_PLATFORM_EXPORT TraceConfig {
234
229
class V8_PLATFORM_EXPORT TracingController
235
230
: public V8_PLATFORM_NON_EXPORTED_BASE (v8::TracingController) {
236
231
public:
237
- TracingController ();
238
- ~TracingController () override ;
239
-
240
- #if defined(V8_USE_PERFETTO)
241
- // Must be called before StartTracing() if V8_USE_PERFETTO is true. Provides
242
- // the output stream for the JSON trace data.
243
- void InitializeForPerfetto (std::ostream* output_stream);
244
- // Provide an optional listener for testing that will receive trace events.
245
- // Must be called before StartTracing().
246
- void SetTraceEventListenerForTesting (TraceEventListener* listener);
247
- #else // defined(V8_USE_PERFETTO)
248
232
// The pointer returned from GetCategoryGroupEnabled() points to a value with
249
233
// zero or more of the following bits. Used in this class only. The
250
234
// TRACE_EVENT macros should only use the value as a bool. These values must
@@ -258,8 +242,19 @@ class V8_PLATFORM_EXPORT TracingController
258
242
ENABLED_FOR_ETW_EXPORT = 1 << 3
259
243
};
260
244
245
+ TracingController ();
246
+ ~TracingController () override ;
247
+
261
248
// Takes ownership of |trace_buffer|.
262
249
void Initialize (TraceBuffer* trace_buffer);
250
+ #ifdef V8_USE_PERFETTO
251
+ // Must be called before StartTracing() if V8_USE_PERFETTO is true. Provides
252
+ // the output stream for the JSON trace data.
253
+ void InitializeForPerfetto (std::ostream* output_stream);
254
+ // Provide an optional listener for testing that will receive trace events.
255
+ // Must be called before StartTracing().
256
+ void SetTraceEventListenerForTesting (TraceEventListener* listener);
257
+ #endif
263
258
264
259
// v8::TracingController implementation.
265
260
const uint8_t * GetCategoryGroupEnabled (const char * category_group) override ;
@@ -279,10 +274,6 @@ class V8_PLATFORM_EXPORT TracingController
279
274
unsigned int flags, int64_t timestamp) override ;
280
275
void UpdateTraceEventDuration (const uint8_t * category_enabled_flag,
281
276
const char * name, uint64_t handle) override ;
282
-
283
- static const char * GetCategoryGroupName (const uint8_t * category_enabled_flag);
284
- #endif // !defined(V8_USE_PERFETTO)
285
-
286
277
void AddTraceStateObserver (
287
278
v8::TracingController::TraceStateObserver* observer) override ;
288
279
void RemoveTraceStateObserver (
@@ -291,32 +282,27 @@ class V8_PLATFORM_EXPORT TracingController
291
282
void StartTracing (TraceConfig* trace_config);
292
283
void StopTracing ();
293
284
285
+ static const char * GetCategoryGroupName (const uint8_t * category_enabled_flag);
286
+
294
287
protected:
295
- #if !defined(V8_USE_PERFETTO)
296
288
virtual int64_t CurrentTimestampMicroseconds ();
297
289
virtual int64_t CurrentCpuTimestampMicroseconds ();
298
- #endif // !defined(V8_USE_PERFETTO)
299
290
300
291
private:
301
- #if !defined(V8_USE_PERFETTO)
302
292
void UpdateCategoryGroupEnabledFlag (size_t category_index);
303
293
void UpdateCategoryGroupEnabledFlags ();
304
- #endif // !defined(V8_USE_PERFETTO)
305
294
306
- std::unique_ptr<base::Mutex> mutex_ ;
295
+ std::unique_ptr<TraceBuffer> trace_buffer_ ;
307
296
std::unique_ptr<TraceConfig> trace_config_;
308
- std::atomic_bool recording_{ false } ;
297
+ std::unique_ptr<base::Mutex> mutex_ ;
309
298
std::unordered_set<v8::TracingController::TraceStateObserver*> observers_;
310
-
311
- #if defined( V8_USE_PERFETTO)
299
+ std::atomic_bool recording_{ false };
300
+ #ifdef V8_USE_PERFETTO
312
301
std::ostream* output_stream_ = nullptr ;
313
- std::unique_ptr<perfetto::trace_processor::TraceProcessorStorage>
314
- trace_processor_;
302
+ std::unique_ptr<JSONTraceEventListener> json_listener_;
315
303
TraceEventListener* listener_for_testing_ = nullptr ;
316
304
std::unique_ptr<perfetto::TracingSession> tracing_session_;
317
- #else // !defined(V8_USE_PERFETTO)
318
- std::unique_ptr<TraceBuffer> trace_buffer_;
319
- #endif // !defined(V8_USE_PERFETTO)
305
+ #endif
320
306
321
307
// Disallow copy and assign
322
308
TracingController (const TracingController&) = delete ;
0 commit comments