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

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: re-add gyp files Created 8 years, 3 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
« no previous file with comments | « ppapi/proxy/serialized_structs.h ('k') | ppapi/proxy/serialized_var.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // static
121 bool SerializedHandle::WriteHeader(const Header& hdr, Pickle* pickle) {
122 if (!pickle->WriteInt(hdr.type))
123 return false;
124 if (hdr.type == SHARED_MEMORY) {
125 if (!pickle->WriteUInt32(hdr.size))
126 return false;
127 }
128 return true;
129 }
130
131 // static
132 bool SerializedHandle::ReadHeader(PickleIterator* iter, Header* hdr) {
133 *hdr = Header(INVALID, 0);
134 int type = 0;
135 if (!iter->ReadInt(&type))
136 return false;
137 bool valid_type = false;
138 switch (type) {
139 case SHARED_MEMORY: {
140 uint32_t size = 0;
141 if (!iter->ReadUInt32(&size))
142 return false;
143 hdr->size = size;
144 valid_type = true;
145 break;
146 }
147 case SOCKET:
148 valid_type = true;
149 break;
150 case INVALID:
151 valid_type = true;
152 break;
153 // No default so the compiler will warn us if a new type is added.
154 }
155 if (valid_type)
156 hdr->type = Type(type);
157 return valid_type;
158 }
159
81 } // namespace proxy 160 } // namespace proxy
82 } // namespace ppapi 161 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/serialized_structs.h ('k') | ppapi/proxy/serialized_var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698