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: ppapi/proxy/serialized_structs.cc

Issue 10828023: PPAPI/NaCl: Make NaClIPCAdapter transfer handles more generally (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready for review? 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
Index: ppapi/proxy/serialized_structs.cc
diff --git a/ppapi/proxy/serialized_structs.cc b/ppapi/proxy/serialized_structs.cc
index bd17e4ddb641386390a0a4e395275e4b80e21f0f..95de668866fba2f7bc26da6d57e2f493b6112138 100644
--- a/ppapi/proxy/serialized_structs.cc
+++ b/ppapi/proxy/serialized_structs.cc
@@ -1,9 +1,10 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
#include "ppapi/proxy/serialized_structs.h"
+#include "base/pickle.h"
#include "ppapi/c/dev/ppb_font_dev.h"
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/pp_rect.h"
@@ -78,5 +79,53 @@ PPBFlash_DrawGlyphs_Params::PPBFlash_DrawGlyphs_Params()
PPBFlash_DrawGlyphs_Params::~PPBFlash_DrawGlyphs_Params() {}
+SerializedHandle::SerializedHandle()
+ : type_(INVALID),
+ shm_handle_(base::SharedMemory::NULLHandle()),
+ size_(0),
+ descriptor_(IPC::InvalidPlatformFileForTransit()) {
+}
+
+SerializedHandle::SerializedHandle(Type type_param)
+ : type_(type_param),
+ shm_handle_(base::SharedMemory::NULLHandle()),
+ size_(0),
+ descriptor_(IPC::InvalidPlatformFileForTransit()) {
+}
+
+SerializedHandle::SerializedHandle(const base::SharedMemoryHandle& handle,
+ uint32_t size)
+ : type_(SHARED_MEMORY),
+ shm_handle_(handle),
+ size_(size),
+ descriptor_(IPC::InvalidPlatformFileForTransit()) {
+}
+
+SerializedHandle::SerializedHandle(
+ const IPC::PlatformFileForTransit& socket_descriptor)
+ : type_(SOCKET),
+ shm_handle_(base::SharedMemory::NULLHandle()),
+ size_(0),
+ descriptor_(socket_descriptor) {
+}
+
+bool SerializedHandle::IsHandleValid() const {
+ if (type_ == SHARED_MEMORY)
+ return base::SharedMemory::IsHandleValid(shm_handle_);
+ else if (type_ == SOCKET)
+ return (IPC::InvalidPlatformFileForTransit() == descriptor_);
+ return false;
+}
+
+bool SerializedHandle::WriteHeader(Pickle* pickle) const {
+ if (!pickle->WriteInt(type_))
+ return false;
+ if (type_ == SHARED_MEMORY) {
+ if (!pickle->WriteUInt32(size_))
+ return false;
+ }
+ return true;
+}
+
} // namespace proxy
} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698