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: ppapi/shared_impl/id_assignment.h

Issue 7687005: Create ppapi_proxy.dll. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/shared_impl/host_resource.h ('k') | ppapi/shared_impl/image_data_impl.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_SHARED_IMPL_ID_ASSIGNMENT_H_ 5 #ifndef PPAPI_SHARED_IMPL_ID_ASSIGNMENT_H_
6 #define PPAPI_SHARED_IMPL_ID_ASSIGNMENT_H_ 6 #define PPAPI_SHARED_IMPL_ID_ASSIGNMENT_H_
7 7
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "ppapi/shared_impl/ppapi_shared_export.h"
11 12
12 namespace ppapi { 13 namespace ppapi {
13 14
14 enum PPIdType { 15 enum PPIdType {
15 PP_ID_TYPE_MODULE, 16 PP_ID_TYPE_MODULE,
16 PP_ID_TYPE_INSTANCE, 17 PP_ID_TYPE_INSTANCE,
17 PP_ID_TYPE_RESOURCE, 18 PP_ID_TYPE_RESOURCE,
18 PP_ID_TYPE_VAR, 19 PP_ID_TYPE_VAR,
19 20
20 // Not a real type, must be last. 21 // Not a real type, must be last.
21 PP_ID_TYPE_COUNT 22 PP_ID_TYPE_COUNT
22 }; 23 };
23 24
24 extern const unsigned int kPPIdTypeBits; 25 PPAPI_SHARED_EXPORT extern const unsigned int kPPIdTypeBits;
25 26
26 extern const int32 kMaxPPId; 27 extern const int32 kMaxPPId;
27 28
28 // The most significant bits are the type, the rest are the value. 29 // The most significant bits are the type, the rest are the value.
29 template <typename T> inline T MakeTypedId(T value, PPIdType type) { 30 template <typename T> inline T MakeTypedId(T value, PPIdType type) {
30 return (value << kPPIdTypeBits) | static_cast<T>(type); 31 return (value << kPPIdTypeBits) | static_cast<T>(type);
31 } 32 }
32 33
33 template <typename T> inline bool CheckIdType(T id, PPIdType type) { 34 template <typename T> inline bool CheckIdType(T id, PPIdType type) {
34 // Say a resource of 0 is always valid, since that means "no resource." 35 // Say a resource of 0 is always valid, since that means "no resource."
35 // You shouldn't be passing 0 var, instance, or module IDs around so those 36 // You shouldn't be passing 0 var, instance, or module IDs around so those
36 // are still invalid. 37 // are still invalid.
37 if (type == PP_ID_TYPE_RESOURCE && !id) 38 if (type == PP_ID_TYPE_RESOURCE && !id)
38 return true; 39 return true;
39 const T mask = (static_cast<T>(1) << kPPIdTypeBits) - 1; 40 const T mask = (static_cast<T>(1) << kPPIdTypeBits) - 1;
40 return (id & mask) == type; 41 return (id & mask) == type;
41 } 42 }
42 43
43 } // namespace ppapi 44 } // namespace ppapi
44 45
45 #endif // PPAPI_SHARED_IMPL_ID_ASSIGNMENT_H_ 46 #endif // PPAPI_SHARED_IMPL_ID_ASSIGNMENT_H_
OLDNEW
« no previous file with comments | « ppapi/shared_impl/host_resource.h ('k') | ppapi/shared_impl/image_data_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698