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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/serialized_structs.h" 5 #include "ppapi/proxy/serialized_structs.h"
6 6
7 #include "base/pickle.h"
7 #include "ppapi/c/dev/ppb_font_dev.h" 8 #include "ppapi/c/dev/ppb_font_dev.h"
8 #include "ppapi/c/pp_file_info.h" 9 #include "ppapi/c/pp_file_info.h"
9 #include "ppapi/c/pp_rect.h" 10 #include "ppapi/c/pp_rect.h"
10 11
11 namespace ppapi { 12 namespace ppapi {
12 namespace proxy { 13 namespace proxy {
13 14
14 SerializedFontDescription::SerializedFontDescription() 15 SerializedFontDescription::SerializedFontDescription()
15 : face(), 16 : face(),
16 family(0), 17 family(0),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 clip.point.y = 0; 72 clip.point.y = 0;
72 clip.size.height = 0; 73 clip.size.height = 0;
73 clip.size.width = 0; 74 clip.size.width = 0;
74 position.x = 0; 75 position.x = 0;
75 position.y = 0; 76 position.y = 0;
76 allow_subpixel_aa = PP_FALSE; 77 allow_subpixel_aa = PP_FALSE;
77 } 78 }
78 79
79 PPBFlash_DrawGlyphs_Params::~PPBFlash_DrawGlyphs_Params() {} 80 PPBFlash_DrawGlyphs_Params::~PPBFlash_DrawGlyphs_Params() {}
80 81
82 SerializedHandle::SerializedHandle()
83 : type_(INVALID),
84 shm_handle_(base::SharedMemory::NULLHandle()),
85 size_(0),
86 descriptor_(IPC::InvalidPlatformFileForTransit()) {
87 }
88
89 SerializedHandle::SerializedHandle(Type type_param)
90 : type_(type_param),
91 shm_handle_(base::SharedMemory::NULLHandle()),
92 size_(0),
93 descriptor_(IPC::InvalidPlatformFileForTransit()) {
94 }
95
96 SerializedHandle::SerializedHandle(const base::SharedMemoryHandle& handle,
97 uint32_t size)
98 : type_(SHARED_MEMORY),
99 shm_handle_(handle),
100 size_(size),
101 descriptor_(IPC::InvalidPlatformFileForTransit()) {
102 }
103
104 SerializedHandle::SerializedHandle(
105 const IPC::PlatformFileForTransit& socket_descriptor)
106 : type_(SOCKET),
107 shm_handle_(base::SharedMemory::NULLHandle()),
108 size_(0),
109 descriptor_(socket_descriptor) {
110 }
111
112 bool SerializedHandle::IsHandleValid() const {
113 if (type_ == SHARED_MEMORY)
114 return base::SharedMemory::IsHandleValid(shm_handle_);
115 else if (type_ == SOCKET)
116 return (IPC::InvalidPlatformFileForTransit() == descriptor_);
117 return false;
118 }
119
120 bool SerializedHandle::WriteHeader(Pickle* pickle) const {
121 if (!pickle->WriteInt(type_))
122 return false;
123 if (type_ == SHARED_MEMORY) {
124 if (!pickle->WriteUInt32(size_))
125 return false;
126 }
127 return true;
128 }
129
81 } // namespace proxy 130 } // namespace proxy
82 } // namespace ppapi 131 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698