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

Side by Side Diff: ppapi/thunk/enter.h

Issue 2762513002: Remove keep-alive impulse IPCs from NaCl modules. (Closed)
Patch Set: Rebase Created 3 years, 8 months 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 | « ppapi/tests/extensions/background_keepalive/background.js ('k') | ppapi/thunk/enter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PPAPI_THUNK_ENTER_H_ 5 #ifndef PPAPI_THUNK_ENTER_H_
6 #define PPAPI_THUNK_ENTER_H_ 6 #define PPAPI_THUNK_ENTER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 void* object, 141 void* object,
142 bool report_error); 142 bool report_error);
143 143
144 // Same as SetStateForResourceError except for function API. 144 // Same as SetStateForResourceError except for function API.
145 void SetStateForFunctionError(PP_Instance pp_instance, 145 void SetStateForFunctionError(PP_Instance pp_instance,
146 void* object, 146 void* object,
147 bool report_error); 147 bool report_error);
148 148
149 // For Enter objects that need a resource, we'll store a pointer to the 149 // For Enter objects that need a resource, we'll store a pointer to the
150 // Resource object so that we don't need to look it up more than once. For 150 // Resource object so that we don't need to look it up more than once. For
151 // Enter objects with no resource, this will be NULL. 151 // Enter objects with no resource, this will be null.
152 Resource* resource_; 152 Resource* resource_ = nullptr;
153 153
154 private: 154 private:
155 bool CallbackIsValid() const; 155 bool CallbackIsValid() const;
156 156
157 // Checks whether the callback is valid (i.e., if it is either non-blocking, 157 // Checks whether the callback is valid (i.e., if it is either non-blocking,
158 // or blocking and we're on a background thread). If the callback is invalid, 158 // or blocking and we're on a background thread). If the callback is invalid,
159 // this will set retval_ = PP_ERROR_BLOCKS_MAIN_THREAD, and if report_error is 159 // this will set retval_ = PP_ERROR_BLOCKS_MAIN_THREAD, and if report_error is
160 // set, it will log a message to the programmer. 160 // set, it will log a message to the programmer.
161 void SetStateForCallbackError(bool report_error); 161 void SetStateForCallbackError(bool report_error);
162 162
163 // Holds the callback. For Enter objects that aren't given a callback, this 163 // Holds the callback. For Enter objects that aren't given a callback, this
164 // will be NULL. 164 // will be null.
165 scoped_refptr<TrackedCallback> callback_; 165 scoped_refptr<TrackedCallback> callback_;
166 166
167 int32_t retval_; 167 int32_t retval_ = PP_OK;
168 }; 168 };
169 169
170 } // namespace subtle 170 } // namespace subtle
171 171
172 // EnterResource --------------------------------------------------------------- 172 // EnterResource ---------------------------------------------------------------
173 173
174 template<typename ResourceT, bool lock_on_entry = true> 174 template<typename ResourceT, bool lock_on_entry = true>
175 class EnterResource 175 class EnterResource
176 : public subtle::LockOnEntry<lock_on_entry>, // Must be first; see above. 176 : public subtle::LockOnEntry<lock_on_entry>, // Must be first; see above.
177 public subtle::EnterBase { 177 public subtle::EnterBase {
(...skipping 10 matching lines...) Expand all
188 ~EnterResource() {} 188 ~EnterResource() {}
189 189
190 ResourceT* object() { return object_; } 190 ResourceT* object() { return object_; }
191 Resource* resource() { return resource_; } 191 Resource* resource() { return resource_; }
192 192
193 private: 193 private:
194 void Init(PP_Resource resource, bool report_error) { 194 void Init(PP_Resource resource, bool report_error) {
195 if (resource_) 195 if (resource_)
196 object_ = resource_->GetAs<ResourceT>(); 196 object_ = resource_->GetAs<ResourceT>();
197 else 197 else
198 object_ = NULL; 198 object_ = nullptr;
199 // Validate the resource (note, if both are wrong, we will return 199 // Validate the resource (note, if both are wrong, we will return
200 // PP_ERROR_BADRESOURCE; last in wins). 200 // PP_ERROR_BADRESOURCE; last in wins).
201 SetStateForResourceError(resource, resource_, object_, report_error); 201 SetStateForResourceError(resource, resource_, object_, report_error);
202 } 202 }
203 203
204 ResourceT* object_; 204 ResourceT* object_;
205 205
206 DISALLOW_COPY_AND_ASSIGN(EnterResource); 206 DISALLOW_COPY_AND_ASSIGN(EnterResource);
207 }; 207 };
208 208
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 }; 258 };
259 259
260 // EnterInstanceAPI ------------------------------------------------------------ 260 // EnterInstanceAPI ------------------------------------------------------------
261 261
262 template<typename ApiT, bool lock_on_entry = true> 262 template<typename ApiT, bool lock_on_entry = true>
263 class EnterInstanceAPI 263 class EnterInstanceAPI
264 : public subtle::LockOnEntry<lock_on_entry>, // Must be first; see above 264 : public subtle::LockOnEntry<lock_on_entry>, // Must be first; see above
265 public subtle::EnterBase { 265 public subtle::EnterBase {
266 public: 266 public:
267 explicit EnterInstanceAPI(PP_Instance instance) 267 explicit EnterInstanceAPI(PP_Instance instance)
268 : EnterBase(instance, ApiT::kSingletonResourceID), 268 : EnterBase(instance, ApiT::kSingletonResourceID) {
269 functions_(NULL) {
270 if (resource_) 269 if (resource_)
271 functions_ = resource_->GetAs<ApiT>(); 270 functions_ = resource_->GetAs<ApiT>();
272 SetStateForFunctionError(instance, functions_, true); 271 SetStateForFunctionError(instance, functions_, true);
273 } 272 }
274 EnterInstanceAPI(PP_Instance instance, 273 EnterInstanceAPI(PP_Instance instance, const PP_CompletionCallback& callback)
275 const PP_CompletionCallback& callback) 274 : EnterBase(instance, ApiT::kSingletonResourceID, callback) {
276 : EnterBase(instance, ApiT::kSingletonResourceID, callback),
277 functions_(NULL) {
278 if (resource_) 275 if (resource_)
279 functions_ = resource_->GetAs<ApiT>(); 276 functions_ = resource_->GetAs<ApiT>();
280 SetStateForFunctionError(instance, functions_, true); 277 SetStateForFunctionError(instance, functions_, true);
281 } 278 }
282 ~EnterInstanceAPI() {} 279 ~EnterInstanceAPI() {}
283 280
284 bool succeeded() const { return !!functions_; } 281 bool succeeded() const { return !!functions_; }
285 bool failed() const { return !functions_; } 282 bool failed() const { return !functions_; }
286 283
287 ApiT* functions() const { return functions_; } 284 ApiT* functions() const { return functions_; }
288 285
289 private: 286 private:
290 ApiT* functions_; 287 ApiT* functions_ = nullptr;
291 }; 288 };
292 289
293 template<typename ApiT> 290 template<typename ApiT>
294 class EnterInstanceAPINoLock : public EnterInstanceAPI<ApiT, false> { 291 class EnterInstanceAPINoLock : public EnterInstanceAPI<ApiT, false> {
295 public: 292 public:
296 explicit EnterInstanceAPINoLock(PP_Instance instance) 293 explicit EnterInstanceAPINoLock(PP_Instance instance)
297 : EnterInstanceAPI<ApiT, false>(instance) { 294 : EnterInstanceAPI<ApiT, false>(instance) {
298 } 295 }
299 }; 296 };
300 297
(...skipping 22 matching lines...) Expand all
323 ResourceCreationAPI* functions() { return functions_; } 320 ResourceCreationAPI* functions() { return functions_; }
324 321
325 private: 322 private:
326 ResourceCreationAPI* functions_; 323 ResourceCreationAPI* functions_;
327 }; 324 };
328 325
329 } // namespace thunk 326 } // namespace thunk
330 } // namespace ppapi 327 } // namespace ppapi
331 328
332 #endif // PPAPI_THUNK_ENTER_H_ 329 #endif // PPAPI_THUNK_ENTER_H_
OLDNEW
« no previous file with comments | « ppapi/tests/extensions/background_keepalive/background.js ('k') | ppapi/thunk/enter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698