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

Side by Side Diff: content/browser/renderer_host/media/audio_input_renderer_host.cc

Issue 525313002: SyncSocket Transit Descriptor - refactoring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits done - Prelanding checks Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/sync_socket_win.cc ('k') | content/browser/renderer_host/media/audio_input_sync_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/numerics/safe_math.h" 10 #include "base/numerics/safe_math.h"
(...skipping 13 matching lines...) Expand all
24 void LogMessage(int stream_id, const std::string& msg, bool add_prefix) { 24 void LogMessage(int stream_id, const std::string& msg, bool add_prefix) {
25 std::ostringstream oss; 25 std::ostringstream oss;
26 oss << "[stream_id=" << stream_id << "] "; 26 oss << "[stream_id=" << stream_id << "] ";
27 if (add_prefix) 27 if (add_prefix)
28 oss << "AIRH::"; 28 oss << "AIRH::";
29 oss << msg; 29 oss << msg;
30 content::MediaStreamManager::SendMessageToNativeLog(oss.str()); 30 content::MediaStreamManager::SendMessageToNativeLog(oss.str());
31 DVLOG(1) << oss.str(); 31 DVLOG(1) << oss.str();
32 } 32 }
33 33
34 } 34 } // namespace
35 35
36 namespace content { 36 namespace content {
37 37
38 struct AudioInputRendererHost::AudioEntry { 38 struct AudioInputRendererHost::AudioEntry {
39 AudioEntry(); 39 AudioEntry();
40 ~AudioEntry(); 40 ~AudioEntry();
41 41
42 // The AudioInputController that manages the audio input stream. 42 // The AudioInputController that manages the audio input stream.
43 scoped_refptr<media::AudioInputController> controller; 43 scoped_refptr<media::AudioInputController> controller;
44 44
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 &foreign_memory_handle)) { 171 &foreign_memory_handle)) {
172 // If we failed to map and share the shared memory then close the audio 172 // If we failed to map and share the shared memory then close the audio
173 // stream and send an error message. 173 // stream and send an error message.
174 DeleteEntryOnError(entry, MEMORY_SHARING_FAILED); 174 DeleteEntryOnError(entry, MEMORY_SHARING_FAILED);
175 return; 175 return;
176 } 176 }
177 177
178 AudioInputSyncWriter* writer = 178 AudioInputSyncWriter* writer =
179 static_cast<AudioInputSyncWriter*>(entry->writer.get()); 179 static_cast<AudioInputSyncWriter*>(entry->writer.get());
180 180
181 #if defined(OS_WIN) 181 base::SyncSocket::TransitDescriptor socket_transit_descriptor;
182 base::SyncSocket::Handle foreign_socket_handle;
183 #else
184 base::FileDescriptor foreign_socket_handle;
185 #endif
186 182
187 // If we failed to prepare the sync socket for the renderer then we fail 183 // If we failed to prepare the sync socket for the renderer then we fail
188 // the construction of audio input stream. 184 // the construction of audio input stream.
189 if (!writer->PrepareForeignSocketHandle(PeerHandle(), 185 if (!writer->PrepareForeignSocket(PeerHandle(), &socket_transit_descriptor)) {
190 &foreign_socket_handle)) {
191 DeleteEntryOnError(entry, SYNC_SOCKET_ERROR); 186 DeleteEntryOnError(entry, SYNC_SOCKET_ERROR);
192 return; 187 return;
193 } 188 }
194 189
195 LogMessage(entry->stream_id, 190 LogMessage(entry->stream_id,
196 "DoCompleteCreation: IPC channel and stream are now open", 191 "DoCompleteCreation: IPC channel and stream are now open",
197 true); 192 true);
198 193
199 Send(new AudioInputMsg_NotifyStreamCreated(entry->stream_id, 194 Send(new AudioInputMsg_NotifyStreamCreated(
200 foreign_memory_handle, foreign_socket_handle, 195 entry->stream_id, foreign_memory_handle, socket_transit_descriptor,
201 entry->shared_memory.requested_size(), 196 entry->shared_memory.requested_size(),
202 entry->shared_memory_segment_count)); 197 entry->shared_memory_segment_count));
203 } 198 }
204 199
205 void AudioInputRendererHost::DoSendRecordingMessage( 200 void AudioInputRendererHost::DoSendRecordingMessage(
206 media::AudioInputController* controller) { 201 media::AudioInputController* controller) {
207 DCHECK_CURRENTLY_ON(BrowserThread::IO); 202 DCHECK_CURRENTLY_ON(BrowserThread::IO);
208 // TODO(henrika): See crbug.com/115262 for details on why this method 203 // TODO(henrika): See crbug.com/115262 for details on why this method
209 // should be implemented. 204 // should be implemented.
210 AudioEntry* entry = LookupByController(controller); 205 AudioEntry* entry = LookupByController(controller);
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 // TODO(hclam): Implement a faster look up method. 496 // TODO(hclam): Implement a faster look up method.
502 for (AudioEntryMap::iterator i = audio_entries_.begin(); 497 for (AudioEntryMap::iterator i = audio_entries_.begin();
503 i != audio_entries_.end(); ++i) { 498 i != audio_entries_.end(); ++i) {
504 if (controller == i->second->controller.get()) 499 if (controller == i->second->controller.get())
505 return i->second; 500 return i->second;
506 } 501 }
507 return NULL; 502 return NULL;
508 } 503 }
509 504
510 } // namespace content 505 } // namespace content
OLDNEW
« no previous file with comments | « base/sync_socket_win.cc ('k') | content/browser/renderer_host/media/audio_input_sync_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698