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

Side by Side Diff: ppapi/proxy/serialized_structs.cc

Issue 10912011: Change NaCl IPC PPAPI proxy startup to support a NaCl-Browser process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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') | no next file » | 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) 2012 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 "base/pickle.h"
8 #include "ppapi/c/dev/ppb_font_dev.h" 8 #include "ppapi/c/dev/ppb_font_dev.h"
9 #include "ppapi/c/pp_file_info.h" 9 #include "ppapi/c/pp_file_info.h"
10 #include "ppapi/c/pp_rect.h" 10 #include "ppapi/c/pp_rect.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 SerializedHandle::SerializedHandle(const base::SharedMemoryHandle& handle, 96 SerializedHandle::SerializedHandle(const base::SharedMemoryHandle& handle,
97 uint32_t size) 97 uint32_t size)
98 : type_(SHARED_MEMORY), 98 : type_(SHARED_MEMORY),
99 shm_handle_(handle), 99 shm_handle_(handle),
100 size_(size), 100 size_(size),
101 descriptor_(IPC::InvalidPlatformFileForTransit()) { 101 descriptor_(IPC::InvalidPlatformFileForTransit()) {
102 } 102 }
103 103
104 SerializedHandle::SerializedHandle( 104 SerializedHandle::SerializedHandle(
105 Type type,
105 const IPC::PlatformFileForTransit& socket_descriptor) 106 const IPC::PlatformFileForTransit& socket_descriptor)
106 : type_(SOCKET), 107 : type_(type),
107 shm_handle_(base::SharedMemory::NULLHandle()), 108 shm_handle_(base::SharedMemory::NULLHandle()),
108 size_(0), 109 size_(0),
109 descriptor_(socket_descriptor) { 110 descriptor_(socket_descriptor) {
110 } 111 }
111 112
112 bool SerializedHandle::IsHandleValid() const { 113 bool SerializedHandle::IsHandleValid() const {
113 if (type_ == SHARED_MEMORY) 114 if (type_ == SHARED_MEMORY)
114 return base::SharedMemory::IsHandleValid(shm_handle_); 115 return base::SharedMemory::IsHandleValid(shm_handle_);
115 else if (type_ == SOCKET) 116 else if (type_ == SOCKET || type_ == CHANNEL_HANDLE)
116 return (IPC::InvalidPlatformFileForTransit() == descriptor_); 117 return !(IPC::InvalidPlatformFileForTransit() == descriptor_);
117 return false; 118 return false;
118 } 119 }
119 120
120 // static 121 // static
121 bool SerializedHandle::WriteHeader(const Header& hdr, Pickle* pickle) { 122 bool SerializedHandle::WriteHeader(const Header& hdr, Pickle* pickle) {
122 if (!pickle->WriteInt(hdr.type)) 123 if (!pickle->WriteInt(hdr.type))
123 return false; 124 return false;
124 if (hdr.type == SHARED_MEMORY) { 125 if (hdr.type == SHARED_MEMORY) {
125 if (!pickle->WriteUInt32(hdr.size)) 126 if (!pickle->WriteUInt32(hdr.size))
126 return false; 127 return false;
(...skipping 11 matching lines...) Expand all
138 switch (type) { 139 switch (type) {
139 case SHARED_MEMORY: { 140 case SHARED_MEMORY: {
140 uint32_t size = 0; 141 uint32_t size = 0;
141 if (!iter->ReadUInt32(&size)) 142 if (!iter->ReadUInt32(&size))
142 return false; 143 return false;
143 hdr->size = size; 144 hdr->size = size;
144 valid_type = true; 145 valid_type = true;
145 break; 146 break;
146 } 147 }
147 case SOCKET: 148 case SOCKET:
148 valid_type = true; 149 case CHANNEL_HANDLE:
149 break;
150 case INVALID: 150 case INVALID:
151 valid_type = true; 151 valid_type = true;
152 break; 152 break;
153 // No default so the compiler will warn us if a new type is added. 153 // No default so the compiler will warn us if a new type is added.
154 } 154 }
155 if (valid_type) 155 if (valid_type)
156 hdr->type = Type(type); 156 hdr->type = Type(type);
157 return valid_type; 157 return valid_type;
158 } 158 }
159 159
160 } // namespace proxy 160 } // namespace proxy
161 } // namespace ppapi 161 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/serialized_structs.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698