DescriptionPreparing |SyncSocket|'s handle for the peer process is different for POSIX and Windows
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
Committed: https://crrev.com/3d67005036e98d91a329e5f70dbc4f1ddb27a1ab
Cr-Commit-Position: refs/heads/master@{#293680}
Patch Set 1 #Patch Set 2 : Rebased on master #
Total comments: 31
Patch Set 3 : clang formatting and nits addressed #
Total comments: 40
Patch Set 4 : Refactor audio_output_device_unittest.cc #
Total comments: 10
Patch Set 5 : Windows fixes with nits #
Total comments: 4
Patch Set 6 : Nits and bits #Patch Set 7 : Add DCHECK on posix for descriptor pointer #
Total comments: 8
Patch Set 8 : Nits done - Prelanding checks #Messages
Total messages: 33 (8 generated)
|