Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / platform / EventDispatchForbiddenScope.h
blobed04351930f637ece70c7235e3b6231a1e87b5ee
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
3 // found in the LICENSE file.
5 #ifndef EventDispatchForbiddenScope_h
6 #define EventDispatchForbiddenScope_h
8 #include "platform/PlatformExport.h"
9 #include "wtf/Assertions.h"
10 #include "wtf/MainThread.h"
11 #include "wtf/TemporaryChange.h"
13 namespace blink {
15 #if ENABLE(ASSERT)
17 class EventDispatchForbiddenScope {
18 public:
19 EventDispatchForbiddenScope()
21 ASSERT(isMainThread());
22 ++s_count;
25 ~EventDispatchForbiddenScope()
27 ASSERT(isMainThread());
28 ASSERT(s_count);
29 --s_count;
32 static bool isEventDispatchForbidden()
34 if (!isMainThread())
35 return false;
36 return s_count;
39 class AllowUserAgentEvents {
40 public:
41 AllowUserAgentEvents()
42 : m_change(s_count, 0)
44 ASSERT(isMainThread());
47 ~AllowUserAgentEvents()
49 ASSERT(!s_count);
52 TemporaryChange<unsigned> m_change;
55 private:
56 PLATFORM_EXPORT static unsigned s_count;
59 #else
61 class EventDispatchForbiddenScope {
62 public:
63 EventDispatchForbiddenScope() { }
65 class AllowUserAgentEvents {
66 public:
67 AllowUserAgentEvents() { }
71 #endif // ENABLE(ASSERT)
73 } // namespace blink
75 #endif // EventDispatchForbiddenScope_h