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

Side by Side Diff: ppapi/shared_impl/id_assignment.h

Issue 7578001: Unify var tracking between webkit and the proxy. (Closed) Base URL: svn://chrome-svn/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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef PPAPI_SHARED_IMPL_ID_ASSIGNMENT_H_
6 #define PPAPI_SHARED_IMPL_ID_ASSIGNMENT_H_
7
8 #include <limits>
9
10 #include "base/basictypes.h"
11
12 namespace ppapi {
13
14 enum PPIdType {
15 PP_ID_TYPE_MODULE,
16 PP_ID_TYPE_INSTANCE,
17 PP_ID_TYPE_RESOURCE,
18 PP_ID_TYPE_VAR,
19 PP_ID_TYPE_COUNT
dmichael (off chromium) 2011/08/08 22:13:59 Can you comment a little about COUNT not being a r
20 };
21
22 extern const unsigned int kPPIdTypeBits;
23
24 extern const int32 kMaxPPIdType;
dmichael (off chromium) 2011/08/08 22:13:59 Why does this assume int32, but the functions are
brettw 2011/08/09 17:08:09 I think this is because this is old code and resou
25
26 template <typename T> inline T MakeTypedId(T value, PPIdType type) {
27 return (value << kPPIdTypeBits) | static_cast<T>(type);
dmichael (off chromium) 2011/08/08 22:13:59 So you use the least-significant bits for the type
28 }
29
30 template <typename T> inline bool CheckIdType(T id, PPIdType type) {
31 // 0 is a valid resource.
dmichael (off chromium) 2011/08/08 22:13:59 Apparently, 0 is also a valid Var, Instance, and M
32 if (!id)
33 return true;
34 const T mask = (static_cast<T>(1) << kPPIdTypeBits) - 1;
35 return (id & mask) == type;
36 }
37
38 } // namespace ppapi
39
40 #endif // PPAPI_SHARED_IMPL_ID_ASSIGNMENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698