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

Side by Side Diff: sky/engine/platform/EventTracer.cpp

Issue 893503002: Remove unused trace sampling states (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « sky/engine/platform/EventTracer.h ('k') | sky/engine/platform/testing/RunAllTests.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 22 matching lines...) Expand all
33 33
34 #include <stdio.h> 34 #include <stdio.h>
35 #include "sky/engine/public/platform/Platform.h" 35 #include "sky/engine/public/platform/Platform.h"
36 #include "sky/engine/public/platform/WebConvertableToTraceFormat.h" 36 #include "sky/engine/public/platform/WebConvertableToTraceFormat.h"
37 #include "sky/engine/wtf/Assertions.h" 37 #include "sky/engine/wtf/Assertions.h"
38 38
39 namespace blink { 39 namespace blink {
40 40
41 COMPILE_ASSERT(sizeof(blink::Platform::TraceEventHandle) == sizeof(TraceEvent::T raceEventHandle), TraceEventHandle_types_must_be_compatible); 41 COMPILE_ASSERT(sizeof(blink::Platform::TraceEventHandle) == sizeof(TraceEvent::T raceEventHandle), TraceEventHandle_types_must_be_compatible);
42 42
43 // The dummy variable is needed to avoid a crash when someone updates the state variables
44 // before EventTracer::initialize() is called.
45 long dummyTraceSamplingState = 0;
46 long* traceSamplingState[3] = {&dummyTraceSamplingState, &dummyTraceSamplingStat e, &dummyTraceSamplingState };
47
48 void EventTracer::initialize()
49 {
50 // current() might not exist in unit tests.
51 if (!blink::Platform::current())
52 return;
53
54 traceSamplingState[0] = blink::Platform::current()->getTraceSamplingState(0) ;
55 // FIXME: traceSamplingState[0] can be 0 in split-dll build. http://crbug.co m/256965
56 if (!traceSamplingState[0])
57 traceSamplingState[0] = &dummyTraceSamplingState;
58 traceSamplingState[1] = blink::Platform::current()->getTraceSamplingState(1) ;
59 if (!traceSamplingState[1])
60 traceSamplingState[1] = &dummyTraceSamplingState;
61 traceSamplingState[2] = blink::Platform::current()->getTraceSamplingState(2) ;
62 if (!traceSamplingState[2])
63 traceSamplingState[2] = &dummyTraceSamplingState;
64 }
65
66 const unsigned char* EventTracer::getTraceCategoryEnabledFlag(const char* catego ryName) 43 const unsigned char* EventTracer::getTraceCategoryEnabledFlag(const char* catego ryName)
67 { 44 {
68 static const char* dummyCategoryEnabledFlag = "*"; 45 static const char* dummyCategoryEnabledFlag = "*";
69 // current() might not exist in unit tests. 46 // current() might not exist in unit tests.
70 if (!blink::Platform::current()) 47 if (!blink::Platform::current())
71 return reinterpret_cast<const unsigned char*>(dummyCategoryEnabledFlag); 48 return reinterpret_cast<const unsigned char*>(dummyCategoryEnabledFlag);
72 49
73 return blink::Platform::current()->getTraceCategoryEnabledFlag(categoryName) ; 50 return blink::Platform::current()->getTraceCategoryEnabledFlag(categoryName) ;
74 } 51 }
75 52
(...skipping 22 matching lines...) Expand all
98 { 75 {
99 return blink::Platform::current()->addTraceEvent(phase, categoryEnabledFlag, name, id, numArgs, argNames, argTypes, argValues, 0, flags); 76 return blink::Platform::current()->addTraceEvent(phase, categoryEnabledFlag, name, id, numArgs, argNames, argTypes, argValues, 0, flags);
100 } 77 }
101 78
102 void EventTracer::updateTraceEventDuration(const unsigned char* categoryEnabledF lag, const char* name, TraceEvent::TraceEventHandle handle) 79 void EventTracer::updateTraceEventDuration(const unsigned char* categoryEnabledF lag, const char* name, TraceEvent::TraceEventHandle handle)
103 { 80 {
104 blink::Platform::current()->updateTraceEventDuration(categoryEnabledFlag, na me, handle); 81 blink::Platform::current()->updateTraceEventDuration(categoryEnabledFlag, na me, handle);
105 } 82 }
106 83
107 } // namespace blink 84 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/platform/EventTracer.h ('k') | sky/engine/platform/testing/RunAllTests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698