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

Issue 525313002: SyncSocket Transit Descriptor - refactoring (Closed)

Created:
6 years, 3 months ago by burnik
Modified:
6 years, 3 months ago
CC:
chromium-reviews, posciak+watch_chromium.org, jam, mcasas+watch_chromium.org, feature-media-reviews_chromium.org, darin-cc_chromium.org, erikwright+watch_chromium.org, wjia+watch_chromium.org, miu+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Preparing |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 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+118 lines, -165 lines) Patch
M base/sync_socket.h View 1 2 3 2 chunks +16 lines, -0 lines 0 comments Download
M base/sync_socket_nacl.cc View 1 2 3 1 chunk +18 lines, -0 lines 0 comments Download
M base/sync_socket_posix.cc View 1 2 3 4 5 7 1 chunk +13 lines, -0 lines 0 comments Download
M base/sync_socket_win.cc View 1 2 3 4 5 1 chunk +17 lines, -0 lines 0 comments Download
M content/browser/renderer_host/media/audio_input_renderer_host.cc View 1 2 3 3 chunks +5 lines, -10 lines 0 comments Download
M content/browser/renderer_host/media/audio_input_sync_writer.h View 1 2 1 chunk +2 lines, -6 lines 0 comments Download
M content/browser/renderer_host/media/audio_input_sync_writer.cc View 1 2 3 1 chunk +3 lines, -19 lines 0 comments Download
M content/browser/renderer_host/media/audio_renderer_host.cc View 1 2 1 chunk +3 lines, -10 lines 0 comments Download
M content/browser/renderer_host/media/audio_renderer_host_unittest.cc View 1 2 2 chunks +5 lines, -14 lines 0 comments Download
M content/browser/renderer_host/media/audio_sync_reader.h View 1 2 1 chunk +2 lines, -6 lines 0 comments Download
M content/browser/renderer_host/media/audio_sync_reader.cc View 1 2 3 4 1 chunk +3 lines, -16 lines 0 comments Download
M content/common/media/audio_messages.h View 1 2 3 1 chunk +13 lines, -28 lines 0 comments Download
M content/renderer/media/audio_input_message_filter.cc View 1 2 3 4 5 6 7 2 chunks +4 lines, -9 lines 0 comments Download
M content/renderer/media/audio_message_filter.h View 1 chunk +1 line, -5 lines 0 comments Download
M content/renderer/media/audio_message_filter.cc View 1 3 4 5 6 7 2 chunks +3 lines, -8 lines 0 comments Download
M content/renderer/media/audio_message_filter_unittest.cc View 1 2 1 chunk +3 lines, -9 lines 0 comments Download
M media/audio/audio_output_device_unittest.cc View 1 2 3 3 chunks +7 lines, -25 lines 0 comments Download

Messages

Total messages: 33 (8 generated)
burnik
Updated description. Please have a look.
6 years, 3 months ago (2014-09-01 14:22:14 UTC) #2
henrika (OOO until Aug 14)
Looks like really nice and useful code. I don't know the underlying details well enough ...
6 years, 3 months ago (2014-09-01 14:30:43 UTC) #3
no longer working on chromium
Looking good. https://codereview.chromium.org/525313002/diff/20001/base/sync_socket.h File base/sync_socket.h (right): https://codereview.chromium.org/525313002/diff/20001/base/sync_socket.h#newcode34 base/sync_socket.h:34: typedef Handle TransitDescriptor; The existing sync socket ...
6 years, 3 months ago (2014-09-01 14:56:19 UTC) #4
burnik
Nits done and crbug created: http://crbug.com/409656 https://codereview.chromium.org/525313002/diff/20001/base/sync_socket.h File base/sync_socket.h (right): https://codereview.chromium.org/525313002/diff/20001/base/sync_socket.h#newcode59 base/sync_socket.h:59: TransitDescriptor * descriptor); ...
6 years, 3 months ago (2014-09-01 14:59:34 UTC) #5
burnik
Thanks for the clang-format tip. :-) https://codereview.chromium.org/525313002/diff/20001/base/sync_socket.h File base/sync_socket.h (right): https://codereview.chromium.org/525313002/diff/20001/base/sync_socket.h#newcode34 base/sync_socket.h:34: typedef Handle TransitDescriptor; ...
6 years, 3 months ago (2014-09-01 15:08:03 UTC) #6
burnik
https://codereview.chromium.org/525313002/diff/40001/base/sync_socket_win.cc File base/sync_socket_win.cc (right): https://codereview.chromium.org/525313002/diff/40001/base/sync_socket_win.cc#newcode219 base/sync_socket_win.cc:219: // |TransitDescriptor| on Windows is the |Handle| itself I ...
6 years, 3 months ago (2014-09-01 15:18:21 UTC) #7
henrika (OOO until Aug 14)
LGTM https://codereview.chromium.org/525313002/diff/40001/base/sync_socket_nacl.cc File base/sync_socket_nacl.cc (right): https://codereview.chromium.org/525313002/diff/40001/base/sync_socket_nacl.cc#newcode33 base/sync_socket_nacl.cc:33: // TODO(burnik): Still unclear how NaCl uses SyncSocket. ...
6 years, 3 months ago (2014-09-02 07:46:06 UTC) #8
burnik
Thanks! https://codereview.chromium.org/525313002/diff/40001/base/sync_socket_nacl.cc File base/sync_socket_nacl.cc (right): https://codereview.chromium.org/525313002/diff/40001/base/sync_socket_nacl.cc#newcode33 base/sync_socket_nacl.cc:33: // TODO(burnik): Still unclear how NaCl uses SyncSocket. ...
6 years, 3 months ago (2014-09-02 10:02:54 UTC) #9
no longer working on chromium
I think you missed the audio_output_device_unittest.cc Also, you should add stamps from owners of base/ ...
6 years, 3 months ago (2014-09-02 10:25:04 UTC) #12
henrika (OOO until Aug 14)
https://codereview.chromium.org/525313002/diff/40001/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/525313002/diff/40001/base/sync_socket_posix.cc#newcode108 base/sync_socket_posix.cc:108: // |TransitDescriptor| on POSIX is a |FileDescriptor|. It does ...
6 years, 3 months ago (2014-09-02 10:26:38 UTC) #13
burnik
Added audio_output_device_unittest.cc https://codereview.chromium.org/525313002/diff/20001/base/sync_socket.h File base/sync_socket.h (right): https://codereview.chromium.org/525313002/diff/20001/base/sync_socket.h#newcode57 base/sync_socket.h:57: // the foreign handle to the peer ...
6 years, 3 months ago (2014-09-02 15:01:34 UTC) #14
no longer working on chromium
https://codereview.chromium.org/525313002/diff/40001/content/common/media/audio_messages.h File content/common/media/audio_messages.h (right): https://codereview.chromium.org/525313002/diff/40001/content/common/media/audio_messages.h#newcode53 content/common/media/audio_messages.h:53: uint32 /* length */, uint32 /* segment count */) ...
6 years, 3 months ago (2014-09-02 15:09:01 UTC) #16
burnik
I would appreciate any thoughts or suggestions from darin@ and tommi@. https://codereview.chromium.org/525313002/diff/40001/content/common/media/audio_messages.h File content/common/media/audio_messages.h (right): ...
6 years, 3 months ago (2014-09-04 09:04:57 UTC) #17
tommi (sloooow) - chröme
I think this is good cleanup. I found one issue below (some nits too). I ...
6 years, 3 months ago (2014-09-04 11:34:11 UTC) #18
burnik
Checks for windows added. Nits addressed. https://codereview.chromium.org/525313002/diff/60001/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/525313002/diff/60001/base/sync_socket_posix.cc#newcode111 base/sync_socket_posix.cc:111: return (descriptor->fd != ...
6 years, 3 months ago (2014-09-04 12:24:44 UTC) #19
tommi (sloooow) - chröme
only very minor things https://codereview.chromium.org/525313002/diff/60001/base/sync_socket_win.cc File base/sync_socket_win.cc (right): https://codereview.chromium.org/525313002/diff/60001/base/sync_socket_win.cc#newcode213 base/sync_socket_win.cc:213: return static_cast<SyncSocket::Handle>(descriptor); On 2014/09/04 12:24:44, ...
6 years, 3 months ago (2014-09-04 17:02:26 UTC) #20
burnik
Agreed. https://codereview.chromium.org/525313002/diff/60001/base/sync_socket_win.cc File base/sync_socket_win.cc (right): https://codereview.chromium.org/525313002/diff/60001/base/sync_socket_win.cc#newcode213 base/sync_socket_win.cc:213: return static_cast<SyncSocket::Handle>(descriptor); On 2014/09/04 17:02:25, tommi wrote: > ...
6 years, 3 months ago (2014-09-04 18:04:07 UTC) #21
tommi (sloooow) - chröme
lgtm https://codereview.chromium.org/525313002/diff/120001/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/525313002/diff/120001/base/sync_socket_posix.cc#newcode107 base/sync_socket_posix.cc:107: DCHECK(descriptor); nit: we generally don't add DCHECKs like ...
6 years, 3 months ago (2014-09-04 19:47:00 UTC) #22
burnik
Thx. :) https://codereview.chromium.org/525313002/diff/120001/base/sync_socket_win.cc File base/sync_socket_win.cc (right): https://codereview.chromium.org/525313002/diff/120001/base/sync_socket_win.cc#newcode218 base/sync_socket_win.cc:218: DCHECK(descriptor); On 2014/09/04 19:47:00, tommi wrote: > ...
6 years, 3 months ago (2014-09-05 08:17:42 UTC) #23
nasko
IPC LGTM and a couple of drive-by style nits. https://codereview.chromium.org/525313002/diff/120001/content/renderer/media/audio_input_message_filter.cc File content/renderer/media/audio_input_message_filter.cc (right): https://codereview.chromium.org/525313002/diff/120001/content/renderer/media/audio_input_message_filter.cc#newcode128 content/renderer/media/audio_input_message_filter.cc:128: ...
6 years, 3 months ago (2014-09-05 17:31:52 UTC) #25
darin (slow to review)
LGTM
6 years, 3 months ago (2014-09-05 17:52:08 UTC) #26
burnik
Thanks all! FYI: Looks like some of the bots have unrelated build/test issues. Anyone care ...
6 years, 3 months ago (2014-09-06 18:17:10 UTC) #27
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/burnik@chromium.org/525313002/140001
6 years, 3 months ago (2014-09-08 04:06:22 UTC) #29
commit-bot: I haz the power
Committed patchset #8 (id:140001) as 35fa8e415c1b9c71f5b806998ef310be048b5183
6 years, 3 months ago (2014-09-08 07:01:39 UTC) #32
commit-bot: I haz the power
6 years, 3 months ago (2014-09-10 03:44:52 UTC) #33
Message was sent while issue was closed.
Patchset 8 (id:??) landed as
https://crrev.com/3d67005036e98d91a329e5f70dbc4f1ddb27a1ab
Cr-Commit-Position: refs/heads/master@{#293680}

Powered by Google App Engine
This is Rietveld 408576698