OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <include/v8-tracing.h> |
| 6 |
| 7 #include "src/log.h" |
| 8 #include "src/v8.h" |
| 9 |
| 10 class DefaultEventTracer : public v8::EventTracer { |
| 11 virtual v8::EventTracer::Handle AddTraceEvent( |
| 12 char phase, const uint8_t* categoryEnabledFlag, const char* name, |
| 13 uint64_t id, uint64_t context_id, uint64_t bind_id, int numArgs, |
| 14 const char** argNames, const uint8_t* argTypes, const uint64_t* argValues, |
| 15 unsigned int flags) { |
| 16 return 0; |
| 17 } |
| 18 |
| 19 virtual void UpdateTraceEventDuration(const uint8_t* categoryEnabledFlag, |
| 20 const char* name, |
| 21 EventTracer::Handle handle) {} |
| 22 |
| 23 virtual const uint8_t* GetCategoryGroupEnabled(const char* name) { |
| 24 static uint8_t no = 0; |
| 25 return &no; |
| 26 } |
| 27 |
| 28 virtual const char* GetCategoryGroupName(const uint8_t* categoryEnabledFlag) { |
| 29 static const char* dummy = "dummy"; |
| 30 return dummy; |
| 31 } |
| 32 }; |
| 33 |
| 34 |
| 35 static void CleanupTracer() { |
| 36 // calling SetInstance will delete the existing instance. |
| 37 v8::EventTracer::SetInstance(NULL); |
| 38 } |
| 39 |
| 40 |
| 41 static void IntializeDefaultTracer(v8::EventTracer* current_instance) { |
| 42 if (current_instance == NULL) |
| 43 v8::EventTracer::SetInstance(new (DefaultEventTracer)); |
| 44 atexit(CleanupTracer); |
| 45 } |
| 46 |
| 47 |
| 48 V8_DECLARE_ONCE(init_once); |
| 49 v8::EventTracer* v8::EventTracer::instance; |
| 50 v8::EventTracer* v8::EventTracer::GetInstance() { |
| 51 base::CallOnce(&init_once, IntializeDefaultTracer, v8::EventTracer::instance); |
| 52 DCHECK(v8::EventTracer::instance); |
| 53 return v8::EventTracer::instance; |
| 54 } |
OLD | NEW |