OLD | NEW |
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 CONTENT_BROWSER_RENDERER_HOST_GPU_MESSAGE_FILTER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_GPU_MESSAGE_FILTER_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_GPU_MESSAGE_FILTER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_GPU_MESSAGE_FILTER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/message_loop_helpers.h" |
10 #include "content/common/gpu/gpu_process_launch_causes.h" | 11 #include "content/common/gpu/gpu_process_launch_causes.h" |
11 #include "content/public/browser/browser_message_filter.h" | 12 #include "content/public/browser/browser_message_filter.h" |
12 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
13 | 14 |
14 class GpuProcessHost; | 15 class GpuProcessHost; |
15 struct GPUCreateCommandBufferConfig; | 16 struct GPUCreateCommandBufferConfig; |
16 class RenderWidgetHelper; | 17 class RenderWidgetHelper; |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 struct GPUInfo; | 20 struct GPUInfo; |
20 } // namespace content | 21 } // namespace content |
21 | 22 |
22 // A message filter for messages from the renderer to the GpuProcessHost(UIShim) | 23 // A message filter for messages from the renderer to the GpuProcessHost(UIShim) |
23 // in the browser. Such messages are typically destined for the GPU process, | 24 // in the browser. Such messages are typically destined for the GPU process, |
24 // but need to be mediated by the browser. | 25 // but need to be mediated by the browser. |
25 class GpuMessageFilter : public content::BrowserMessageFilter, | 26 class GpuMessageFilter : public content::BrowserMessageFilter, |
26 public base::SupportsWeakPtr<GpuMessageFilter> { | 27 public base::SupportsWeakPtr<GpuMessageFilter> { |
27 public: | 28 public: |
28 GpuMessageFilter(int render_process_id, | 29 GpuMessageFilter(int render_process_id, |
29 RenderWidgetHelper* render_widget_helper); | 30 RenderWidgetHelper* render_widget_helper); |
30 | 31 |
31 // content::BrowserMessageFilter methods: | 32 // content::BrowserMessageFilter methods: |
32 virtual bool OnMessageReceived(const IPC::Message& message, | 33 virtual bool OnMessageReceived(const IPC::Message& message, |
33 bool* message_was_ok) OVERRIDE; | 34 bool* message_was_ok) OVERRIDE; |
34 | 35 |
35 private: | 36 private: |
36 friend class content::BrowserThread; | 37 friend class content::BrowserThread; |
37 friend class DeleteTask<GpuMessageFilter>; | 38 friend class base::DeleteHelper<GpuMessageFilter>; |
38 virtual ~GpuMessageFilter(); | 39 virtual ~GpuMessageFilter(); |
39 | 40 |
40 // Message handlers called on the browser IO thread: | 41 // Message handlers called on the browser IO thread: |
41 void OnEstablishGpuChannel(content::CauseForGpuLaunch, | 42 void OnEstablishGpuChannel(content::CauseForGpuLaunch, |
42 IPC::Message* reply); | 43 IPC::Message* reply); |
43 void OnCreateViewCommandBuffer( | 44 void OnCreateViewCommandBuffer( |
44 int32 render_view_id, | 45 int32 render_view_id, |
45 const GPUCreateCommandBufferConfig& init_params, | 46 const GPUCreateCommandBufferConfig& init_params, |
46 IPC::Message* reply); | 47 IPC::Message* reply); |
47 // Helper callbacks for the message handlers. | 48 // Helper callbacks for the message handlers. |
48 void EstablishChannelCallback(IPC::Message* reply, | 49 void EstablishChannelCallback(IPC::Message* reply, |
49 const IPC::ChannelHandle& channel, | 50 const IPC::ChannelHandle& channel, |
50 base::ProcessHandle gpu_process_for_browser, | 51 base::ProcessHandle gpu_process_for_browser, |
51 const content::GPUInfo& gpu_info); | 52 const content::GPUInfo& gpu_info); |
52 void CreateCommandBufferCallback(IPC::Message* reply, int32 route_id); | 53 void CreateCommandBufferCallback(IPC::Message* reply, int32 route_id); |
53 | 54 |
54 int gpu_host_id_; | 55 int gpu_host_id_; |
55 int render_process_id_; | 56 int render_process_id_; |
56 | 57 |
57 scoped_refptr<RenderWidgetHelper> render_widget_helper_; | 58 scoped_refptr<RenderWidgetHelper> render_widget_helper_; |
58 | 59 |
59 DISALLOW_COPY_AND_ASSIGN(GpuMessageFilter); | 60 DISALLOW_COPY_AND_ASSIGN(GpuMessageFilter); |
60 }; | 61 }; |
61 | 62 |
62 #endif // CONTENT_BROWSER_RENDERER_HOST_GPU_MESSAGE_FILTER_H_ | 63 #endif // CONTENT_BROWSER_RENDERER_HOST_GPU_MESSAGE_FILTER_H_ |
OLD | NEW |