| 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 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/inspector/InspectorTaskRunner.h" | 6 #include "core/inspector/InspectorTaskRunner.h" |
| 7 | 7 |
| 8 #include "wtf/Deque.h" | 8 #include "wtf/Deque.h" |
| 9 #include "wtf/ThreadingPrimitives.h" | 9 #include "wtf/ThreadingPrimitives.h" |
| 10 #include <v8.h> | 10 #include <v8.h> |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 InspectorTaskRunner::IgnoreInterruptsScope::IgnoreInterruptsScope(InspectorTaskR
unner* taskRunner) |
| 15 : m_wasIgnoring(taskRunner->m_ignoreInterrupts) |
| 16 , m_taskRunner(taskRunner) |
| 17 { |
| 18 // There may be nested scopes e.g. when tasks are being executed on XHR brea
kpoint. |
| 19 m_taskRunner->m_ignoreInterrupts = true; |
| 20 } |
| 21 |
| 22 InspectorTaskRunner::IgnoreInterruptsScope::~IgnoreInterruptsScope() |
| 23 { |
| 24 m_taskRunner->m_ignoreInterrupts = m_wasIgnoring; |
| 25 } |
| 26 |
| 14 class InspectorTaskRunner::ThreadSafeTaskQueue { | 27 class InspectorTaskRunner::ThreadSafeTaskQueue { |
| 15 WTF_MAKE_NONCOPYABLE(ThreadSafeTaskQueue); | 28 WTF_MAKE_NONCOPYABLE(ThreadSafeTaskQueue); |
| 16 public: | 29 public: |
| 17 ThreadSafeTaskQueue() { } | 30 ThreadSafeTaskQueue() { } |
| 18 PassOwnPtr<Task> tryTake() | 31 PassOwnPtr<Task> tryTake() |
| 19 { | 32 { |
| 20 MutexLocker lock(m_mutex); | 33 MutexLocker lock(m_mutex); |
| 21 if (m_queue.isEmpty()) | 34 if (m_queue.isEmpty()) |
| 22 return nullptr; | 35 return nullptr; |
| 23 return m_queue.takeFirst(); | 36 return m_queue.takeFirst(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 75 |
| 63 void InspectorTaskRunner::v8InterruptCallback(v8::Isolate*, void* data) | 76 void InspectorTaskRunner::v8InterruptCallback(v8::Isolate*, void* data) |
| 64 { | 77 { |
| 65 InspectorTaskRunner* runner = static_cast<InspectorTaskRunner*>(data); | 78 InspectorTaskRunner* runner = static_cast<InspectorTaskRunner*>(data); |
| 66 if (runner->m_ignoreInterrupts) | 79 if (runner->m_ignoreInterrupts) |
| 67 return; | 80 return; |
| 68 runner->runPendingTasks(); | 81 runner->runPendingTasks(); |
| 69 } | 82 } |
| 70 | 83 |
| 71 } | 84 } |
| OLD | NEW |