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

Side by Side Diff: webkit/plugins/ppapi/ppb_video_decoder_impl.cc

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: export AssertLockHeld Created 8 years, 6 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 "webkit/plugins/ppapi/ppb_video_decoder_impl.h" 5 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "gpu/command_buffer/client/gles2_implementation.h" 11 #include "gpu/command_buffer/client/gles2_implementation.h"
12 #include "media/video/picture.h" 12 #include "media/video/picture.h"
13 #include "ppapi/c/dev/pp_video_dev.h" 13 #include "ppapi/c/dev/pp_video_dev.h"
14 #include "ppapi/c/dev/ppb_video_decoder_dev.h" 14 #include "ppapi/c/dev/ppb_video_decoder_dev.h"
15 #include "ppapi/c/dev/ppp_video_decoder_dev.h" 15 #include "ppapi/c/dev/ppp_video_decoder_dev.h"
16 #include "ppapi/c/pp_completion_callback.h" 16 #include "ppapi/c/pp_completion_callback.h"
17 #include "ppapi/c/pp_errors.h" 17 #include "ppapi/c/pp_errors.h"
18 #include "ppapi/shared_impl/resource_tracker.h" 18 #include "ppapi/shared_impl/resource_tracker.h"
19 #include "ppapi/thunk/enter.h" 19 #include "ppapi/thunk/enter.h"
20 #include "webkit/plugins/ppapi/common.h" 20 #include "webkit/plugins/ppapi/common.h"
21 #include "webkit/plugins/ppapi/plugin_module.h" 21 #include "webkit/plugins/ppapi/plugin_module.h"
22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
23 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" 23 #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
24 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" 24 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
25 #include "webkit/plugins/ppapi/resource_helper.h" 25 #include "webkit/plugins/ppapi/resource_helper.h"
26 26
27 using ppapi::TrackedCallback;
27 using ppapi::thunk::EnterResourceNoLock; 28 using ppapi::thunk::EnterResourceNoLock;
28 using ppapi::thunk::PPB_Buffer_API; 29 using ppapi::thunk::PPB_Buffer_API;
29 using ppapi::thunk::PPB_Graphics3D_API; 30 using ppapi::thunk::PPB_Graphics3D_API;
30 using ppapi::thunk::PPB_VideoDecoder_API; 31 using ppapi::thunk::PPB_VideoDecoder_API;
31 32
32 namespace webkit { 33 namespace webkit {
33 namespace ppapi { 34 namespace ppapi {
34 35
35 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PP_Instance instance) 36 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PP_Instance instance)
36 : PPB_VideoDecoder_Shared(instance), 37 : PPB_VideoDecoder_Shared(instance),
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 this, command_buffer_route_id); 120 this, command_buffer_route_id);
120 if (!platform_video_decoder_) 121 if (!platform_video_decoder_)
121 return false; 122 return false;
122 123
123 FlushCommandBuffer(); 124 FlushCommandBuffer();
124 return platform_video_decoder_->Initialize(PPToMediaProfile(profile)); 125 return platform_video_decoder_->Initialize(PPToMediaProfile(profile));
125 } 126 }
126 127
127 int32_t PPB_VideoDecoder_Impl::Decode( 128 int32_t PPB_VideoDecoder_Impl::Decode(
128 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, 129 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
129 PP_CompletionCallback callback) { 130 scoped_refptr<TrackedCallback> callback) {
130 if (!callback.func)
131 return PP_ERROR_BLOCKS_MAIN_THREAD;
132
133 if (!platform_video_decoder_) 131 if (!platform_video_decoder_)
134 return PP_ERROR_BADRESOURCE; 132 return PP_ERROR_BADRESOURCE;
135 133
136 EnterResourceNoLock<PPB_Buffer_API> enter(bitstream_buffer->data, true); 134 EnterResourceNoLock<PPB_Buffer_API> enter(bitstream_buffer->data, true);
137 if (enter.failed()) 135 if (enter.failed())
138 return PP_ERROR_FAILED; 136 return PP_ERROR_FAILED;
139 137
140 PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); 138 PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object());
141 media::BitstreamBuffer decode_buffer( 139 media::BitstreamBuffer decode_buffer(
142 bitstream_buffer->id, 140 bitstream_buffer->id,
(...skipping 28 matching lines...) Expand all
171 } 169 }
172 170
173 void PPB_VideoDecoder_Impl::ReusePictureBuffer(int32_t picture_buffer_id) { 171 void PPB_VideoDecoder_Impl::ReusePictureBuffer(int32_t picture_buffer_id) {
174 if (!platform_video_decoder_) 172 if (!platform_video_decoder_)
175 return; 173 return;
176 174
177 FlushCommandBuffer(); 175 FlushCommandBuffer();
178 platform_video_decoder_->ReusePictureBuffer(picture_buffer_id); 176 platform_video_decoder_->ReusePictureBuffer(picture_buffer_id);
179 } 177 }
180 178
181 int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { 179 int32_t PPB_VideoDecoder_Impl::Flush(scoped_refptr<TrackedCallback> callback) {
182 if (!callback.func)
183 return PP_ERROR_BLOCKS_MAIN_THREAD;
184
185 if (!platform_video_decoder_) 180 if (!platform_video_decoder_)
186 return PP_ERROR_BADRESOURCE; 181 return PP_ERROR_BADRESOURCE;
187 182
188 if (!SetFlushCallback(callback)) 183 if (!SetFlushCallback(callback))
189 return PP_ERROR_INPROGRESS; 184 return PP_ERROR_INPROGRESS;
190 185
191 FlushCommandBuffer(); 186 FlushCommandBuffer();
192 platform_video_decoder_->Flush(); 187 platform_video_decoder_->Flush();
193 return PP_OK_COMPLETIONPENDING; 188 return PP_OK_COMPLETIONPENDING;
194 } 189 }
195 190
196 int32_t PPB_VideoDecoder_Impl::Reset(PP_CompletionCallback callback) { 191 int32_t PPB_VideoDecoder_Impl::Reset(scoped_refptr<TrackedCallback> callback) {
197 if (!callback.func)
198 return PP_ERROR_BLOCKS_MAIN_THREAD;
199
200 if (!platform_video_decoder_) 192 if (!platform_video_decoder_)
201 return PP_ERROR_BADRESOURCE; 193 return PP_ERROR_BADRESOURCE;
202 194
203 if (!SetResetCallback(callback)) 195 if (!SetResetCallback(callback))
204 return PP_ERROR_INPROGRESS; 196 return PP_ERROR_INPROGRESS;
205 197
206 FlushCommandBuffer(); 198 FlushCommandBuffer();
207 platform_video_decoder_->Reset(); 199 platform_video_decoder_->Reset();
208 return PP_OK_COMPLETIONPENDING; 200 return PP_OK_COMPLETIONPENDING;
209 } 201 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 void PPB_VideoDecoder_Impl::NotifyFlushDone() { 265 void PPB_VideoDecoder_Impl::NotifyFlushDone() {
274 RunFlushCallback(PP_OK); 266 RunFlushCallback(PP_OK);
275 } 267 }
276 268
277 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { 269 void PPB_VideoDecoder_Impl::NotifyInitializeDone() {
278 NOTREACHED() << "PlatformVideoDecoder::Initialize() is synchronous!"; 270 NOTREACHED() << "PlatformVideoDecoder::Initialize() is synchronous!";
279 } 271 }
280 272
281 } // namespace ppapi 273 } // namespace ppapi
282 } // namespace webkit 274 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_video_decoder_impl.h ('k') | webkit/plugins/ppapi/ppb_websocket_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698