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

Unified Diff: ipc/ipc_message_utils.h

Issue 1496103002: Reusing base::IdType<...> to implement SurfaceId. Base URL: https://chromium.googlesource.com/chromium/src.git@type-safe-id-base
Patch Set: Created 5 years 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 | « content/renderer/render_frame_proxy.h ('k') | mojo/converters/surfaces/surfaces_type_converters.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_message_utils.h
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h
index 97b95e986a9237ee881594416e93ebefbf99b875..567e89d9f7a0400718d01fc73f0d4bb3cc55fd06 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -17,6 +17,7 @@
#include "base/containers/stack_container.h"
#include "base/files/file.h"
#include "base/format_macros.h"
+#include "base/id_type.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/strings/string16.h"
@@ -858,6 +859,31 @@ struct ParamTraits<scoped_ptr<P> > {
}
};
+template <typename TypeBeingIdentified,
+ typename WrappedType,
+ WrappedType kInvalidValue>
+struct ParamTraits<
+ base::IdType<TypeBeingIdentified, WrappedType, kInvalidValue>> {
+ typedef base::IdType<TypeBeingIdentified, WrappedType, kInvalidValue>
+ param_type;
+ typedef ParamTraits<WrappedType> base_param_traits;
+ static void Write(Message* m, const param_type& p) {
+ base_param_traits::Write(m, p.GetUnsafeValue());
+ }
+ static bool Read(const Message* m,
+ base::PickleIterator* iter,
+ param_type* r) {
+ WrappedType value;
+ if (!base_param_traits::Read(m, iter, &value))
+ return false;
+ *r = param_type::FromUnsafeValue(value);
+ return true;
+ }
+ static void Log(const param_type& p, std::string* l) {
+ base_param_traits::Log(p.GetUnsafeValue(), l);
+ }
+};
+
// IPC types ParamTraits -------------------------------------------------------
// A ChannelHandle is basically a platform-inspecific wrapper around the
« no previous file with comments | « content/renderer/render_frame_proxy.h ('k') | mojo/converters/surfaces/surfaces_type_converters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698