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