OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BASE_NATIVE_SYNC_SOCKET_H_ | |
6 #define BASE_NATIVE_SYNC_SOCKET_H_ | |
7 | |
8 #include "base/process/process_handle.h" | |
9 #include "base/sync_socket.h" | |
10 | |
11 #if defined(OS_POSIX) | |
12 #include "base/file_descriptor_posix.h" | |
13 #endif | |
14 | |
15 namespace base { | |
16 | |
17 // Helper class for using |SyncSocket| cross-platform | |
18 class NativeSyncSocket { | |
tommi (sloooow) - chröme
2014/08/29 11:25:30
This class seems to rely on SyncSocket but doesn't
no longer working on chromium
2014/08/29 12:23:06
You and I should have a discussion with Tommi on i
burnik
2014/08/29 13:26:16
Agreed. Socket should be more cross-platform frien
burnik
2014/08/29 13:26:16
I agree. SyncSocket should have a descriptor which
| |
19 public: | |
20 #if defined(OS_WIN) | |
21 typedef base::SyncSocket::Handle Descriptor; | |
22 | |
23 static bool PrepareForeignSocketDescriptor( | |
tommi (sloooow) - chröme
2014/08/29 11:25:30
implementation should be in the cc file
tommi (sloooow) - chröme
2014/08/29 11:25:30
I know that this method name comes from elsewhere,
burnik
2014/08/29 13:26:16
Acknowledged.
burnik
2014/08/29 13:26:16
Agreed. I think name should be something like |Pre
| |
24 base::ProcessHandle process_handle, | |
25 base::SyncSocket * foreign_socket, | |
26 base::SyncSocket::Handle * foreign_handle) { | |
27 ::DuplicateHandle(GetCurrentProcess(), foreign_socket->handle(), | |
28 process_handle, foreign_handle, | |
29 0, FALSE, DUPLICATE_SAME_ACCESS); | |
30 return (*foreign_handle != 0); | |
31 } | |
32 | |
33 static base::SyncSocket::Handle Unwrap(const Descriptor& descriptor) { | |
34 return descriptor; | |
35 } | |
36 | |
37 #else | |
38 typedef base::FileDescriptor Descriptor; | |
39 | |
40 static bool PrepareForeignSocketDescriptor( | |
41 base::ProcessHandle process_handle, | |
42 base::SyncSocket * foreign_socket, | |
43 base::FileDescriptor * foreign_handle) { | |
44 foreign_handle->fd = foreign_socket->handle(); | |
45 foreign_handle->auto_close = false; | |
46 return (foreign_handle->fd != -1); | |
47 } | |
48 | |
49 static int Unwrap(const Descriptor& descriptor) { | |
tommi (sloooow) - chröme
2014/08/29 11:25:30
use base::SyncSocket::Handle here as well as the r
burnik
2014/08/29 13:26:16
Good point. When impl moves to .cc it will make mo
| |
50 return descriptor.fd; | |
51 } | |
52 #endif | |
53 }; | |
54 | |
55 } // namespace base | |
56 #endif // BASE_NATIVE_SYNC_SOCKET_H_ | |
OLD | NEW |