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

Unified Diff: ipc/ipc_message_utils.h

Issue 1548443002: Introducing gpu::CommandBufferId as a distinct, IdType<...>-based type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@type-safe-save-package-id-self-contained
Patch Set: Created 4 years, 10 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 | « gpu/ipc/gpu_command_buffer_traits.cc ('k') | media/base/video_frame_unittest.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 d8b660740d8b67d1c739efe44be20c950a1f153b..4adeabe630483b1220ca8f4f7d1248a69796555e 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -19,6 +19,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"
@@ -976,6 +977,27 @@ struct ParamTraits<scoped_ptr<P> > {
}
};
+template <typename TypeMarker, typename WrappedType, WrappedType kInvalidValue>
+struct ParamTraits<base::IdType<TypeMarker, WrappedType, kInvalidValue>> {
+ typedef base::IdType<TypeMarker, WrappedType, kInvalidValue> param_type;
+ typedef ParamTraits<WrappedType> base_param_traits;
+ static void Write(base::Pickle* m, const param_type& p) {
+ base_param_traits::Write(m, p.GetUnsafeValue());
+ }
+ static bool Read(const base::Pickle* 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);
+ }
+};
Nico 2016/02/09 20:04:29 This isn't more type-safe than just sending the in
Łukasz Anforowicz 2016/02/09 23:06:32 It *is* more type-safe to use gpu::CommandBufferId
+
// IPC types ParamTraits -------------------------------------------------------
// A ChannelHandle is basically a platform-inspecific wrapper around the
« no previous file with comments | « gpu/ipc/gpu_command_buffer_traits.cc ('k') | media/base/video_frame_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698