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

Side by Side Diff: src/tracing/event-tracer.cc

Issue 988893003: Implement tracing interface for v8 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add a Unittest for trace-event Created 5 years, 9 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
(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, int numArgs, const char** argNames, const uint8_t* argTypes,
14 const uint64_t* argValues, uint8_t flags) {
15 return 0;
16 }
17
18 virtual void UpdateTraceEventDuration(const uint8_t* categoryEnabledFlag,
19 const char* name,
20 EventTracer::Handle handle) {}
21
22 virtual const uint8_t* GetCategoryGroupEnabled(const char* name) {
23 static uint8_t no = 0;
24 return &no;
25 }
26
27 virtual const char* GetCategoryGroupName(const uint8_t* categoryEnabledFlag) {
28 static const char* dummy = "dummy";
29 return dummy;
30 }
31 };
32
33
34 static void CleanupTracer() {
35 // calling SetInstance will delete the existing instance.
36 v8::EventTracer::SetInstance(NULL);
37 }
38
39
40 static void IntializeDefaultTracer(v8::EventTracer* current_instance) {
41 if (current_instance == NULL) {
42 v8::EventTracer::SetInstance(new (DefaultEventTracer));
43 }
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,
52 v8::EventTracer::instance);
53 DCHECK(v8::EventTracer::instance);
54 return v8::EventTracer::instance;
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698