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

Unified Diff: ppapi/proxy/content_decryptor_private_serializer.h

Issue 10854209: Modify the PPAPI CDM interface to pass more info. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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/cpp/private/content_decryptor_private.cc ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/content_decryptor_private_serializer.h
diff --git a/ppapi/proxy/content_decryptor_private_serializer.h b/ppapi/proxy/content_decryptor_private_serializer.h
new file mode 100644
index 0000000000000000000000000000000000000000..e8d72132f75bd2db0d5f21d57b6a3f06582d5eb9
--- /dev/null
+++ b/ppapi/proxy/content_decryptor_private_serializer.h
@@ -0,0 +1,56 @@
+// Copyright (c) 2012 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_PROXY_CONTENT_DECRYPTOR_PRIVATE_SERIALIZER_H_
+#define PPAPI_PROXY_CONTENT_DECRYPTOR_PRIVATE_SERIALIZER_H_
+
+#include <cstring>
+#include <string>
+
+#include "ppapi/c/private/pp_content_decryptor.h"
+
+namespace ppapi {
+namespace proxy {
+
+// Serialization/deserialization utility functions for storing/extracting
+// PP_{De|En}cryptedBlockInfo structs within std::string's for passing through
+// IPC. Both functions return true upon success, and false upon failure.
+//
+// Note, these functions check the size of |block_info| against the size of
+// the "serialized" data stored within |serialized_block_info|, and will report
+// failure if expectations are not met. Use of CHECK/DCHECK has been avoided
+// because the functions are intended for use on both sides of the IPC proxy.
+
+template <typename T>
+bool SerializeBlockInfo(const T& block_info,
+ std::string* serialized_block_info) {
+ if (!serialized_block_info)
+ return false;
+
+ serialized_block_info->assign(reinterpret_cast<const char*>(&block_info),
+ sizeof(block_info));
+
+ if (serialized_block_info->size() != sizeof(block_info))
+ return false;
+
+ return true;
+}
+
+template <typename T>
+bool DeserializeBlockInfo(const std::string& serialized_block_info,
+ T* block_info) {
+ if (!block_info)
+ return false;
+
+ if (serialized_block_info.size() != sizeof(*block_info))
+ return false;
+
+ std::memcpy(block_info, serialized_block_info.data(), sizeof(*block_info));
+ return true;
+}
+
+} // namespace proxy
+} // namespace ppapi
+
+#endif // PPAPI_PROXY_CONTENT_DECRYPTOR_PRIVATE_SERIALIZER_H_
« no previous file with comments | « ppapi/cpp/private/content_decryptor_private.cc ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698