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

Side by Side Diff: ppapi/proxy/ppb_audio_proxy.cc

Issue 10828023: PPAPI/NaCl: Make NaClIPCAdapter transfer handles more generally (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed some proxy changes that aren't necessary now Created 8 years, 4 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 | Annotate | Revision Log
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 "ppapi/proxy/ppb_audio_proxy.h" 5 #include "ppapi/proxy/ppb_audio_proxy.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/threading/simple_thread.h" 8 #include "base/threading/simple_thread.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/ppb_audio.h" 10 #include "ppapi/c/ppb_audio.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 result_code = GetAudioConnectedHandles(resource, &socket_handle, 245 result_code = GetAudioConnectedHandles(resource, &socket_handle,
246 &shared_memory, 246 &shared_memory,
247 &shared_memory_length); 247 &shared_memory_length);
248 } 248 }
249 249
250 // Send all the values, even on error. This simplifies some of our cleanup 250 // Send all the values, even on error. This simplifies some of our cleanup
251 // code since the handles will be in the other process and could be 251 // code since the handles will be in the other process and could be
252 // inconvenient to clean up. Our IPC code will automatically handle this for 252 // inconvenient to clean up. Our IPC code will automatically handle this for
253 // us, as long as the remote side always closes the handles it receives 253 // us, as long as the remote side always closes the handles it receives
254 // (in OnMsgNotifyAudioStreamCreated), even in the failure case. 254 // (in OnMsgNotifyAudioStreamCreated), even in the failure case.
255 ppapi::proxy::SerializedHandle fd_wrapper(socket_handle);
256 ppapi::proxy::SerializedHandle handle_wrapper(
257 shared_memory, shared_memory_length + sizeof(int32_t));
255 dispatcher()->Send(new PpapiMsg_PPBAudio_NotifyAudioStreamCreated( 258 dispatcher()->Send(new PpapiMsg_PPBAudio_NotifyAudioStreamCreated(
256 API_ID_PPB_AUDIO, resource, result_code, socket_handle, 259 API_ID_PPB_AUDIO, resource, result_code, fd_wrapper, handle_wrapper));
257 shared_memory, shared_memory_length));
258 } 260 }
259 261
260 int32_t PPB_Audio_Proxy::GetAudioConnectedHandles( 262 int32_t PPB_Audio_Proxy::GetAudioConnectedHandles(
261 const HostResource& resource, 263 const HostResource& resource,
262 IPC::PlatformFileForTransit* foreign_socket_handle, 264 IPC::PlatformFileForTransit* foreign_socket_handle,
263 base::SharedMemoryHandle* foreign_shared_memory_handle, 265 base::SharedMemoryHandle* foreign_shared_memory_handle,
264 uint32_t* shared_memory_length) { 266 uint32_t* shared_memory_length) {
265 // Get the audio interface which will give us the handles. 267 // Get the audio interface which will give us the handles.
266 EnterHostFromHostResource<PPB_Audio_API> enter(resource); 268 EnterHostFromHostResource<PPB_Audio_API> enter(resource);
267 if (enter.failed()) 269 if (enter.failed())
(...skipping 24 matching lines...) Expand all
292 if (*foreign_shared_memory_handle == IPC::InvalidPlatformFileForTransit()) 294 if (*foreign_shared_memory_handle == IPC::InvalidPlatformFileForTransit())
293 return PP_ERROR_FAILED; 295 return PP_ERROR_FAILED;
294 296
295 return PP_OK; 297 return PP_OK;
296 } 298 }
297 299
298 // Processed in the plugin (message from host). 300 // Processed in the plugin (message from host).
299 void PPB_Audio_Proxy::OnMsgNotifyAudioStreamCreated( 301 void PPB_Audio_Proxy::OnMsgNotifyAudioStreamCreated(
300 const HostResource& audio_id, 302 const HostResource& audio_id,
301 int32_t result_code, 303 int32_t result_code,
302 IPC::PlatformFileForTransit socket_handle, 304 ppapi::proxy::SerializedHandle socket_handle,
303 base::SharedMemoryHandle handle, 305 ppapi::proxy::SerializedHandle handle) {
304 uint32_t length) { 306 CHECK(socket_handle.is_socket());
307 CHECK(handle.is_shmem());
305 EnterPluginFromHostResource<PPB_Audio_API> enter(audio_id); 308 EnterPluginFromHostResource<PPB_Audio_API> enter(audio_id);
306 if (enter.failed() || result_code != PP_OK) { 309 if (enter.failed() || result_code != PP_OK) {
307 // The caller may still have given us these handles in the failure case. 310 // The caller may still have given us these handles in the failure case.
308 // The easiest way to clean these up is to just put them in the objects 311 // The easiest way to clean these up is to just put them in the objects
309 // and then close them. This failure case is not performance critical. 312 // and then close them. This failure case is not performance critical.
310 base::SyncSocket temp_socket( 313 base::SyncSocket temp_socket(
311 IPC::PlatformFileForTransitToPlatformFile(socket_handle)); 314 IPC::PlatformFileForTransitToPlatformFile(socket_handle.descriptor()));
312 base::SharedMemory temp_mem(handle, false); 315 base::SharedMemory temp_mem(handle.shmem(), false);
313 } else { 316 } else {
314 static_cast<Audio*>(enter.object())->SetStreamInfo( 317 static_cast<Audio*>(enter.object())->SetStreamInfo(
315 enter.resource()->pp_instance(), handle, length, 318 enter.resource()->pp_instance(), handle.shmem(),
316 IPC::PlatformFileForTransitToPlatformFile(socket_handle)); 319 handle.size() - sizeof(int32_t),
brettw 2012/08/22 23:27:06 Can you add a comment why you do "- sizeof(int32_t
dmichael (off chromium) 2012/08/23 22:55:14 Oops, I meant to clean that up, thanks for pointin
320 IPC::PlatformFileForTransitToPlatformFile(socket_handle.descriptor()));
317 } 321 }
318 } 322 }
319 323
320 } // namespace proxy 324 } // namespace proxy
321 } // namespace ppapi 325 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698