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

Unified Diff: third_party/WebKit/Source/platform/UserGestureIndicator.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/platform/UserGestureIndicator.cpp
diff --git a/third_party/WebKit/Source/platform/UserGestureIndicator.cpp b/third_party/WebKit/Source/platform/UserGestureIndicator.cpp
index 84433950de11762274b42ad1da528f1b40838d11..631145827362f2a19b324126f2feb653a7645af7 100644
--- a/third_party/WebKit/Source/platform/UserGestureIndicator.cpp
+++ b/third_party/WebKit/Source/platform/UserGestureIndicator.cpp
@@ -42,7 +42,7 @@ UserGestureToken::UserGestureToken(Status status)
m_timestamp(WTF::currentTime()),
m_timeoutPolicy(Default),
m_usageCallback(nullptr) {
- if (status == NewGesture || !UserGestureIndicator::currentToken())
+ if (status == NewGesture || !UserGestureIndicator::currentTokenThreadSafe())
m_consumableGestures++;
}
@@ -151,18 +151,18 @@ bool UserGestureIndicator::utilizeUserGesture() {
}
bool UserGestureIndicator::processingUserGesture() {
- if (auto* token = currentToken()) {
- ASSERT(isMainThread());
+ if (auto* token = currentToken())
return token->hasGestures();
- }
-
return false;
}
+bool UserGestureIndicator::processingUserGestureThreadSafe() {
+ return isMainThread() && processingUserGesture();
+}
+
// static
bool UserGestureIndicator::consumeUserGesture() {
if (auto* token = currentToken()) {
- ASSERT(isMainThread());
if (token->consumeGesture()) {
token->userGestureUtilized();
return true;
@@ -171,11 +171,17 @@ bool UserGestureIndicator::consumeUserGesture() {
return false;
}
-// static
+bool UserGestureIndicator::consumeUserGestureThreadSafe() {
+ return isMainThread() && consumeUserGesture();
+}
+
UserGestureToken* UserGestureIndicator::currentToken() {
- if (!isMainThread() || !s_rootToken)
- return nullptr;
+ DCHECK(isMainThread());
return s_rootToken;
}
+UserGestureToken* UserGestureIndicator::currentTokenThreadSafe() {
+ return isMainThread() ? currentToken() : nullptr;
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/UserGestureIndicator.h ('k') | third_party/WebKit/Source/web/WebUserGestureIndicator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698