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

Side by Side Diff: ppapi/shared_impl/ppb_video_decoder_shared.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 "ppapi/shared_impl/ppb_video_decoder_shared.h" 5 #include "ppapi/shared_impl/ppb_video_decoder_shared.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "gpu/command_buffer/client/gles2_implementation.h" 8 #include "gpu/command_buffer/client/gles2_implementation.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/shared_impl/resource_tracker.h" 10 #include "ppapi/shared_impl/resource_tracker.h"
(...skipping 30 matching lines...) Expand all
41 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(graphics_context); 41 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(graphics_context);
42 graphics_context_ = graphics_context; 42 graphics_context_ = graphics_context;
43 } 43 }
44 44
45 void PPB_VideoDecoder_Shared::Destroy() { 45 void PPB_VideoDecoder_Shared::Destroy() {
46 graphics_context_ = 0; 46 graphics_context_ = 0;
47 gles2_impl_ = NULL; 47 gles2_impl_ = NULL;
48 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(graphics_context_); 48 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(graphics_context_);
49 } 49 }
50 50
51 bool PPB_VideoDecoder_Shared::SetFlushCallback(PP_CompletionCallback callback) { 51 bool PPB_VideoDecoder_Shared::SetFlushCallback(
52 CHECK(callback.func); 52 scoped_refptr<TrackedCallback> callback) {
53 if (flush_callback_.get()) 53 if (flush_callback_.get())
54 return false; 54 return false;
55 flush_callback_ = new TrackedCallback(this, callback); 55 flush_callback_ = callback;
56 return true; 56 return true;
57 } 57 }
58 58
59 bool PPB_VideoDecoder_Shared::SetResetCallback(PP_CompletionCallback callback) { 59 bool PPB_VideoDecoder_Shared::SetResetCallback(
60 CHECK(callback.func); 60 scoped_refptr<TrackedCallback> callback) {
61 if (TrackedCallback::IsPending(reset_callback_)) 61 if (TrackedCallback::IsPending(reset_callback_))
62 return false; 62 return false;
63 reset_callback_ = new TrackedCallback(this, callback); 63 reset_callback_ = callback;
64 return true; 64 return true;
65 } 65 }
66 66
67 bool PPB_VideoDecoder_Shared::SetBitstreamBufferCallback( 67 bool PPB_VideoDecoder_Shared::SetBitstreamBufferCallback(
68 int32 bitstream_buffer_id, 68 int32 bitstream_buffer_id,
69 PP_CompletionCallback callback) { 69 scoped_refptr<TrackedCallback> callback) {
70 return bitstream_buffer_callbacks_.insert( 70 return bitstream_buffer_callbacks_.insert(
71 std::make_pair(bitstream_buffer_id, 71 std::make_pair(bitstream_buffer_id, callback)).second;
72 new TrackedCallback(this, callback))).second;
73 } 72 }
74 73
75 void PPB_VideoDecoder_Shared::RunFlushCallback(int32 result) { 74 void PPB_VideoDecoder_Shared::RunFlushCallback(int32 result) {
76 TrackedCallback::ClearAndRun(&flush_callback_, result); 75 TrackedCallback::ClearAndRun(&flush_callback_, result);
77 } 76 }
78 77
79 void PPB_VideoDecoder_Shared::RunResetCallback(int32 result) { 78 void PPB_VideoDecoder_Shared::RunResetCallback(int32 result) {
80 TrackedCallback::ClearAndRun(&reset_callback_, result); 79 TrackedCallback::ClearAndRun(&reset_callback_, result);
81 } 80 }
82 81
83 void PPB_VideoDecoder_Shared::RunBitstreamBufferCallback( 82 void PPB_VideoDecoder_Shared::RunBitstreamBufferCallback(
84 int32 bitstream_buffer_id, int32 result) { 83 int32 bitstream_buffer_id, int32 result) {
85 CallbackById::iterator it = 84 CallbackById::iterator it =
86 bitstream_buffer_callbacks_.find(bitstream_buffer_id); 85 bitstream_buffer_callbacks_.find(bitstream_buffer_id);
87 DCHECK(it != bitstream_buffer_callbacks_.end()); 86 DCHECK(it != bitstream_buffer_callbacks_.end());
88 scoped_refptr<TrackedCallback> cc = it->second; 87 scoped_refptr<TrackedCallback> cc = it->second;
89 bitstream_buffer_callbacks_.erase(it); 88 bitstream_buffer_callbacks_.erase(it);
90 cc->Run(PP_OK); 89 cc->Run(PP_OK);
91 } 90 }
92 91
93 void PPB_VideoDecoder_Shared::FlushCommandBuffer() { 92 void PPB_VideoDecoder_Shared::FlushCommandBuffer() {
94 if (gles2_impl_) 93 if (gles2_impl_)
95 gles2_impl_->Flush(); 94 gles2_impl_->Flush();
96 } 95 }
97 96
98 } // namespace ppapi 97 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/ppb_video_decoder_shared.h ('k') | ppapi/shared_impl/private/ppb_host_resolver_shared.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698