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

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

Issue 9053003: Convert ppapi/shared to use TrackedCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef PPAPI_SHARED_IMPL_PPB_VIDEO_DECODER_SHARED_H_ 5 #ifndef PPAPI_SHARED_IMPL_PPB_VIDEO_DECODER_SHARED_H_
6 #define PPAPI_SHARED_IMPL_PPB_VIDEO_DECODER_SHARED_H_ 6 #define PPAPI_SHARED_IMPL_PPB_VIDEO_DECODER_SHARED_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "ppapi/c/dev/ppb_video_decoder_dev.h" 13 #include "ppapi/c/dev/ppb_video_decoder_dev.h"
14 #include "ppapi/shared_impl/resource.h" 14 #include "ppapi/shared_impl/resource.h"
15 #include "ppapi/shared_impl/tracked_callback.h"
15 #include "ppapi/thunk/ppb_video_decoder_api.h" 16 #include "ppapi/thunk/ppb_video_decoder_api.h"
16 17
17 namespace gpu { 18 namespace gpu {
18 namespace gles2 { 19 namespace gles2 {
19 class GLES2Implementation; 20 class GLES2Implementation;
20 } // namespace gles2 21 } // namespace gles2
21 } // namespace gpu 22 } // namespace gpu
22 23
23 namespace ppapi { 24 namespace ppapi {
24 25
25 // Implements the logic to set and run callbacks for various video decoder 26 // Implements the logic to set and run callbacks for various video decoder
26 // events. Both the proxy and the renderer implementation share this code. 27 // events. Both the proxy and the renderer implementation share this code.
27 class PPAPI_SHARED_EXPORT PPB_VideoDecoder_Shared 28 class PPAPI_SHARED_EXPORT PPB_VideoDecoder_Shared
28 : NON_EXPORTED_BASE(public thunk::PPB_VideoDecoder_API) { 29 : public Resource,
30 NON_EXPORTED_BASE(public thunk::PPB_VideoDecoder_API) {
29 public: 31 public:
30 PPB_VideoDecoder_Shared(); 32 PPB_VideoDecoder_Shared(PP_Instance instance);
viettrungluu 2012/01/03 22:43:46 explicit
33 PPB_VideoDecoder_Shared(const HostResource& host_resource);
viettrungluu 2012/01/03 22:43:46 "
31 virtual ~PPB_VideoDecoder_Shared(); 34 virtual ~PPB_VideoDecoder_Shared();
32 35
36 // Resource overrides.
37 virtual thunk::PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() OVERRIDE;
38
33 // PPB_VideoDecoder_API implementation. 39 // PPB_VideoDecoder_API implementation.
34 virtual void Destroy() OVERRIDE; 40 virtual void Destroy() OVERRIDE;
35 41
36 protected: 42 protected:
37 bool SetFlushCallback(PP_CompletionCallback callback); 43 bool SetFlushCallback(PP_CompletionCallback callback);
38 bool SetResetCallback(PP_CompletionCallback callback); 44 bool SetResetCallback(PP_CompletionCallback callback);
39 bool SetBitstreamBufferCallback( 45 bool SetBitstreamBufferCallback(
40 int32 bitstream_buffer_id, PP_CompletionCallback callback); 46 int32 bitstream_buffer_id, PP_CompletionCallback callback);
41 47
42 void RunFlushCallback(int32 result); 48 void RunFlushCallback(int32 result);
43 void RunResetCallback(int32 result); 49 void RunResetCallback(int32 result);
44 void RunBitstreamBufferCallback(int32 bitstream_buffer_id, int32 result); 50 void RunBitstreamBufferCallback(int32 bitstream_buffer_id, int32 result);
45 51
46 // Tell command buffer to process all commands it has received so far. 52 // Tell command buffer to process all commands it has received so far.
47 void FlushCommandBuffer(); 53 void FlushCommandBuffer();
48 54
49 // Initialize the underlying decoder. 55 // Initialize the underlying decoder.
50 void InitCommon(PP_Resource graphics_context, 56 void InitCommon(PP_Resource graphics_context,
51 gpu::gles2::GLES2Implementation* gles2_impl); 57 gpu::gles2::GLES2Implementation* gles2_impl);
52 58
53 private: 59 private:
54 // Key: bitstream_buffer_id, value: callback to run when bitstream decode is 60 // Key: bitstream_buffer_id, value: callback to run when bitstream decode is
55 // done. 61 // done.
56 typedef std::map<int32, PP_CompletionCallback> CallbackById; 62 typedef std::map<int32, scoped_refptr<TrackedCallback> > CallbackById;
57 63
58 PP_CompletionCallback flush_callback_; 64 scoped_refptr<TrackedCallback> flush_callback_;
59 PP_CompletionCallback reset_callback_; 65 scoped_refptr<TrackedCallback> reset_callback_;
60 CallbackById bitstream_buffer_callbacks_; 66 CallbackById bitstream_buffer_callbacks_;
61 67
62 // The resource ID of the underlying Graphics3D object being used. Used only 68 // The resource ID of the underlying Graphics3D object being used. Used only
63 // for reference counting to keep it alive for the lifetime of |*this|. 69 // for reference counting to keep it alive for the lifetime of |*this|.
64 PP_Resource graphics_context_; 70 PP_Resource graphics_context_;
65 71
66 // Reference to the GLES2Implementation owned by |graphics_context_|. 72 // Reference to the GLES2Implementation owned by |graphics_context_|.
67 // Graphics3D is guaranteed to be alive for the lifetime of this class. 73 // Graphics3D is guaranteed to be alive for the lifetime of this class.
68 // In the out-of-process case, Graphics3D's gles2_impl() exists in the plugin 74 // In the out-of-process case, Graphics3D's gles2_impl() exists in the plugin
69 // process only, so gles2_impl_ is NULL in that case. 75 // process only, so gles2_impl_ is NULL in that case.
70 gpu::gles2::GLES2Implementation* gles2_impl_; 76 gpu::gles2::GLES2Implementation* gles2_impl_;
71 77
72 DISALLOW_COPY_AND_ASSIGN(PPB_VideoDecoder_Shared); 78 DISALLOW_COPY_AND_ASSIGN(PPB_VideoDecoder_Shared);
73 }; 79 };
74 80
75 } // namespace ppapi 81 } // namespace ppapi
76 82
77 #endif // PPAPI_SHARED_IMPL_PPB_VIDEO_DECODER_SHARED_H_ 83 #endif // PPAPI_SHARED_IMPL_PPB_VIDEO_DECODER_SHARED_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698