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

Unified Diff: third_party/WebKit/Source/core/frame/DOMTimer.cpp

Issue 2555013004: UserGestureIndicator: remove many unnecessary calls to isMainThread (Closed)
Patch Set: Avoid duplicate thread checks in DOMTimer Created 4 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/core/frame/DOMTimer.cpp
diff --git a/third_party/WebKit/Source/core/frame/DOMTimer.cpp b/third_party/WebKit/Source/core/frame/DOMTimer.cpp
index a6140804ca9f54ac1a5eb73cb73cc82aa0a5ac0c..492982f4a7867858e02ecafb3ed86e29599c79ef 100644
--- a/third_party/WebKit/Source/core/frame/DOMTimer.cpp
+++ b/third_party/WebKit/Source/core/frame/DOMTimer.cpp
@@ -47,7 +47,7 @@ static const double oneMillisecond = 0.001;
static const double minimumInterval = 0.004;
static inline bool shouldForwardUserGesture(int interval, int nestingLevel) {
- return UserGestureIndicator::processingUserGesture() &&
+ return UserGestureIndicator::processingUserGestureThreadSafe() &&
interval <= maxIntervalForUserGestureForwarding &&
nestingLevel ==
1; // Gestures should not be forwarded to nested timers.
@@ -90,8 +90,11 @@ DOMTimer::DOMTimer(ExecutionContext* context,
m_nestingLevel(context->timers()->timerNestingLevel() + 1),
m_action(action) {
ASSERT(timeoutID > 0);
- if (shouldForwardUserGesture(interval, m_nestingLevel))
+ if (shouldForwardUserGesture(interval, m_nestingLevel)) {
+ // Thread safe because shouldForwardUserGesture will only return true if
+ // execution is on the the main thread.
m_userGestureToken = UserGestureIndicator::currentToken();
+ }
InspectorInstrumentation::asyncTaskScheduled(
context, singleShot ? "setTimeout" : "setInterval", this, !singleShot);
« no previous file with comments | « extensions/renderer/request_sender.cc ('k') | third_party/WebKit/Source/modules/permissions/Permissions.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698