OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/dispatcher.h" | 5 #include "ppapi/proxy/dispatcher.h" |
6 | 6 |
7 #include <string.h> // For memset. | 7 #include <string.h> // For memset. |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 | 245 |
246 void Dispatcher::SetSerializationRules( | 246 void Dispatcher::SetSerializationRules( |
247 VarSerializationRules* var_serialization_rules) { | 247 VarSerializationRules* var_serialization_rules) { |
248 serialization_rules_.reset(var_serialization_rules); | 248 serialization_rules_.reset(var_serialization_rules); |
249 } | 249 } |
250 | 250 |
251 const void* Dispatcher::GetLocalInterface(const char* interface) { | 251 const void* Dispatcher::GetLocalInterface(const char* interface) { |
252 return local_get_interface_(interface); | 252 return local_get_interface_(interface); |
253 } | 253 } |
254 | 254 |
255 IPC::PlatformFileForTransit Dispatcher::ShareHandleWithRemote( | |
256 base::PlatformFile handle, | |
257 bool close_source) { | |
viettrungluu
2011/02/25 01:25:03
Or maybe |should_close_source|?
| |
258 IPC::PlatformFileForTransit out_handle; | |
259 #if defined(OS_WIN) | |
260 DWORD options = DUPLICATE_SAME_ACCESS; | |
261 if (close_source) | |
262 options |= DUPLICATE_CLOSE_SOURCE; | |
263 if (!::DuplicateHandle(::GetCurrentProcess(), | |
264 handle, | |
265 remote_process_handle_, | |
266 &out_handle, | |
267 0, | |
268 FALSE, | |
269 options)) | |
270 out_handle = IPC::InvalidPlatformFileForTransit(); | |
271 #elif defined(OS_POSIX) | |
272 // If asked to close the source, we can simply re-use the source fd instead of | |
273 // dup()ing and close()ing. | |
274 int fd = close_source ? handle : ::dup(handle); | |
275 out_handle = base::FileDescriptor(fd, true); | |
276 #else | |
277 #error Not implemented. | |
278 #endif | |
279 return out_handle; | |
280 } | |
281 | |
255 bool Dispatcher::Send(IPC::Message* msg) { | 282 bool Dispatcher::Send(IPC::Message* msg) { |
256 if (test_sink_) | 283 if (test_sink_) |
257 return test_sink_->Send(msg); | 284 return test_sink_->Send(msg); |
258 if (channel_.get()) | 285 if (channel_.get()) |
259 return channel_->Send(msg); | 286 return channel_->Send(msg); |
260 | 287 |
261 // Remote side crashed, drop this message. | 288 // Remote side crashed, drop this message. |
262 delete msg; | 289 delete msg; |
263 return false; | 290 return false; |
264 } | 291 } |
265 | 292 |
266 } // namespace proxy | 293 } // namespace proxy |
267 } // namespace pp | 294 } // namespace pp |
268 | 295 |
OLD | NEW |