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

Unified Diff: mojo/public/cpp/bindings/lib/serialization_util.h

Issue 2112093002: Mojo C++ bindings: Merge EncodePointers/DecodePointers into Serialize/Deserialize, respectively. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@61_array_fix
Patch Set: . Created 4 years, 6 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 | « mojo/public/cpp/bindings/lib/serialization.h ('k') | mojo/public/cpp/bindings/lib/serialization_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/serialization_util.h
diff --git a/mojo/public/cpp/bindings/lib/serialization_util.h b/mojo/public/cpp/bindings/lib/serialization_util.h
index 523f4842c366c46e4b5c3b79527a2a891ef579b8..4820a014ec182c21c14ead49534ff57374a6edcc 100644
--- a/mojo/public/cpp/bindings/lib/serialization_util.h
+++ b/mojo/public/cpp/bindings/lib/serialization_util.h
@@ -12,95 +12,12 @@
#include "base/logging.h"
#include "base/macros.h"
-#include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
-#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization_context.h"
-#include "mojo/public/cpp/system/handle.h"
namespace mojo {
-
-class AssociatedGroupController;
-
namespace internal {
-size_t Align(size_t size);
-char* AlignPointer(char* ptr);
-
-bool IsAligned(const void* ptr);
-
-// Pointers are encoded as relative offsets. The offsets are relative to the
-// address of where the offset value is stored, such that the pointer may be
-// recovered with the expression:
-//
-// ptr = reinterpret_cast<char*>(offset) + *offset
-//
-// A null pointer is encoded as an offset value of 0.
-//
-void EncodePointer(const void* ptr, uint64_t* offset);
-// Note: This function doesn't validate the encoded pointer value.
-const void* DecodePointerRaw(const uint64_t* offset);
-
-// Note: This function doesn't validate the encoded pointer value.
-template <typename T>
-inline void DecodePointer(const uint64_t* offset, T** ptr) {
- *ptr = reinterpret_cast<T*>(const_cast<void*>(DecodePointerRaw(offset)));
-}
-
-// The following 2 functions are used to encode/decode all objects (structs and
-// arrays) in a consistent manner.
-
-template <typename T>
-inline void Encode(T* obj) {
- if (obj->ptr)
- obj->ptr->EncodePointers();
- EncodePointer(obj->ptr, &obj->offset);
-}
-
-// Note: This function doesn't validate the encoded pointer and handle values.
-template <typename T>
-inline void Decode(T* obj) {
- DecodePointer(&obj->offset, &obj->ptr);
- if (obj->ptr)
- obj->ptr->DecodePointers();
-}
-
-template <typename T>
-inline void AssociatedInterfacePtrInfoToData(
- AssociatedInterfacePtrInfo<T> input,
- AssociatedInterface_Data* output) {
- output->version = input.version();
- output->interface_id = input.PassHandle().release();
-}
-
-template <typename T>
-inline void AssociatedInterfaceDataToPtrInfo(
- AssociatedInterface_Data* input,
- AssociatedInterfacePtrInfo<T>* output,
- AssociatedGroupController* group_controller) {
- output->set_handle(group_controller->CreateLocalEndpointHandle(
- FetchAndReset(&input->interface_id)));
- output->set_version(input->version);
-}
-
-template <typename T>
-inline void InterfacePointerToData(InterfacePtr<T> input,
- Interface_Data* output,
- SerializationContext* context) {
- InterfacePtrInfo<T> info = input.PassInterface();
- output->handle = context->handles.AddHandle(info.PassHandle().release());
- output->version = info.version();
-}
-
-template <typename T>
-inline void InterfaceDataToPointer(Interface_Data* input,
- InterfacePtr<T>* output,
- SerializationContext* context) {
- output->Bind(InterfacePtrInfo<T>(
- context->handles.TakeHandleAs<mojo::MessagePipeHandle>(input->handle),
- input->version));
-}
-
template <typename T>
struct HasIsNullMethod {
template <typename U>
« no previous file with comments | « mojo/public/cpp/bindings/lib/serialization.h ('k') | mojo/public/cpp/bindings/lib/serialization_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698