| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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 CHROME_RENDERER_GPU_CHANNEL_HOST_H_ | |
| 6 #define CHROME_RENDERER_GPU_CHANNEL_HOST_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/hash_tables.h" | |
| 13 #include "base/process_util.h" | |
| 14 #include "base/scoped_ptr.h" | |
| 15 #include "content/common/gpu_info.h" | |
| 16 #include "content/common/message_router.h" | |
| 17 #include "ipc/ipc_channel_handle.h" | |
| 18 #include "ipc/ipc_sync_channel.h" | |
| 19 #include "ui/gfx/native_widget_types.h" | |
| 20 #include "ui/gfx/size.h" | |
| 21 | |
| 22 class CommandBufferProxy; | |
| 23 class GpuVideoServiceHost; | |
| 24 | |
| 25 // Encapsulates an IPC channel between the renderer and one plugin process. | |
| 26 // On the plugin side there's a corresponding GpuChannel. | |
| 27 class GpuChannelHost : public IPC::Channel::Listener, | |
| 28 public IPC::Message::Sender, | |
| 29 public base::RefCountedThreadSafe<GpuChannelHost> { | |
| 30 public: | |
| 31 enum State { | |
| 32 // Not yet connected. | |
| 33 kUnconnected, | |
| 34 // Ready to use. | |
| 35 kConnected, | |
| 36 // An error caused the host to become disconnected. Recreate channel to | |
| 37 // reestablish connection. | |
| 38 kLost | |
| 39 }; | |
| 40 | |
| 41 // Called on the render thread | |
| 42 GpuChannelHost(); | |
| 43 ~GpuChannelHost(); | |
| 44 | |
| 45 // Connect to GPU process channel. | |
| 46 void Connect(const IPC::ChannelHandle& channel_handle, | |
| 47 base::ProcessHandle renderer_process_for_gpu); | |
| 48 | |
| 49 State state() const { return state_; } | |
| 50 | |
| 51 // Change state to kLost. | |
| 52 void SetStateLost(); | |
| 53 | |
| 54 // The GPU stats reported by the GPU process. | |
| 55 void set_gpu_info(const GPUInfo& gpu_info); | |
| 56 const GPUInfo& gpu_info() const; | |
| 57 | |
| 58 // IPC::Channel::Listener implementation: | |
| 59 virtual bool OnMessageReceived(const IPC::Message& msg); | |
| 60 virtual void OnChannelConnected(int32 peer_pid); | |
| 61 virtual void OnChannelError(); | |
| 62 | |
| 63 // IPC::Message::Sender implementation: | |
| 64 virtual bool Send(IPC::Message* msg); | |
| 65 | |
| 66 // Create and connect to a command buffer in the GPU process. | |
| 67 CommandBufferProxy* CreateViewCommandBuffer( | |
| 68 int render_view_id, | |
| 69 const std::string& allowed_extensions, | |
| 70 const std::vector<int32>& attribs); | |
| 71 | |
| 72 // Create and connect to a command buffer in the GPU process. | |
| 73 CommandBufferProxy* CreateOffscreenCommandBuffer( | |
| 74 CommandBufferProxy* parent, | |
| 75 const gfx::Size& size, | |
| 76 const std::string& allowed_extensions, | |
| 77 const std::vector<int32>& attribs, | |
| 78 uint32 parent_texture_id); | |
| 79 | |
| 80 // Destroy a command buffer created by this channel. | |
| 81 void DestroyCommandBuffer(CommandBufferProxy* command_buffer); | |
| 82 | |
| 83 GpuVideoServiceHost* gpu_video_service_host() { | |
| 84 return gpu_video_service_host_.get(); | |
| 85 } | |
| 86 | |
| 87 private: | |
| 88 State state_; | |
| 89 | |
| 90 GPUInfo gpu_info_; | |
| 91 | |
| 92 scoped_ptr<IPC::SyncChannel> channel_; | |
| 93 | |
| 94 // Used to implement message routing functionality to CommandBufferProxy | |
| 95 // objects | |
| 96 MessageRouter router_; | |
| 97 | |
| 98 // Keep track of all the registered CommandBufferProxies to | |
| 99 // inform about OnChannelError | |
| 100 typedef base::hash_map<int, IPC::Channel::Listener*> ProxyMap; | |
| 101 ProxyMap proxies_; | |
| 102 | |
| 103 // This is a MessageFilter to intercept IPC messages and distribute them | |
| 104 // to the corresponding GpuVideoDecoderHost. | |
| 105 scoped_refptr<GpuVideoServiceHost> gpu_video_service_host_; | |
| 106 | |
| 107 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); | |
| 108 }; | |
| 109 | |
| 110 #endif // CHROME_RENDERER_GPU_CHANNEL_HOST_H_ | |
| OLD | NEW |