OLD | NEW |
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/renderer/pepper/audio_helper.h" | 5 #include "content/renderer/pepper/audio_helper.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/renderer/pepper/common.h" | 8 #include "content/renderer/pepper/common.h" |
9 #include "ppapi/c/pp_completion_callback.h" | 9 #include "ppapi/c/pp_completion_callback.h" |
10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 *shm_size = shared_memory_size_for_create_callback_; | 46 *shm_size = shared_memory_size_for_create_callback_; |
47 return PP_OK; | 47 return PP_OK; |
48 } | 48 } |
49 return PP_ERROR_FAILED; | 49 return PP_ERROR_FAILED; |
50 } | 50 } |
51 | 51 |
52 void AudioHelper::StreamCreated(base::SharedMemoryHandle shared_memory_handle, | 52 void AudioHelper::StreamCreated(base::SharedMemoryHandle shared_memory_handle, |
53 size_t shared_memory_size, | 53 size_t shared_memory_size, |
54 base::SyncSocket::Handle socket_handle) { | 54 base::SyncSocket::Handle socket_handle) { |
55 if (TrackedCallback::IsPending(create_callback_)) { | 55 if (TrackedCallback::IsPending(create_callback_)) { |
56 // Trusted side of proxy can specify a callback to recieve handles. In | 56 // Trusted side of proxy can specify a callback to receive handles. In |
57 // this case we don't need to map any data or start the thread since it | 57 // this case we don't need to map any data or start the thread since it |
58 // will be handled by the proxy. | 58 // will be handled by the proxy. |
59 shared_memory_for_create_callback_.reset( | 59 shared_memory_for_create_callback_.reset( |
60 new base::SharedMemory(shared_memory_handle, false)); | 60 new base::SharedMemory(shared_memory_handle, false)); |
61 shared_memory_size_for_create_callback_ = shared_memory_size; | 61 shared_memory_size_for_create_callback_ = shared_memory_size; |
62 socket_for_create_callback_.reset(new base::SyncSocket(socket_handle)); | 62 socket_for_create_callback_.reset(new base::SyncSocket(socket_handle)); |
63 | 63 |
64 create_callback_->Run(PP_OK); | 64 create_callback_->Run(PP_OK); |
65 | 65 |
66 // It might be nice to close the handles here to free up some system | 66 // It might be nice to close the handles here to free up some system |
67 // resources, but we can't since there's a race condition. The handles must | 67 // resources, but we can't since there's a race condition. The handles must |
68 // be valid until they're sent over IPC, which is done from the I/O thread | 68 // be valid until they're sent over IPC, which is done from the I/O thread |
69 // which will often get done after this code executes. We could do | 69 // which will often get done after this code executes. We could do |
70 // something more elaborate like an ACK from the plugin or post a task to | 70 // something more elaborate like an ACK from the plugin or post a task to |
71 // the I/O thread and back, but this extra complexity doesn't seem worth it | 71 // the I/O thread and back, but this extra complexity doesn't seem worth it |
72 // just to clean up these handles faster. | 72 // just to clean up these handles faster. |
73 } else { | 73 } else { |
74 OnSetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle); | 74 OnSetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle); |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 void AudioHelper::SetCreateCallback( | 78 void AudioHelper::SetCreateCallback( |
79 scoped_refptr<ppapi::TrackedCallback> create_callback) { | 79 scoped_refptr<ppapi::TrackedCallback> create_callback) { |
80 DCHECK(!TrackedCallback::IsPending(create_callback_)); | 80 DCHECK(!TrackedCallback::IsPending(create_callback_)); |
81 create_callback_ = create_callback; | 81 create_callback_ = create_callback; |
82 } | 82 } |
83 | 83 |
84 } // namespace content | 84 } // namespace content |
OLD | NEW |