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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/shared_impl/id_assignment.h
===================================================================
--- ppapi/shared_impl/id_assignment.h (revision 0)
+++ ppapi/shared_impl/id_assignment.h (revision 0)
@@ -0,0 +1,40 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_SHARED_IMPL_ID_ASSIGNMENT_H_
+#define PPAPI_SHARED_IMPL_ID_ASSIGNMENT_H_
+
+#include <limits>
+
+#include "base/basictypes.h"
+
+namespace ppapi {
+
+enum PPIdType {
+ PP_ID_TYPE_MODULE,
+ PP_ID_TYPE_INSTANCE,
+ PP_ID_TYPE_RESOURCE,
+ PP_ID_TYPE_VAR,
+ PP_ID_TYPE_COUNT
dmichael (off chromium) 2011/08/08 22:13:59 Can you comment a little about COUNT not being a r
+};
+
+extern const unsigned int kPPIdTypeBits;
+
+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
+
+template <typename T> inline T MakeTypedId(T value, PPIdType type) {
+ 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
+}
+
+template <typename T> inline bool CheckIdType(T id, PPIdType type) {
+ // 0 is a valid resource.
dmichael (off chromium) 2011/08/08 22:13:59 Apparently, 0 is also a valid Var, Instance, and M
+ if (!id)
+ return true;
+ const T mask = (static_cast<T>(1) << kPPIdTypeBits) - 1;
+ return (id & mask) == type;
+}
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_ID_ASSIGNMENT_H_
Property changes on: ppapi/shared_impl/id_assignment.h
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698