OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium 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 TracedTask_h | 5 #ifndef TracedTask_h |
6 #define TracedTask_h | 6 #define TracedTask_h |
7 | 7 |
8 #include "platform/Task.h" | 8 #include "platform/Task.h" |
9 #include "platform/TraceEvent.h" | 9 #include "platform/TraceEvent.h" |
10 #include "platform/TraceLocation.h" | 10 #include "platform/TraceLocation.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
| 13 namespace internal { |
13 | 14 |
14 #ifdef MANGLE_COMPILES_ON_WIN_OK | 15 #ifdef MANGLE_COMPILES_ON_WIN_OK |
15 // TODO: Once win version compiles correctly when using TRACE_ID_MANGLE remove | 16 // TODO: Once win version compiles correctly when using TRACE_ID_MANGLE remove |
16 // the ifdef to always mangle | 17 // the ifdef to always mangle |
17 #define MANGLE(id) TRACE_ID_MANGLE(id) | 18 #define MANGLE(id) TRACE_ID_MANGLE(id) |
18 #else | 19 #else |
19 #define MANGLE(id) (id) | 20 #define MANGLE(id) (id) |
20 #endif | 21 #endif |
21 | 22 |
22 class TracedTask { | 23 class TracedTask { |
23 public: | 24 public: |
24 typedef Function<void()> Task; | 25 virtual void run() const = 0; |
| 26 virtual ~TracedTask(); |
25 | 27 |
26 void run() const; | 28 protected: |
| 29 TracedTask(const TraceLocation&, const char* traceName); |
| 30 TraceLocation getLocation() const; |
| 31 const char* getTraceName() const; |
| 32 void endFlowTraceEvent() const; |
27 | 33 |
28 private: | 34 private: |
29 friend class Scheduler; | |
30 TracedTask(const Task&, const TraceLocation&, const char* traceName); | |
31 | |
32 // Declared volatile as it is atomically incremented. | 35 // Declared volatile as it is atomically incremented. |
33 static volatile int s_nextFlowTraceID; | 36 static volatile int s_nextFlowTraceID; |
34 | 37 |
35 uint64_t m_flowTraceID; | 38 uint64_t m_flowTraceID; |
36 Task m_task; | |
37 TraceLocation m_location; | 39 TraceLocation m_location; |
38 const char* m_traceName; | 40 const char* m_traceName; |
39 }; | 41 }; |
40 | 42 |
| 43 class TracedStandardTask : public TracedTask { |
| 44 public: |
| 45 typedef Function<void()> Task; |
| 46 |
| 47 static PassOwnPtr<TracedStandardTask> Create(const Task&, const TraceLocatio
n&, const char* traceName); |
| 48 virtual void run() const; |
| 49 virtual ~TracedStandardTask(); |
| 50 |
| 51 private: |
| 52 TracedStandardTask(const Task&, const TraceLocation&, const char* traceName)
; |
| 53 Task m_task; |
| 54 }; |
| 55 |
| 56 class TracedIdleTask : public TracedTask { |
| 57 public: |
| 58 typedef Function<void(double deadlineSeconds)> IdleTask; |
| 59 |
| 60 static PassOwnPtr<TracedIdleTask> Create(const IdleTask&, const TraceLocatio
n&, const char* traceName); |
| 61 virtual void run() const; |
| 62 virtual ~TracedIdleTask(); |
| 63 |
| 64 private: |
| 65 TracedIdleTask(const IdleTask&, const TraceLocation&, const char* traceName)
; |
| 66 IdleTask m_idleTask; |
| 67 }; |
| 68 |
| 69 } // namespace internal |
41 } // namespace blink | 70 } // namespace blink |
42 | 71 |
43 #endif // TracedTask_h | 72 #endif // TracedTask_h |
OLD | NEW |