diff options
author | burnik <burnik@chromium.org> | 2014-09-07 23:58:22 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-08 07:10:25 +0000 |
commit | 3d67005036e98d91a329e5f70dbc4f1ddb27a1ab (patch) | |
tree | 6da0575c5699e1b8f8f3451c3acfa08b26f3291a /content/browser/renderer_host/media/audio_renderer_host.cc | |
parent | 4189453237c2ef570d07e132c72b171664a19e51 (diff) | |
download | chromium_src-3d67005036e98d91a329e5f70dbc4f1ddb27a1ab.zip chromium_src-3d67005036e98d91a329e5f70dbc4f1ddb27a1ab.tar.gz chromium_src-3d67005036e98d91a329e5f70dbc4f1ddb27a1ab.tar.bz2 |
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
Review URL: https://codereview.chromium.org/525313002
Cr-Commit-Position: refs/heads/master@{#293680}
Diffstat (limited to 'content/browser/renderer_host/media/audio_renderer_host.cc')
-rw-r--r-- | content/browser/renderer_host/media/audio_renderer_host.cc | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/content/browser/renderer_host/media/audio_renderer_host.cc b/content/browser/renderer_host/media/audio_renderer_host.cc index 91cea83..f93eb41 100644 --- a/content/browser/renderer_host/media/audio_renderer_host.cc +++ b/content/browser/renderer_host/media/audio_renderer_host.cc @@ -238,24 +238,17 @@ void AudioRendererHost::DoCompleteCreation(int stream_id) { AudioSyncReader* reader = static_cast<AudioSyncReader*>(entry->reader()); -#if defined(OS_WIN) - base::SyncSocket::Handle foreign_socket_handle; -#else - base::FileDescriptor foreign_socket_handle; -#endif + base::SyncSocket::TransitDescriptor socket_descriptor; // If we failed to prepare the sync socket for the renderer then we fail // the construction of audio stream. - if (!reader->PrepareForeignSocketHandle(PeerHandle(), - &foreign_socket_handle)) { + if (!reader->PrepareForeignSocket(PeerHandle(), &socket_descriptor)) { ReportErrorAndClose(entry->stream_id()); return; } Send(new AudioMsg_NotifyStreamCreated( - entry->stream_id(), - foreign_memory_handle, - foreign_socket_handle, + entry->stream_id(), foreign_memory_handle, socket_descriptor, entry->shared_memory()->requested_size())); } |