| 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 EventDispatchForbiddenScope_h | 5 #ifndef EventDispatchForbiddenScope_h |
| 6 #define EventDispatchForbiddenScope_h | 6 #define EventDispatchForbiddenScope_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "wtf/Assertions.h" | 9 #include "wtf/Assertions.h" |
| 10 #include "wtf/MainThread.h" | 10 #include "wtf/MainThread.h" |
| 11 #include "wtf/TemporaryChange.h" | 11 #include "wtf/TemporaryChange.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 #if ENABLE(ASSERT) | 15 #if ENABLE(ASSERT) |
| 16 | 16 |
| 17 class EventDispatchForbiddenScope { | 17 class EventDispatchForbiddenScope { |
| 18 public: | 18 public: |
| 19 EventDispatchForbiddenScope() | 19 EventDispatchForbiddenScope() |
| 20 { | 20 { |
| 21 if (!isMainThread()) | 21 ASSERT(isMainThread()); |
| 22 return; | |
| 23 ++s_count; | 22 ++s_count; |
| 24 } | 23 } |
| 25 | 24 |
| 26 ~EventDispatchForbiddenScope() | 25 ~EventDispatchForbiddenScope() |
| 27 { | 26 { |
| 28 if (!isMainThread()) | 27 ASSERT(isMainThread()); |
| 29 return; | |
| 30 ASSERT(s_count); | 28 ASSERT(s_count); |
| 31 --s_count; | 29 --s_count; |
| 32 } | 30 } |
| 33 | 31 |
| 34 static bool isEventDispatchForbidden() | 32 static bool isEventDispatchForbidden() |
| 35 { | 33 { |
| 36 if (!isMainThread()) | 34 if (!isMainThread()) |
| 37 return false; | 35 return false; |
| 38 return s_count; | 36 return s_count; |
| 39 } | 37 } |
| 40 | 38 |
| 41 class AllowUserAgentEvents { | 39 class AllowUserAgentEvents { |
| 42 public: | 40 public: |
| 43 AllowUserAgentEvents() | 41 AllowUserAgentEvents() |
| 44 : m_change(s_count, 0) | 42 : m_change(s_count, 0) |
| 45 { | 43 { |
| 44 ASSERT(isMainThread()); |
| 46 } | 45 } |
| 47 | 46 |
| 48 ~AllowUserAgentEvents() | 47 ~AllowUserAgentEvents() |
| 49 { | 48 { |
| 50 ASSERT(!s_count); | 49 ASSERT(!s_count); |
| 51 } | 50 } |
| 52 | 51 |
| 53 TemporaryChange<unsigned> m_change; | 52 TemporaryChange<unsigned> m_change; |
| 54 }; | 53 }; |
| 55 | 54 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 67 public: | 66 public: |
| 68 AllowUserAgentEvents() { } | 67 AllowUserAgentEvents() { } |
| 69 }; | 68 }; |
| 70 }; | 69 }; |
| 71 | 70 |
| 72 #endif // ENABLE(ASSERT) | 71 #endif // ENABLE(ASSERT) |
| 73 | 72 |
| 74 } // namespace blink | 73 } // namespace blink |
| 75 | 74 |
| 76 #endif // EventDispatchForbiddenScope_h | 75 #endif // EventDispatchForbiddenScope_h |
| OLD | NEW |