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

Side by Side Diff: content/common/gpu/client/gpu_video_decode_accelerator_host.h

Issue 10852009: Clarify ownership of GpuVideoDecodeAcceleratorHost and avoid crash on context loss. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 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 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_
6 #define CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/non_thread_safe.h" 11 #include "base/threading/non_thread_safe.h"
12 #include "ipc/ipc_listener.h" 12 #include "ipc/ipc_listener.h"
13 #include "media/video/video_decode_accelerator.h" 13 #include "media/video/video_decode_accelerator.h"
14 14
15 class GpuChannelHost; 15 class GpuChannelHost;
16 16
17 // This class is used to talk to VideoDecodeAccelerator in the Gpu process 17 // This class is used to talk to VideoDecodeAccelerator in the Gpu process
18 // through IPC messages. 18 // through IPC messages.
19 class GpuVideoDecodeAcceleratorHost 19 class GpuVideoDecodeAcceleratorHost
20 : public IPC::Listener, 20 : public IPC::Listener,
21 public media::VideoDecodeAccelerator, 21 public media::VideoDecodeAccelerator,
22 public base::NonThreadSafe { 22 public base::NonThreadSafe {
23 public: 23 public:
24 // |channel| is used to send IPC messages to GPU process. 24 // |channel| is used to send IPC messages to GPU process.
25 GpuVideoDecodeAcceleratorHost(GpuChannelHost* channel, 25 GpuVideoDecodeAcceleratorHost(GpuChannelHost* channel,
26 int32 decoder_route_id, 26 int32 decoder_route_id,
27 media::VideoDecodeAccelerator::Client* client); 27 media::VideoDecodeAccelerator::Client* client);
28 virtual ~GpuVideoDecodeAcceleratorHost();
29 28
30 // IPC::Listener implementation. 29 // IPC::Listener implementation.
31 virtual void OnChannelError() OVERRIDE; 30 virtual void OnChannelError() OVERRIDE;
32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 31 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
33 32
34 // media::VideoDecodeAccelerator implementation. 33 // media::VideoDecodeAccelerator implementation.
35 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; 34 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE;
36 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; 35 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
37 virtual void AssignPictureBuffers( 36 virtual void AssignPictureBuffers(
38 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; 37 const std::vector<media::PictureBuffer>& buffers) OVERRIDE;
39 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; 38 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE;
40 virtual void Flush() OVERRIDE; 39 virtual void Flush() OVERRIDE;
41 virtual void Reset() OVERRIDE; 40 virtual void Reset() OVERRIDE;
42 virtual void Destroy() OVERRIDE; 41 virtual void Destroy() OVERRIDE;
43 42
44 private: 43 private:
44 // Only Destroy() should be deleting |this|.
45 virtual ~GpuVideoDecodeAcceleratorHost();
46
45 void Send(IPC::Message* message); 47 void Send(IPC::Message* message);
46 48
47 void OnBitstreamBufferProcessed(int32 bitstream_buffer_id); 49 void OnBitstreamBufferProcessed(int32 bitstream_buffer_id);
48 void OnProvidePictureBuffer(uint32 num_requested_buffers, 50 void OnProvidePictureBuffer(uint32 num_requested_buffers,
49 const gfx::Size& buffer_size, 51 const gfx::Size& buffer_size,
50 uint32 texture_target); 52 uint32 texture_target);
51 void OnDismissPictureBuffer(int32 picture_buffer_id); 53 void OnDismissPictureBuffer(int32 picture_buffer_id);
52 void OnPictureReady(int32 picture_buffer_id, int32 bitstream_buffer_id); 54 void OnPictureReady(int32 picture_buffer_id, int32 bitstream_buffer_id);
53 void OnFlushDone(); 55 void OnFlushDone();
54 void OnResetDone(); 56 void OnResetDone();
55 void OnErrorNotification(uint32 error); 57 void OnErrorNotification(uint32 error);
56 58
57 // Sends IPC messages to the Gpu process. 59 // Sends IPC messages to the Gpu process.
58 GpuChannelHost* channel_; 60 GpuChannelHost* channel_;
59 61
60 // Route ID for the associated decoder in the GPU process. 62 // Route ID for the associated decoder in the GPU process.
61 // TODO(fischman): storing route_id's for GPU process entities in the client 63 // TODO(fischman): storing route_id's for GPU process entities in the client
62 // process is vulnerable to GPU process crashing & being respawned, and 64 // process is vulnerable to GPU process crashing & being respawned, and
63 // attempting to use an outdated or reused route id. 65 // attempting to use an outdated or reused route id.
64 int32 decoder_route_id_; 66 int32 decoder_route_id_;
65 67
66 // Reference to the client that will receive callbacks from the decoder. 68 // Reference to the client that will receive callbacks from the decoder.
67 media::VideoDecodeAccelerator::Client* client_; 69 media::VideoDecodeAccelerator::Client* client_;
68 70
69 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecodeAcceleratorHost); 71 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecodeAcceleratorHost);
70 }; 72 };
71 73
72 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ 74 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_
OLDNEW
« no previous file with comments | « content/common/gpu/client/command_buffer_proxy_impl.cc ('k') | content/common/gpu/client/gpu_video_decode_accelerator_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698