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

Unified Diff: third_party/WebKit/Source/platform/ScriptForbiddenScope.h

Issue 1502093002: Improve ScriptForbiddenScope handling in cross-threaded code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased up past r363426 Created 5 years 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: third_party/WebKit/Source/platform/ScriptForbiddenScope.h
diff --git a/third_party/WebKit/Source/platform/ScriptForbiddenScope.h b/third_party/WebKit/Source/platform/ScriptForbiddenScope.h
index 9c3ba7e8f5dda74bb6ab5445c065f6fecf9b7b77..db7bc6b3e1e62776f0f047c092b254ff61aa839d 100644
--- a/third_party/WebKit/Source/platform/ScriptForbiddenScope.h
+++ b/third_party/WebKit/Source/platform/ScriptForbiddenScope.h
@@ -6,13 +6,16 @@
#define ScriptForbiddenScope_h
#include "platform/PlatformExport.h"
-#include "wtf/Assertions.h"
+#include "wtf/Allocator.h"
#include "wtf/Optional.h"
#include "wtf/TemporaryChange.h"
namespace blink {
+// Scoped disabling of script execution on the main thread,
+// and only to be used by the main thread.
class PLATFORM_EXPORT ScriptForbiddenScope {
+ STACK_ALLOCATED();
public:
ScriptForbiddenScope();
~ScriptForbiddenScope();
@@ -30,6 +33,20 @@ public:
static bool isScriptForbidden();
};
+// Scoped disabling of script execution on the main thread,
+// if called on the main thread.
+//
+// No effect when used by from other threads -- simplifies
+// call sites that might be used by multiple threads to have
+// this scope object perform the is-main-thread check on
+// its behalf.
+class PLATFORM_EXPORT ScriptForbiddenIfMainThreadScope {
+ STACK_ALLOCATED();
+public:
+ ScriptForbiddenIfMainThreadScope();
+ ~ScriptForbiddenIfMainThreadScope();
+};
+
} // namespace blink
#endif // ScriptForbiddenScope_h

Powered by Google App Engine
This is Rietveld 408576698