OLD | NEW |
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_CHANNEL_HOST_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
6 #define CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 29 matching lines...) Expand all Loading... |
40 } | 40 } |
41 | 41 |
42 namespace IPC { | 42 namespace IPC { |
43 class SyncMessageFilter; | 43 class SyncMessageFilter; |
44 } | 44 } |
45 | 45 |
46 struct GpuListenerInfo { | 46 struct GpuListenerInfo { |
47 GpuListenerInfo(); | 47 GpuListenerInfo(); |
48 ~GpuListenerInfo(); | 48 ~GpuListenerInfo(); |
49 | 49 |
50 base::WeakPtr<IPC::Channel::Listener> listener; | 50 base::WeakPtr<IPC::Listener> listener; |
51 scoped_refptr<base::MessageLoopProxy> loop; | 51 scoped_refptr<base::MessageLoopProxy> loop; |
52 }; | 52 }; |
53 | 53 |
54 class CONTENT_EXPORT GpuChannelHostFactory { | 54 class CONTENT_EXPORT GpuChannelHostFactory { |
55 public: | 55 public: |
56 virtual ~GpuChannelHostFactory() {} | 56 virtual ~GpuChannelHostFactory() {} |
57 | 57 |
58 virtual bool IsMainThread() = 0; | 58 virtual bool IsMainThread() = 0; |
59 virtual bool IsIOThread() = 0; | 59 virtual bool IsIOThread() = 0; |
60 virtual MessageLoop* GetMainLoop() = 0; | 60 virtual MessageLoop* GetMainLoop() = 0; |
61 virtual scoped_refptr<base::MessageLoopProxy> GetIOLoopProxy() = 0; | 61 virtual scoped_refptr<base::MessageLoopProxy> GetIOLoopProxy() = 0; |
62 virtual base::WaitableEvent* GetShutDownEvent() = 0; | 62 virtual base::WaitableEvent* GetShutDownEvent() = 0; |
63 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory(uint32 size) = 0; | 63 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory(uint32 size) = 0; |
64 virtual int32 CreateViewCommandBuffer( | 64 virtual int32 CreateViewCommandBuffer( |
65 int32 surface_id, const GPUCreateCommandBufferConfig& init_params) = 0; | 65 int32 surface_id, const GPUCreateCommandBufferConfig& init_params) = 0; |
66 virtual GpuChannelHost* EstablishGpuChannelSync( | 66 virtual GpuChannelHost* EstablishGpuChannelSync( |
67 content::CauseForGpuLaunch) = 0; | 67 content::CauseForGpuLaunch) = 0; |
68 }; | 68 }; |
69 | 69 |
70 // Encapsulates an IPC channel between the client and one GPU process. | 70 // Encapsulates an IPC channel between the client and one GPU process. |
71 // On the GPU process side there's a corresponding GpuChannel. | 71 // On the GPU process side there's a corresponding GpuChannel. |
72 class GpuChannelHost : public IPC::Message::Sender, | 72 class GpuChannelHost : public IPC::Sender, |
73 public base::RefCountedThreadSafe<GpuChannelHost> { | 73 public base::RefCountedThreadSafe<GpuChannelHost> { |
74 public: | 74 public: |
75 enum State { | 75 enum State { |
76 // Not yet connected. | 76 // Not yet connected. |
77 kUnconnected, | 77 kUnconnected, |
78 // Ready to use. | 78 // Ready to use. |
79 kConnected, | 79 kConnected, |
80 // An error caused the host to become disconnected. Recreate channel to | 80 // An error caused the host to become disconnected. Recreate channel to |
81 // reestablish connection. | 81 // reestablish connection. |
82 kLost | 82 kLost |
(...skipping 11 matching lines...) Expand all Loading... |
94 | 94 |
95 // Change state to kLost. | 95 // Change state to kLost. |
96 void SetStateLost(); | 96 void SetStateLost(); |
97 | 97 |
98 // The GPU stats reported by the GPU process. | 98 // The GPU stats reported by the GPU process. |
99 void set_gpu_info(const content::GPUInfo& gpu_info); | 99 void set_gpu_info(const content::GPUInfo& gpu_info); |
100 const content::GPUInfo& gpu_info() const; | 100 const content::GPUInfo& gpu_info() const; |
101 | 101 |
102 void OnChannelError(); | 102 void OnChannelError(); |
103 | 103 |
104 // IPC::Message::Sender implementation: | 104 // IPC::Sender implementation: |
105 virtual bool Send(IPC::Message* msg) OVERRIDE; | 105 virtual bool Send(IPC::Message* msg) OVERRIDE; |
106 | 106 |
107 // Create and connect to a command buffer in the GPU process. | 107 // Create and connect to a command buffer in the GPU process. |
108 CommandBufferProxy* CreateViewCommandBuffer( | 108 CommandBufferProxy* CreateViewCommandBuffer( |
109 int32 surface_id, | 109 int32 surface_id, |
110 CommandBufferProxy* share_group, | 110 CommandBufferProxy* share_group, |
111 const std::string& allowed_extensions, | 111 const std::string& allowed_extensions, |
112 const std::vector<int32>& attribs, | 112 const std::vector<int32>& attribs, |
113 const GURL& active_url, | 113 const GURL& active_url, |
114 gfx::GpuPreference gpu_preference); | 114 gfx::GpuPreference gpu_preference); |
(...skipping 11 matching lines...) Expand all Loading... |
126 // Returned pointer is owned by the CommandBufferProxy for |route_id|. | 126 // Returned pointer is owned by the CommandBufferProxy for |route_id|. |
127 GpuVideoDecodeAcceleratorHost* CreateVideoDecoder( | 127 GpuVideoDecodeAcceleratorHost* CreateVideoDecoder( |
128 int command_buffer_route_id, | 128 int command_buffer_route_id, |
129 media::VideoCodecProfile profile, | 129 media::VideoCodecProfile profile, |
130 media::VideoDecodeAccelerator::Client* client); | 130 media::VideoDecodeAccelerator::Client* client); |
131 | 131 |
132 // Destroy a command buffer created by this channel. | 132 // Destroy a command buffer created by this channel. |
133 void DestroyCommandBuffer(CommandBufferProxy* command_buffer); | 133 void DestroyCommandBuffer(CommandBufferProxy* command_buffer); |
134 | 134 |
135 // Add a route for the current message loop. | 135 // Add a route for the current message loop. |
136 void AddRoute(int route_id, base::WeakPtr<IPC::Channel::Listener> listener); | 136 void AddRoute(int route_id, base::WeakPtr<IPC::Listener> listener); |
137 void RemoveRoute(int route_id); | 137 void RemoveRoute(int route_id); |
138 | 138 |
139 GpuChannelHostFactory* factory() const { return factory_; } | 139 GpuChannelHostFactory* factory() const { return factory_; } |
140 int gpu_host_id() const { return gpu_host_id_; } | 140 int gpu_host_id() const { return gpu_host_id_; } |
141 base::ProcessId gpu_pid() const { return channel_->peer_pid(); } | 141 base::ProcessId gpu_pid() const { return channel_->peer_pid(); } |
142 int client_id() const { return client_id_; } | 142 int client_id() const { return client_id_; } |
143 | 143 |
144 private: | 144 private: |
145 friend class base::RefCountedThreadSafe<GpuChannelHost>; | 145 friend class base::RefCountedThreadSafe<GpuChannelHost>; |
146 virtual ~GpuChannelHost(); | 146 virtual ~GpuChannelHost(); |
147 | 147 |
148 // A filter used internally to route incoming messages from the IO thread | 148 // A filter used internally to route incoming messages from the IO thread |
149 // to the correct message loop. | 149 // to the correct message loop. |
150 class MessageFilter : public IPC::ChannelProxy::MessageFilter { | 150 class MessageFilter : public IPC::ChannelProxy::MessageFilter { |
151 public: | 151 public: |
152 explicit MessageFilter(GpuChannelHost* parent); | 152 explicit MessageFilter(GpuChannelHost* parent); |
153 | 153 |
154 void AddRoute(int route_id, | 154 void AddRoute(int route_id, |
155 base::WeakPtr<IPC::Channel::Listener> listener, | 155 base::WeakPtr<IPC::Listener> listener, |
156 scoped_refptr<base::MessageLoopProxy> loop); | 156 scoped_refptr<base::MessageLoopProxy> loop); |
157 void RemoveRoute(int route_id); | 157 void RemoveRoute(int route_id); |
158 | 158 |
159 // IPC::ChannelProxy::MessageFilter implementation: | 159 // IPC::ChannelProxy::MessageFilter implementation: |
160 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 160 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
161 virtual void OnChannelError() OVERRIDE; | 161 virtual void OnChannelError() OVERRIDE; |
162 | 162 |
163 private: | 163 private: |
164 virtual ~MessageFilter(); | 164 virtual ~MessageFilter(); |
165 | 165 |
(...skipping 22 matching lines...) Expand all Loading... |
188 // for calls from contexts that may live on the compositor or main thread. | 188 // for calls from contexts that may live on the compositor or main thread. |
189 mutable base::Lock context_lock_; | 189 mutable base::Lock context_lock_; |
190 | 190 |
191 // A filter for sending messages from thread other than the main thread. | 191 // A filter for sending messages from thread other than the main thread. |
192 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; | 192 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; |
193 | 193 |
194 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); | 194 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); |
195 }; | 195 }; |
196 | 196 |
197 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 197 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
OLD | NEW |