| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 InspectorTaskRunner_h | 5 #ifndef InspectorTaskRunner_h |
| 6 #define InspectorTaskRunner_h | 6 #define InspectorTaskRunner_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "wtf/Allocator.h" |
| 10 #include "wtf/FastAllocBase.h" |
| 9 #include "wtf/Forward.h" | 11 #include "wtf/Forward.h" |
| 10 #include "wtf/Noncopyable.h" | 12 #include "wtf/Noncopyable.h" |
| 11 #include "wtf/OwnPtr.h" | 13 #include "wtf/OwnPtr.h" |
| 12 #include "wtf/PassOwnPtr.h" | 14 #include "wtf/PassOwnPtr.h" |
| 13 #include <v8.h> | 15 #include <v8.h> |
| 14 | 16 |
| 15 namespace blink { | 17 namespace blink { |
| 16 | 18 |
| 17 class CORE_EXPORT InspectorTaskRunner final { | 19 class CORE_EXPORT InspectorTaskRunner final { |
| 18 WTF_MAKE_NONCOPYABLE(InspectorTaskRunner); | 20 WTF_MAKE_NONCOPYABLE(InspectorTaskRunner); |
| 21 WTF_MAKE_FAST_ALLOCATED(InspectorTaskRunner); |
| 19 public: | 22 public: |
| 20 explicit InspectorTaskRunner(v8::Isolate*); | 23 explicit InspectorTaskRunner(v8::Isolate*); |
| 21 ~InspectorTaskRunner(); | 24 ~InspectorTaskRunner(); |
| 22 | 25 |
| 23 class Task { | 26 class Task { |
| 27 WTF_MAKE_FAST_ALLOCATED(Task); |
| 24 public: | 28 public: |
| 25 virtual ~Task() { } | 29 virtual ~Task() { } |
| 26 virtual void run() = 0; | 30 virtual void run() = 0; |
| 27 }; | 31 }; |
| 28 // This method can be called on any thread. It is caller's responsibility to
make sure that | 32 // This method can be called on any thread. It is caller's responsibility to
make sure that |
| 29 // this V8Debugger and corresponding v8::Isolate exist while this method is
running. | 33 // this V8Debugger and corresponding v8::Isolate exist while this method is
running. |
| 30 void interruptAndRun(PassOwnPtr<Task>); | 34 void interruptAndRun(PassOwnPtr<Task>); |
| 31 void runPendingTasks(); | 35 void runPendingTasks(); |
| 32 | 36 |
| 33 class CORE_EXPORT IgnoreInterruptsScope final { | 37 class CORE_EXPORT IgnoreInterruptsScope final { |
| 38 WTF_MAKE_FAST_ALLOCATED(IgnoreInterruptsScope); |
| 34 public: | 39 public: |
| 35 explicit IgnoreInterruptsScope(InspectorTaskRunner*); | 40 explicit IgnoreInterruptsScope(InspectorTaskRunner*); |
| 36 ~IgnoreInterruptsScope(); | 41 ~IgnoreInterruptsScope(); |
| 37 | 42 |
| 38 private: | 43 private: |
| 39 bool m_wasIgnoring; | 44 bool m_wasIgnoring; |
| 40 InspectorTaskRunner* m_taskRunner; | 45 InspectorTaskRunner* m_taskRunner; |
| 41 }; | 46 }; |
| 42 | 47 |
| 43 private: | 48 private: |
| 44 static void v8InterruptCallback(v8::Isolate*, void* data); | 49 static void v8InterruptCallback(v8::Isolate*, void* data); |
| 45 | 50 |
| 46 v8::Isolate* m_isolate; | 51 v8::Isolate* m_isolate; |
| 47 class ThreadSafeTaskQueue; | 52 class ThreadSafeTaskQueue; |
| 48 OwnPtr<ThreadSafeTaskQueue> m_taskQueue; | 53 OwnPtr<ThreadSafeTaskQueue> m_taskQueue; |
| 49 bool m_ignoreInterrupts; | 54 bool m_ignoreInterrupts; |
| 50 }; | 55 }; |
| 51 | 56 |
| 52 } // namespace blink | 57 } // namespace blink |
| 53 | 58 |
| 54 | 59 |
| 55 #endif // !defined(InspectorTaskRunner_h) | 60 #endif // !defined(InspectorTaskRunner_h) |
| OLD | NEW |