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

Side by Side Diff: third_party/WebKit/Source/platform/UserGestureIndicator.cpp

Issue 2408333004: Move persistent gesture state to Document, add DocumentUserGestureToken (Closed)
Patch Set: Re-add dropped null check Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 ("Blink.Gesture.Merged", GestureMergeStateEnd)); 107 ("Blink.Gesture.Merged", GestureMergeStateEnd));
108 int sample = 0; 108 int sample = 0;
109 if (oldToken.hasGestures()) 109 if (oldToken.hasGestures())
110 sample |= OldTokenHasGesture; 110 sample |= OldTokenHasGesture;
111 if (newToken.hasGestures()) 111 if (newToken.hasGestures())
112 sample |= NewTokenHasGesture; 112 sample |= NewTokenHasGesture;
113 gestureMergeHistogram.count(sample); 113 gestureMergeHistogram.count(sample);
114 } 114 }
115 115
116 UserGestureToken* UserGestureIndicator::s_rootToken = nullptr; 116 UserGestureToken* UserGestureIndicator::s_rootToken = nullptr;
117 bool UserGestureIndicator::s_processedUserGestureSinceLoad = false;
118 117
119 UserGestureIndicator::UserGestureIndicator(PassRefPtr<UserGestureToken> token) 118 UserGestureIndicator::UserGestureIndicator(PassRefPtr<UserGestureToken> token)
120 : m_token(token) { 119 : m_token(token) {
121 // Silently ignore UserGestureIndicators on non-main threads. 120 // Silently ignore UserGestureIndicators on non-main threads.
122 if (!isMainThread() || !m_token) 121 if (!isMainThread() || !m_token)
123 return; 122 return;
124 123
125 if (!s_rootToken) { 124 if (!s_rootToken) {
126 s_rootToken = m_token.get(); 125 s_rootToken = m_token.get();
127 } else { 126 } else {
128 RecordUserGestureMerge(*s_rootToken, *m_token); 127 RecordUserGestureMerge(*s_rootToken, *m_token);
129 m_token->transferGestureTo(s_rootToken); 128 m_token->transferGestureTo(s_rootToken);
130 } 129 }
131 s_processedUserGestureSinceLoad = true;
132 } 130 }
133 131
134 UserGestureIndicator::~UserGestureIndicator() { 132 UserGestureIndicator::~UserGestureIndicator() {
135 if (isMainThread() && m_token && m_token == s_rootToken) { 133 if (isMainThread() && m_token && m_token == s_rootToken) {
136 s_rootToken->setUserGestureUtilizedCallback(nullptr); 134 s_rootToken->setUserGestureUtilizedCallback(nullptr);
137 s_rootToken = nullptr; 135 s_rootToken = nullptr;
138 } 136 }
139 } 137 }
140 138
141 // static 139 // static
(...skipping 26 matching lines...) Expand all
168 return false; 166 return false;
169 } 167 }
170 168
171 // static 169 // static
172 UserGestureToken* UserGestureIndicator::currentToken() { 170 UserGestureToken* UserGestureIndicator::currentToken() {
173 if (!isMainThread() || !s_rootToken) 171 if (!isMainThread() || !s_rootToken)
174 return nullptr; 172 return nullptr;
175 return s_rootToken; 173 return s_rootToken;
176 } 174 }
177 175
178 // static
179 void UserGestureIndicator::clearProcessedUserGestureSinceLoad() {
180 if (isMainThread())
181 s_processedUserGestureSinceLoad = false;
182 }
183
184 // static
185 bool UserGestureIndicator::processedUserGestureSinceLoad() {
186 if (!isMainThread())
187 return false;
188 return s_processedUserGestureSinceLoad;
189 }
190
191 } // namespace blink 176 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698