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

Side by Side Diff: ppapi/shared_impl/ppb_video_decoder_shared.cc

Issue 10909244: PPAPI: Get TrackedCallback ready for running on non-main threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged. Created 8 years, 1 month 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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( 51 bool PPB_VideoDecoder_Shared::SetFlushCallback(
52 scoped_refptr<TrackedCallback> callback) { 52 scoped_refptr<TrackedCallback> callback) {
53 if (flush_callback_.get()) 53 if (TrackedCallback::IsPending(flush_callback_))
54 return false; 54 return false;
55 flush_callback_ = callback; 55 flush_callback_ = callback;
56 return true; 56 return true;
57 } 57 }
58 58
59 bool PPB_VideoDecoder_Shared::SetResetCallback( 59 bool PPB_VideoDecoder_Shared::SetResetCallback(
60 scoped_refptr<TrackedCallback> callback) { 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_ = 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 scoped_refptr<TrackedCallback> 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, callback)).second; 71 std::make_pair(bitstream_buffer_id, callback)).second;
72 } 72 }
73 73
74 void PPB_VideoDecoder_Shared::RunFlushCallback(int32 result) { 74 void PPB_VideoDecoder_Shared::RunFlushCallback(int32 result) {
75 TrackedCallback::ClearAndRun(&flush_callback_, result); 75 flush_callback_->Run(result);
76 } 76 }
77 77
78 void PPB_VideoDecoder_Shared::RunResetCallback(int32 result) { 78 void PPB_VideoDecoder_Shared::RunResetCallback(int32 result) {
79 TrackedCallback::ClearAndRun(&reset_callback_, result); 79 reset_callback_->Run(result);
80 } 80 }
81 81
82 void PPB_VideoDecoder_Shared::RunBitstreamBufferCallback( 82 void PPB_VideoDecoder_Shared::RunBitstreamBufferCallback(
83 int32 bitstream_buffer_id, int32 result) { 83 int32 bitstream_buffer_id, int32 result) {
84 CallbackById::iterator it = 84 CallbackById::iterator it =
85 bitstream_buffer_callbacks_.find(bitstream_buffer_id); 85 bitstream_buffer_callbacks_.find(bitstream_buffer_id);
86 DCHECK(it != bitstream_buffer_callbacks_.end()); 86 DCHECK(it != bitstream_buffer_callbacks_.end());
87 scoped_refptr<TrackedCallback> cc = it->second; 87 scoped_refptr<TrackedCallback> cc = it->second;
88 bitstream_buffer_callbacks_.erase(it); 88 bitstream_buffer_callbacks_.erase(it);
89 cc->Run(PP_OK); 89 cc->Run(PP_OK);
90 } 90 }
91 91
92 void PPB_VideoDecoder_Shared::FlushCommandBuffer() { 92 void PPB_VideoDecoder_Shared::FlushCommandBuffer() {
93 if (gles2_impl_) 93 if (gles2_impl_)
94 gles2_impl_->Flush(); 94 gles2_impl_->Flush();
95 } 95 }
96 96
97 } // namespace ppapi 97 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/ppb_video_capture_shared.cc ('k') | ppapi/shared_impl/private/ppb_host_resolver_shared.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698