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

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

Issue 11437038: Revert 171408 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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/shared_impl/file_path.h » ('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) 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 "base/platform_file.h" 8 #include "base/platform_file.h"
9 #include "base/shared_memory.h" 9 #include "base/shared_memory.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 SerializedHandle::SerializedHandle( 100 SerializedHandle::SerializedHandle(
101 Type type, 101 Type type,
102 const IPC::PlatformFileForTransit& socket_descriptor) 102 const IPC::PlatformFileForTransit& socket_descriptor)
103 : type_(type), 103 : type_(type),
104 shm_handle_(base::SharedMemory::NULLHandle()), 104 shm_handle_(base::SharedMemory::NULLHandle()),
105 size_(0), 105 size_(0),
106 descriptor_(socket_descriptor) { 106 descriptor_(socket_descriptor) {
107 } 107 }
108 108
109 bool SerializedHandle::IsHandleValid() const { 109 bool SerializedHandle::IsHandleValid() const {
110 switch (type_) { 110 if (type_ == SHARED_MEMORY)
111 case SHARED_MEMORY: 111 return base::SharedMemory::IsHandleValid(shm_handle_);
112 return base::SharedMemory::IsHandleValid(shm_handle_); 112 else if (type_ == SOCKET || type_ == CHANNEL_HANDLE)
113 case SOCKET: 113 return !(IPC::InvalidPlatformFileForTransit() == descriptor_);
114 case CHANNEL_HANDLE:
115 case FILE:
116 return !(IPC::InvalidPlatformFileForTransit() == descriptor_);
117 case INVALID:
118 return false;
119 // No default so the compiler will warn us if a new type is added.
120 }
121 return false; 114 return false;
122 } 115 }
123 116
124 void SerializedHandle::Close() { 117 void SerializedHandle::Close() {
125 if (IsHandleValid()) { 118 if (IsHandleValid()) {
126 switch (type_) { 119 switch (type_) {
127 case INVALID: 120 case INVALID:
128 NOTREACHED(); 121 NOTREACHED();
129 break; 122 break;
130 case SHARED_MEMORY: 123 case SHARED_MEMORY:
131 base::SharedMemory::CloseHandle(shm_handle_); 124 base::SharedMemory::CloseHandle(shm_handle_);
132 break; 125 break;
133 case SOCKET: 126 case SOCKET:
134 case CHANNEL_HANDLE: 127 case CHANNEL_HANDLE:
135 case FILE:
136 base::PlatformFile file = 128 base::PlatformFile file =
137 IPC::PlatformFileForTransitToPlatformFile(descriptor_); 129 IPC::PlatformFileForTransitToPlatformFile(descriptor_);
138 #if !defined(OS_NACL) 130 #if !defined(OS_NACL)
139 base::ClosePlatformFile(file); 131 base::ClosePlatformFile(file);
140 #else 132 #else
141 close(file); 133 close(file);
142 #endif 134 #endif
143 break; 135 break;
144 // No default so the compiler will warn us if a new type is added. 136 // No default so the compiler will warn us if a new type is added.
145 } 137 }
(...skipping 23 matching lines...) Expand all
169 case SHARED_MEMORY: { 161 case SHARED_MEMORY: {
170 uint32_t size = 0; 162 uint32_t size = 0;
171 if (!iter->ReadUInt32(&size)) 163 if (!iter->ReadUInt32(&size))
172 return false; 164 return false;
173 hdr->size = size; 165 hdr->size = size;
174 valid_type = true; 166 valid_type = true;
175 break; 167 break;
176 } 168 }
177 case SOCKET: 169 case SOCKET:
178 case CHANNEL_HANDLE: 170 case CHANNEL_HANDLE:
179 case FILE:
180 case INVALID: 171 case INVALID:
181 valid_type = true; 172 valid_type = true;
182 break; 173 break;
183 // No default so the compiler will warn us if a new type is added. 174 // No default so the compiler will warn us if a new type is added.
184 } 175 }
185 if (valid_type) 176 if (valid_type)
186 hdr->type = Type(type); 177 hdr->type = Type(type);
187 return valid_type; 178 return valid_type;
188 } 179 }
189 180
190 } // namespace proxy 181 } // namespace proxy
191 } // namespace ppapi 182 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/serialized_structs.h ('k') | ppapi/shared_impl/file_path.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698