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

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
« no previous file with comments | « ppapi/proxy/serialized_var_unittest.cc ('k') | ppapi/shared_impl/id_assignment.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,45 @@
+// 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,
+
+ // Not a real type, must be last.
+ PP_ID_TYPE_COUNT
+};
+
+extern const unsigned int kPPIdTypeBits;
+
+extern const int32 kMaxPPId;
+
+// The most significant bits are the type, the rest are the value.
+template <typename T> inline T MakeTypedId(T value, PPIdType type) {
+ return (value << kPPIdTypeBits) | static_cast<T>(type);
+}
+
+template <typename T> inline bool CheckIdType(T id, PPIdType type) {
+ // Say a resource of 0 is always valid, since that means "no resource."
+ // You shouldn't be passing 0 var, instance, or module IDs around so those
+ // are still invalid.
+ if (type == PP_ID_TYPE_RESOURCE && !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
« no previous file with comments | « ppapi/proxy/serialized_var_unittest.cc ('k') | ppapi/shared_impl/id_assignment.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698