Index: Source/platform/ReentrantScriptForbiddenScope.cpp |
diff --git a/Source/platform/ReentrantScriptForbiddenScope.cpp b/Source/platform/ReentrantScriptForbiddenScope.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c2a4c135e9d3c792745b7adcfb955dcbdb4895eb |
--- /dev/null |
+++ b/Source/platform/ReentrantScriptForbiddenScope.cpp |
@@ -0,0 +1,34 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "platform/ReentrantScriptForbiddenScope.h" |
+ |
+#include "wtf/Assertions.h" |
+#include "wtf/MainThread.h" |
+ |
+namespace blink { |
+ |
+static unsigned s_reentrantScriptForbiddenCount = 0; |
+ |
+ReentrantScriptForbiddenScope::ReentrantScriptForbiddenScope() |
+{ |
+ ASSERT(isMainThread()); |
+ ++s_reentrantScriptForbiddenCount; |
+} |
+ |
+ReentrantScriptForbiddenScope::~ReentrantScriptForbiddenScope() |
+{ |
+ ASSERT(isMainThread()); |
+ ASSERT(s_reentrantScriptForbiddenCount); |
+ --s_reentrantScriptForbiddenCount; |
+} |
+ |
+bool ReentrantScriptForbiddenScope::isForbidden() |
+{ |
+ ASSERT(isMainThread()); |
+ return s_reentrantScriptForbiddenCount > 0; |
+} |
+ |
+} // namespace blink |