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

Unified Diff: Source/platform/PluginScriptForbiddenScope.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: Rename static counter 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
« no previous file with comments | « Source/platform/PluginScriptForbiddenScope.h ('k') | Source/platform/blink_platform.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/PluginScriptForbiddenScope.cpp
diff --git a/Source/platform/PluginScriptForbiddenScope.cpp b/Source/platform/PluginScriptForbiddenScope.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..64c1271ce25fa5ba68d81b863fd59f04a46e451d
--- /dev/null
+++ b/Source/platform/PluginScriptForbiddenScope.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/PluginScriptForbiddenScope.h"
+
+#include "wtf/Assertions.h"
+#include "wtf/MainThread.h"
+
+namespace blink {
+
+static unsigned s_pluginScriptForbiddenCount = 0;
+
+PluginScriptForbiddenScope::PluginScriptForbiddenScope()
+{
+ ASSERT(isMainThread());
+ ++s_pluginScriptForbiddenCount;
+}
+
+PluginScriptForbiddenScope::~PluginScriptForbiddenScope()
+{
+ ASSERT(isMainThread());
+ ASSERT(s_pluginScriptForbiddenCount);
+ --s_pluginScriptForbiddenCount;
+}
+
+bool PluginScriptForbiddenScope::isForbidden()
+{
+ ASSERT(isMainThread());
+ return s_pluginScriptForbiddenCount > 0;
+}
+
+} // namespace blink
« no previous file with comments | « Source/platform/PluginScriptForbiddenScope.h ('k') | Source/platform/blink_platform.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698