Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2250)

Unified Diff: Source/platform/ReentrantScriptForbiddenScope.cpp

Issue 1170413003: Add a scoping object to help block scripting during plugin destruction. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698