-
burnik authored
which leads to code duplication, platform #ifdef checks on multiple levels and general confusion on how to work with the SyncSocket. Typical use case for |SyncSocket|: 1. Browser creates and connects the socket pair - one for browser and one for renderer. 2. Browser prepares the foreign socket (Windows duplicates, POSIX creates file descriptor). 3. Browser relays the foreign socket handle to the renderer via IPC. 4. Renderer receives the IPC and creates the socket using the handle provided. 5. Sockets are ready for send/receive on both ends. Steps 1-4 get simplified since there is no need to check the platform in order to prepare the socket for transit. What this CL brings: 1. Adds |SyncSocket::TransitDescriptor| type which wraps the socket handle and is cross-platform. 2. Adds |SyncSocket::PrepareTransitDescriptor| method which is implemented depending on the platform. 3. Adds |SyncSocket::UnwrapHandle| method which unwraps |SyncSocket::Handle| from |SyncSocket::TransitDescriptor|. 4. Removes #ifdefs for platform-checks in code using |SyncSocket| and simplifies preparing the SyncSocket. Note: - There is still some less evident duplication in the ppapi and pepper-broker code which should be addressed. - SyncSocket unit test should also be reviewed. - There is a similar pattern when using SharedMemory. BUG=409656 Review URL: https://codereview.chromium.org/525313002 Cr-Commit-Position: refs/heads/master@{#293680}
3d670050