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

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

Issue 2483983002: [Blink] Check thread access in UserGestureIndicator (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 int sample = 0; 111 int sample = 0;
112 if (oldToken.hasGestures()) 112 if (oldToken.hasGestures())
113 sample |= OldTokenHasGesture; 113 sample |= OldTokenHasGesture;
114 if (newToken.hasGestures()) 114 if (newToken.hasGestures())
115 sample |= NewTokenHasGesture; 115 sample |= NewTokenHasGesture;
116 gestureMergeHistogram.count(sample); 116 gestureMergeHistogram.count(sample);
117 } 117 }
118 118
119 UserGestureToken* UserGestureIndicator::s_rootToken = nullptr; 119 UserGestureToken* UserGestureIndicator::s_rootToken = nullptr;
120 120
121 UserGestureIndicator::UserGestureIndicator(PassRefPtr<UserGestureToken> token) 121 UserGestureIndicator::UserGestureIndicator(PassRefPtr<UserGestureToken> token) {
122 : m_token(token == s_rootToken ? nullptr : token.get()) { 122 // Silently ignore UserGestureIndicators on non-main threads and tokens that
123 // Silently ignore UserGestureIndicators on non-main threads. 123 // are already active.
124 if (!isMainThread() || !m_token) 124 if (!isMainThread() || !token || token == s_rootToken)
125 return; 125 return;
126 126
127 m_token = token;
127 if (!s_rootToken) { 128 if (!s_rootToken) {
128 s_rootToken = m_token.get(); 129 s_rootToken = m_token.get();
129 } else { 130 } else {
130 RecordUserGestureMerge(*s_rootToken, *m_token); 131 RecordUserGestureMerge(*s_rootToken, *m_token);
131 m_token->transferGestureTo(s_rootToken); 132 m_token->transferGestureTo(s_rootToken);
132 } 133 }
133 m_token->resetTimestamp(); 134 m_token->resetTimestamp();
134 } 135 }
135 136
136 UserGestureIndicator::~UserGestureIndicator() { 137 UserGestureIndicator::~UserGestureIndicator() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 172 }
172 173
173 // static 174 // static
174 UserGestureToken* UserGestureIndicator::currentToken() { 175 UserGestureToken* UserGestureIndicator::currentToken() {
175 if (!isMainThread() || !s_rootToken) 176 if (!isMainThread() || !s_rootToken)
176 return nullptr; 177 return nullptr;
177 return s_rootToken; 178 return s_rootToken;
178 } 179 }
179 180
180 } // namespace blink 181 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698