| 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 SafePoint_h | 5 #ifndef SafePoint_h |
| 6 #define SafePoint_h | 6 #define SafePoint_h |
| 7 | 7 |
| 8 #include "platform/heap/ThreadState.h" | 8 #include "platform/heap/ThreadState.h" |
| 9 #include "wtf/ThreadingPrimitives.h" | 9 #include "platform/wtf/ThreadingPrimitives.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class SafePointScope final { | 13 class SafePointScope final { |
| 14 STACK_ALLOCATED(); | 14 STACK_ALLOCATED(); |
| 15 WTF_MAKE_NONCOPYABLE(SafePointScope); | 15 WTF_MAKE_NONCOPYABLE(SafePointScope); |
| 16 | 16 |
| 17 public: | 17 public: |
| 18 explicit SafePointScope(BlinkGC::StackState stackState, | 18 explicit SafePointScope(BlinkGC::StackState stackState, |
| 19 ThreadState* state = ThreadState::current()) | 19 ThreadState* state = ThreadState::current()) |
| 20 : m_state(state) { | 20 : m_state(state) { |
| 21 if (m_state) { | 21 if (m_state) { |
| 22 m_state->enterSafePoint(stackState, this); | 22 m_state->enterSafePoint(stackState, this); |
| 23 } | 23 } |
| 24 } | 24 } |
| 25 | 25 |
| 26 ~SafePointScope() { | 26 ~SafePointScope() { |
| 27 if (m_state) | 27 if (m_state) |
| 28 m_state->leaveSafePoint(); | 28 m_state->leaveSafePoint(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 ThreadState* m_state; | 32 ThreadState* m_state; |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 } // namespace blink | 35 } // namespace blink |
| 36 | 36 |
| 37 #endif | 37 #endif |
| OLD | NEW |