Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ | |
| 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ | |
| 7 | |
| 8 #include "base/memory/weak_ptr.h" | |
| 9 #include "base/threading/non_thread_safe.h" | |
| 10 #include "ipc/ipc_listener.h" | |
| 11 #include "media/video/jpeg_decode_accelerator.h" | |
| 12 #include "ui/gfx/geometry/size.h" | |
| 13 | |
| 14 namespace content { | |
| 15 class GpuChannelHost; | |
| 16 | |
| 17 // This class is used to talk to JpegDecodeAccelerator in the GPU process | |
| 18 // through IPC messages. | |
| 19 class GpuJpegDecodeAcceleratorHost | |
| 20 : public IPC::Listener, | |
| 21 public media::JpegDecodeAccelerator, | |
| 22 public base::NonThreadSafe, | |
| 23 public base::SupportsWeakPtr<GpuJpegDecodeAcceleratorHost> { | |
| 24 public: | |
| 25 // |this| is guaranteed not to outlive |channel|. (See comments for | |
| 26 // |channel_|.) | |
| 27 // |io_message_loop| is IO thread loop for thread checking. | |
| 28 GpuJpegDecodeAcceleratorHost( | |
| 29 GpuChannelHost* channel, | |
| 30 int32 route_id, | |
| 31 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); | |
| 32 | |
| 33 // IPC::Listener implementation. | |
| 34 void OnChannelError() override; | |
| 35 bool OnMessageReceived(const IPC::Message& message) override; | |
| 36 | |
| 37 // media::JpegDecodeAccelerator implementation. | |
| 38 bool Initialize(media::JpegDecodeAccelerator::Client* client) override; | |
| 39 void Decode(const media::BitstreamBuffer& bitstream_buffer, | |
| 40 const scoped_refptr<media::VideoFrame>& video_frame) override; | |
| 41 void Destroy() override; | |
| 42 | |
| 43 private: | |
| 44 // Only Destroy() should be deleting |this|. | |
| 45 ~GpuJpegDecodeAcceleratorHost() override; | |
| 46 | |
| 47 // Notify |client_| of an error. Posts a task to avoid re-entrancy. | |
| 48 void PostNotifyError(int32_t bitstream_buffer_id, Error error); | |
| 49 | |
| 50 void Send(IPC::Message* message); | |
| 51 | |
| 52 void OnVideoFrameReady(int32_t bitstream_buffer_id); | |
| 53 void OnNotifyError(int32_t bitstream_buffer_id, Error error); | |
| 54 | |
| 55 // Unowned reference to the GpuChannelHost to send IPC messages to the GPU | |
| 56 // process. |channel_| is always valid as long as it is not NULL. | |
| 57 GpuChannelHost* channel_; | |
| 58 | |
| 59 Client* client_; | |
| 60 | |
| 61 // Route ID for the associated decoder in the GPU process. | |
| 62 int32 decoder_route_id_; | |
| 63 | |
| 64 // IO message loop. | |
| 65 scoped_refptr<base::MessageLoopProxy> io_message_loop_; | |
|
mcasas
2015/04/22 01:23:53
const
kcwu
2015/04/22 14:43:34
Done.
| |
| 66 | |
| 67 // WeakPtr factory for posting tasks back to itself. | |
| 68 base::WeakPtrFactory<GpuJpegDecodeAcceleratorHost> weak_this_factory_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(GpuJpegDecodeAcceleratorHost); | |
| 71 }; | |
| 72 | |
| 73 } // namespace content | |
| 74 | |
| 75 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ | |
| OLD | NEW |