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

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: Minor Created 5 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
(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 }
dsinclair 2015/08/25 13:56:22 nit: no {}'s on single line bodies
fmeawad 2015/08/25 21:32:01 Done.
45 atexit(CleanupTracer);
46 }
47
48
49 V8_DECLARE_ONCE(init_once);
50 v8::EventTracer* v8::EventTracer::instance;
51 v8::EventTracer* v8::EventTracer::GetInstance() {
52 base::CallOnce(&init_once, IntializeDefaultTracer, v8::EventTracer::instance);
53 DCHECK(v8::EventTracer::instance);
54 return v8::EventTracer::instance;
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698