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

Unified Diff: third_party/WebKit/Source/platform/UserGestureIndicator.cpp

Issue 2555013004: UserGestureIndicator: remove many unnecessary calls to isMainThread (Closed)
Patch Set: [test] remove isMainThread() check in currentToken() 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..3b9e17a6e10ef88d5ec8d2687aaa976043864ff6 100644
--- a/third_party/WebKit/Source/platform/UserGestureIndicator.cpp
+++ b/third_party/WebKit/Source/platform/UserGestureIndicator.cpp
@@ -42,8 +42,11 @@ UserGestureToken::UserGestureToken(Status status)
m_timestamp(WTF::currentTime()),
m_timeoutPolicy(Default),
m_usageCallback(nullptr) {
- if (status == NewGesture || !UserGestureIndicator::currentToken())
+ if (status == NewGesture ||
+ !UserGestureIndicator::currentToken(
+ UserGestureIndicator::CheckThreadState)) {
m_consumableGestures++;
+ }
}
bool UserGestureToken::hasGestures() const {
@@ -150,19 +153,15 @@ bool UserGestureIndicator::utilizeUserGesture() {
return false;
}
-bool UserGestureIndicator::processingUserGesture() {
- if (auto* token = currentToken()) {
- ASSERT(isMainThread());
+bool UserGestureIndicator::processingUserGesture(ThreadCheck threadCheck) {
+ if (auto* token = currentToken(threadCheck))
return token->hasGestures();
- }
-
return false;
}
// static
-bool UserGestureIndicator::consumeUserGesture() {
- if (auto* token = currentToken()) {
- ASSERT(isMainThread());
+bool UserGestureIndicator::consumeUserGesture(ThreadCheck threadCheck) {
+ if (auto* token = currentToken(threadCheck)) {
if (token->consumeGesture()) {
token->userGestureUtilized();
return true;
@@ -171,10 +170,10 @@ bool UserGestureIndicator::consumeUserGesture() {
return false;
}
-// static
-UserGestureToken* UserGestureIndicator::currentToken() {
- if (!isMainThread() || !s_rootToken)
+UserGestureToken* UserGestureIndicator::currentToken(ThreadCheck threadCheck) {
+ if (threadCheck == CheckThreadState && !isMainThread())
return nullptr;
+ DCHECK(isMainThread());
return s_rootToken;
}

Powered by Google App Engine
This is Rietveld 408576698