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

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

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 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 enum ThreadCheck {
98 CheckThreadState,
99 DoNotCheckThreadState,
100 };
101
97 // Returns whether a user gesture is currently in progress. 102 // Returns whether a user gesture is currently in progress.
98 // Does not invoke the UserGestureUtilizedCallback. Consider calling 103 // Does not invoke the UserGestureUtilizedCallback. Consider calling
99 // utilizeUserGesture instead if you know for sure that the return value 104 // utilizeUserGesture instead if you know for sure that the return value
100 // will have an effect. 105 // will have an effect.
101 static bool processingUserGesture(); 106 static bool processingUserGesture(ThreadCheck = DoNotCheckThreadState);
kinuko 2016/12/09 03:15:51 I slightly prefer having processingUserGestureThre
Charlie Harrison 2016/12/09 15:24:14 Do you feel that way for all the methods? i.e. sho
102 107
103 // Indicates that a user gesture (if any) is being used, without preventing it 108 // 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 109 // from being used again. Returns whether a user gesture is currently in
105 // progress. If true, invokes (and then clears) any 110 // progress. If true, invokes (and then clears) any
106 // UserGestureUtilizedCallback. 111 // UserGestureUtilizedCallback.
107 static bool utilizeUserGesture(); 112 static bool utilizeUserGesture();
kinuko 2016/12/09 03:15:51 Should this also check ThreadCheck?
Charlie Harrison 2016/12/09 15:24:14 If we go with the enum approach, sure. Otherwise I
108 113
109 // Mark the current user gesture (if any) as having been used, such that 114 // 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 115 // it cannot be used again. This is done only for very security-sensitive
111 // operations like creating a new process. 116 // operations like creating a new process.
112 // Like utilizeUserGesture, may invoke/clear any UserGestureUtilizedCallback. 117 // Like utilizeUserGesture, may invoke/clear any UserGestureUtilizedCallback.
113 static bool consumeUserGesture(); 118 static bool consumeUserGesture(ThreadCheck = DoNotCheckThreadState);
114 119
115 static UserGestureToken* currentToken(); 120 static UserGestureToken* currentToken(ThreadCheck = DoNotCheckThreadState);
116 121
117 explicit UserGestureIndicator(PassRefPtr<UserGestureToken>); 122 explicit UserGestureIndicator(PassRefPtr<UserGestureToken>);
118 ~UserGestureIndicator(); 123 ~UserGestureIndicator();
119 124
120 private: 125 private:
121 static UserGestureToken* s_rootToken; 126 static UserGestureToken* s_rootToken;
122 127
123 RefPtr<UserGestureToken> m_token; 128 RefPtr<UserGestureToken> m_token;
124 }; 129 };
125 130
126 } // namespace blink 131 } // namespace blink
127 132
128 #endif 133 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698