Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef V8_LIBPLATFORM_V8_TRACING_H_ | 5 #ifndef V8_LIBPLATFORM_V8_TRACING_H_ |
| 6 #define V8_LIBPLATFORM_V8_TRACING_H_ | 6 #define V8_LIBPLATFORM_V8_TRACING_H_ |
| 7 | 7 |
| 8 #include <fstream> | 8 #include <fstream> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <unordered_set> | |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 13 #include "include/v8-platform.h" | |
| 14 | |
| 12 namespace v8 { | 15 namespace v8 { |
| 16 | |
| 17 namespace base { | |
| 18 class Mutex; | |
| 19 } // namespace base | |
| 20 | |
| 13 namespace platform { | 21 namespace platform { |
| 14 namespace tracing { | 22 namespace tracing { |
| 15 | 23 |
| 16 const int kTraceMaxNumArgs = 2; | 24 const int kTraceMaxNumArgs = 2; |
| 17 | 25 |
| 18 class TraceObject { | 26 class TraceObject { |
| 19 public: | 27 public: |
| 20 union ArgValue { | 28 union ArgValue { |
| 21 bool as_bool; | 29 bool as_bool; |
| 22 uint64_t as_uint; | 30 uint64_t as_uint; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 // These values must be in sync with macro values in TraceEvent.h in Blink. | 218 // These values must be in sync with macro values in TraceEvent.h in Blink. |
| 211 enum CategoryGroupEnabledFlags { | 219 enum CategoryGroupEnabledFlags { |
| 212 // Category group enabled for the recording mode. | 220 // Category group enabled for the recording mode. |
| 213 ENABLED_FOR_RECORDING = 1 << 0, | 221 ENABLED_FOR_RECORDING = 1 << 0, |
| 214 // Category group enabled by SetEventCallbackEnabled(). | 222 // Category group enabled by SetEventCallbackEnabled(). |
| 215 ENABLED_FOR_EVENT_CALLBACK = 1 << 2, | 223 ENABLED_FOR_EVENT_CALLBACK = 1 << 2, |
| 216 // Category group enabled to export events to ETW. | 224 // Category group enabled to export events to ETW. |
| 217 ENABLED_FOR_ETW_EXPORT = 1 << 3 | 225 ENABLED_FOR_ETW_EXPORT = 1 << 3 |
| 218 }; | 226 }; |
| 219 | 227 |
| 220 TracingController() {} | 228 TracingController(); |
| 229 ~TracingController(); | |
| 221 void Initialize(TraceBuffer* trace_buffer); | 230 void Initialize(TraceBuffer* trace_buffer); |
| 222 const uint8_t* GetCategoryGroupEnabled(const char* category_group); | 231 const uint8_t* GetCategoryGroupEnabled(const char* category_group); |
| 223 static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag); | 232 static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag); |
| 224 uint64_t AddTraceEvent(char phase, const uint8_t* category_enabled_flag, | 233 uint64_t AddTraceEvent(char phase, const uint8_t* category_enabled_flag, |
| 225 const char* name, const char* scope, uint64_t id, | 234 const char* name, const char* scope, uint64_t id, |
| 226 uint64_t bind_id, int32_t num_args, | 235 uint64_t bind_id, int32_t num_args, |
| 227 const char** arg_names, const uint8_t* arg_types, | 236 const char** arg_names, const uint8_t* arg_types, |
| 228 const uint64_t* arg_values, unsigned int flags); | 237 const uint64_t* arg_values, unsigned int flags); |
| 229 void UpdateTraceEventDuration(const uint8_t* category_enabled_flag, | 238 void UpdateTraceEventDuration(const uint8_t* category_enabled_flag, |
| 230 const char* name, uint64_t handle); | 239 const char* name, uint64_t handle); |
| 231 | 240 |
| 232 void StartTracing(TraceConfig* trace_config); | 241 void StartTracing(TraceConfig* trace_config); |
| 233 void StopTracing(); | 242 void StopTracing(); |
| 234 | 243 |
| 244 void AddTraceStateObserver(Platform::TraceStateObserver* observer); | |
| 245 void RemoveTraceStateObserver(Platform::TraceStateObserver* observer); | |
| 246 | |
| 235 private: | 247 private: |
| 236 const uint8_t* GetCategoryGroupEnabledInternal(const char* category_group); | 248 const uint8_t* GetCategoryGroupEnabledInternal(const char* category_group); |
| 237 void UpdateCategoryGroupEnabledFlag(size_t category_index); | 249 void UpdateCategoryGroupEnabledFlag(size_t category_index); |
| 238 void UpdateCategoryGroupEnabledFlags(); | 250 void UpdateCategoryGroupEnabledFlags(); |
| 239 | 251 |
| 240 std::unique_ptr<TraceBuffer> trace_buffer_; | 252 std::unique_ptr<TraceBuffer> trace_buffer_; |
| 241 std::unique_ptr<TraceConfig> trace_config_; | 253 std::unique_ptr<TraceConfig> trace_config_; |
| 254 std::unique_ptr<base::Mutex> mutex_; | |
|
fmeawad
2016/09/27 18:05:49
nit: maybe rename the mutex to specify that it is
alph
2016/09/27 19:10:53
It's now guarding against mode change as well to s
| |
| 255 std::unordered_set<Platform::TraceStateObserver*> observers_; | |
| 242 Mode mode_ = DISABLED; | 256 Mode mode_ = DISABLED; |
| 243 | 257 |
| 244 // Disallow copy and assign | 258 // Disallow copy and assign |
| 245 TracingController(const TracingController&) = delete; | 259 TracingController(const TracingController&) = delete; |
| 246 void operator=(const TracingController&) = delete; | 260 void operator=(const TracingController&) = delete; |
| 247 }; | 261 }; |
| 248 | 262 |
| 249 } // namespace tracing | 263 } // namespace tracing |
| 250 } // namespace platform | 264 } // namespace platform |
| 251 } // namespace v8 | 265 } // namespace v8 |
| 252 | 266 |
| 253 #endif // V8_LIBPLATFORM_V8_TRACING_H_ | 267 #endif // V8_LIBPLATFORM_V8_TRACING_H_ |
| OLD | NEW |