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

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

Issue 2555013004: UserGestureIndicator: remove many unnecessary calls to isMainThread (Closed)
Patch Set: remove bad comment (trybots prev) 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 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 double m_timestamp; 87 double m_timestamp;
88 TimeoutPolicy m_timeoutPolicy; 88 TimeoutPolicy m_timeoutPolicy;
89 UserGestureUtilizedCallback* m_usageCallback; 89 UserGestureUtilizedCallback* m_usageCallback;
90 }; 90 };
91 91
92 class PLATFORM_EXPORT UserGestureIndicator final { 92 class PLATFORM_EXPORT UserGestureIndicator final {
93 USING_FAST_MALLOC(UserGestureIndicator); 93 USING_FAST_MALLOC(UserGestureIndicator);
94 WTF_MAKE_NONCOPYABLE(UserGestureIndicator); 94 WTF_MAKE_NONCOPYABLE(UserGestureIndicator);
95 95
96 public: 96 public:
97 // Note: All *ThreadSafe methods are safe to call from any thread. Their
98 // non-suffixed counterparts *must* be called on the main thread.
kinuko 2016/12/12 14:51:26 Let's add: "Consider always using the non-suffixed
Charlie Harrison 2016/12/12 15:20:47 Done.
99
97 // Returns whether a user gesture is currently in progress. 100 // Returns whether a user gesture is currently in progress.
98 // Does not invoke the UserGestureUtilizedCallback. Consider calling 101 // Does not invoke the UserGestureUtilizedCallback. Consider calling
99 // utilizeUserGesture instead if you know for sure that the return value 102 // utilizeUserGesture instead if you know for sure that the return value
100 // will have an effect. 103 // will have an effect.
101 static bool processingUserGesture(); 104 static bool processingUserGesture();
105 static bool processingUserGestureThreadSafe();
102 106
103 // Indicates that a user gesture (if any) is being used, without preventing it 107 // Indicates that a user gesture (if any) is being used, without preventing it
104 // from being used again. Returns whether a user gesture is currently in 108 // from being used again. Returns whether a user gesture is currently in
105 // progress. If true, invokes (and then clears) any 109 // progress. If true, invokes (and then clears) any
106 // UserGestureUtilizedCallback. 110 // UserGestureUtilizedCallback.
107 static bool utilizeUserGesture(); 111 static bool utilizeUserGesture();
108 112
109 // Mark the current user gesture (if any) as having been used, such that 113 // Mark the current user gesture (if any) as having been used, such that
110 // it cannot be used again. This is done only for very security-sensitive 114 // it cannot be used again. This is done only for very security-sensitive
111 // operations like creating a new process. 115 // operations like creating a new process.
112 // Like utilizeUserGesture, may invoke/clear any UserGestureUtilizedCallback. 116 // Like utilizeUserGesture, may invoke/clear any UserGestureUtilizedCallback.
113 static bool consumeUserGesture(); 117 static bool consumeUserGesture();
118 static bool consumeUserGestureThreadSafe();
kinuko 2016/12/12 04:45:12 We don't need this and currentTokenThreadSafe othe
Charlie Harrison 2016/12/12 13:10:09 We use currentTokenThreadSafe in DOMTimer, and we
Charlie Harrison 2016/12/12 15:20:47 I don't think this comment was properly resolved.
kinuko 2016/12/12 15:37:49 Sorry I hadn't explicitly responded to this one. I
114 119
115 static UserGestureToken* currentToken(); 120 static UserGestureToken* currentToken();
121 static UserGestureToken* currentTokenThreadSafe();
116 122
117 explicit UserGestureIndicator(PassRefPtr<UserGestureToken>); 123 explicit UserGestureIndicator(PassRefPtr<UserGestureToken>);
118 ~UserGestureIndicator(); 124 ~UserGestureIndicator();
119 125
120 private: 126 private:
121 static UserGestureToken* s_rootToken; 127 static UserGestureToken* s_rootToken;
122 128
123 RefPtr<UserGestureToken> m_token; 129 RefPtr<UserGestureToken> m_token;
124 }; 130 };
125 131
126 } // namespace blink 132 } // namespace blink
127 133
128 #endif 134 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698