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