| 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_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 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/sequenced_task_runner_helpers.h" | 13 #include "base/sequenced_task_runner_helpers.h" |
| 14 #include "content/common/gpu/gpu_process_launch_causes.h" | 14 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 15 #include "content/public/browser/browser_message_filter.h" | 15 #include "content/public/browser/browser_message_filter.h" |
| 16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 17 | 17 |
| 18 class GpuProcessHost; | 18 class GpuProcessHost; |
| 19 struct GPUCreateCommandBufferConfig; | 19 struct GPUCreateCommandBufferConfig; |
| 20 class RenderWidgetHelper; | |
| 21 | 20 |
| 22 namespace content { | 21 namespace content { |
| 22 class RenderWidgetHelper; |
| 23 struct GPUInfo; | 23 struct GPUInfo; |
| 24 } // namespace content | |
| 25 | 24 |
| 26 // A message filter for messages from the renderer to the GpuProcessHost(UIShim) | 25 // A message filter for messages from the renderer to the GpuProcessHost(UIShim) |
| 27 // in the browser. Such messages are typically destined for the GPU process, | 26 // in the browser. Such messages are typically destined for the GPU process, |
| 28 // but need to be mediated by the browser. | 27 // but need to be mediated by the browser. |
| 29 class GpuMessageFilter : public content::BrowserMessageFilter, | 28 class GpuMessageFilter : public BrowserMessageFilter, |
| 30 public base::SupportsWeakPtr<GpuMessageFilter> { | 29 public base::SupportsWeakPtr<GpuMessageFilter> { |
| 31 public: | 30 public: |
| 32 GpuMessageFilter(int render_process_id, | 31 GpuMessageFilter(int render_process_id, |
| 33 RenderWidgetHelper* render_widget_helper); | 32 RenderWidgetHelper* render_widget_helper); |
| 34 | 33 |
| 35 // content::BrowserMessageFilter methods: | 34 // BrowserMessageFilter methods: |
| 36 virtual bool OnMessageReceived(const IPC::Message& message, | 35 virtual bool OnMessageReceived(const IPC::Message& message, |
| 37 bool* message_was_ok) OVERRIDE; | 36 bool* message_was_ok) OVERRIDE; |
| 38 | 37 |
| 39 // Signals that the handle for a surface id was updated, and it may be time to | 38 // Signals that the handle for a surface id was updated, and it may be time to |
| 40 // unblock existing CreateViewCommandBuffer requests using that surface. | 39 // unblock existing CreateViewCommandBuffer requests using that surface. |
| 41 void SurfaceUpdated(int32 surface_id); | 40 void SurfaceUpdated(int32 surface_id); |
| 42 | 41 |
| 43 private: | 42 private: |
| 44 friend class content::BrowserThread; | 43 friend class BrowserThread; |
| 45 friend class base::DeleteHelper<GpuMessageFilter>; | 44 friend class base::DeleteHelper<GpuMessageFilter>; |
| 46 struct CreateViewCommandBufferRequest; | 45 struct CreateViewCommandBufferRequest; |
| 47 | 46 |
| 48 virtual ~GpuMessageFilter(); | 47 virtual ~GpuMessageFilter(); |
| 49 | 48 |
| 50 // Message handlers called on the browser IO thread: | 49 // Message handlers called on the browser IO thread: |
| 51 void OnEstablishGpuChannel(content::CauseForGpuLaunch, | 50 void OnEstablishGpuChannel(CauseForGpuLaunch, |
| 52 IPC::Message* reply); | 51 IPC::Message* reply); |
| 53 void OnCreateViewCommandBuffer( | 52 void OnCreateViewCommandBuffer( |
| 54 int32 surface_id, | 53 int32 surface_id, |
| 55 const GPUCreateCommandBufferConfig& init_params, | 54 const GPUCreateCommandBufferConfig& init_params, |
| 56 IPC::Message* reply); | 55 IPC::Message* reply); |
| 57 // Helper callbacks for the message handlers. | 56 // Helper callbacks for the message handlers. |
| 58 void EstablishChannelCallback(IPC::Message* reply, | 57 void EstablishChannelCallback(IPC::Message* reply, |
| 59 const IPC::ChannelHandle& channel, | 58 const IPC::ChannelHandle& channel, |
| 60 const content::GPUInfo& gpu_info); | 59 const GPUInfo& gpu_info); |
| 61 void CreateCommandBufferCallback(IPC::Message* reply, int32 route_id); | 60 void CreateCommandBufferCallback(IPC::Message* reply, int32 route_id); |
| 62 | 61 |
| 63 int gpu_process_id_; | 62 int gpu_process_id_; |
| 64 int render_process_id_; | 63 int render_process_id_; |
| 65 bool share_contexts_; | 64 bool share_contexts_; |
| 66 | 65 |
| 67 scoped_refptr<RenderWidgetHelper> render_widget_helper_; | 66 scoped_refptr<RenderWidgetHelper> render_widget_helper_; |
| 68 std::vector<linked_ptr<CreateViewCommandBufferRequest> > pending_requests_; | 67 std::vector<linked_ptr<CreateViewCommandBufferRequest> > pending_requests_; |
| 69 | 68 |
| 70 DISALLOW_COPY_AND_ASSIGN(GpuMessageFilter); | 69 DISALLOW_COPY_AND_ASSIGN(GpuMessageFilter); |
| 71 }; | 70 }; |
| 72 | 71 |
| 72 } // namespace content |
| 73 |
| 73 #endif // CONTENT_BROWSER_RENDERER_HOST_GPU_MESSAGE_FILTER_H_ | 74 #endif // CONTENT_BROWSER_RENDERER_HOST_GPU_MESSAGE_FILTER_H_ |
| OLD | NEW |