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_GPU_GPU_PROCESS_HOST_UI_SHIM_H_ | 5 #ifndef CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_UI_SHIM_H_ |
6 #define CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_UI_SHIM_H_ | 6 #define CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_UI_SHIM_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 // This class lives on the UI thread and supports classes like the | 9 // This class lives on the UI thread and supports classes like the |
10 // BackingStoreProxy, which must live on the UI thread. The IO thread | 10 // BackingStoreProxy, which must live on the UI thread. The IO thread |
11 // portion of this class, the GpuProcessHost, is responsible for | 11 // portion of this class, the GpuProcessHost, is responsible for |
12 // shuttling messages between the browser and GPU processes. | 12 // shuttling messages between the browser and GPU processes. |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "base/callback_forward.h" | 16 #include "base/callback_forward.h" |
17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
18 #include "base/memory/linked_ptr.h" | 18 #include "base/memory/linked_ptr.h" |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
20 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
21 #include "content/common/content_export.h" | 21 #include "content/common/content_export.h" |
22 #include "content/common/message_router.h" | 22 #include "content/common/message_router.h" |
23 #include "content/public/common/gpu_info.h" | 23 #include "content/public/common/gpu_info.h" |
| 24 #include "ipc/ipc_listener.h" |
| 25 #include "ipc/ipc_sender.h" |
24 | 26 |
25 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; | 27 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; |
26 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; | 28 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; |
27 struct GpuHostMsg_AcceleratedSurfaceNew_Params; | 29 struct GpuHostMsg_AcceleratedSurfaceNew_Params; |
28 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; | 30 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; |
29 | 31 |
30 namespace gfx { | 32 namespace gfx { |
31 class Size; | 33 class Size; |
32 } | 34 } |
33 | 35 |
34 namespace IPC { | 36 namespace IPC { |
35 class Message; | 37 class Message; |
36 } | 38 } |
37 | 39 |
38 void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg); | 40 void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg); |
39 | 41 |
40 class GpuProcessHostUIShim | 42 class GpuProcessHostUIShim |
41 : public IPC::Channel::Listener, | 43 : public IPC::Listener, |
42 public IPC::Channel::Sender, | 44 public IPC::Sender, |
43 public base::NonThreadSafe { | 45 public base::NonThreadSafe { |
44 public: | 46 public: |
45 // Create a GpuProcessHostUIShim with the given ID. The object can be found | 47 // Create a GpuProcessHostUIShim with the given ID. The object can be found |
46 // using FromID with the same id. | 48 // using FromID with the same id. |
47 static GpuProcessHostUIShim* Create(int host_id); | 49 static GpuProcessHostUIShim* Create(int host_id); |
48 | 50 |
49 // Destroy the GpuProcessHostUIShim with the given host ID. This can only | 51 // Destroy the GpuProcessHostUIShim with the given host ID. This can only |
50 // be called on the UI thread. Only the GpuProcessHost should destroy the | 52 // be called on the UI thread. Only the GpuProcessHost should destroy the |
51 // UI shim. | 53 // UI shim. |
52 static void Destroy(int host_id); | 54 static void Destroy(int host_id); |
53 | 55 |
54 // Destroy all remaining GpuProcessHostUIShims. | 56 // Destroy all remaining GpuProcessHostUIShims. |
55 CONTENT_EXPORT static void DestroyAll(); | 57 CONTENT_EXPORT static void DestroyAll(); |
56 | 58 |
57 CONTENT_EXPORT static GpuProcessHostUIShim* FromID(int host_id); | 59 CONTENT_EXPORT static GpuProcessHostUIShim* FromID(int host_id); |
58 | 60 |
59 // Get a GpuProcessHostUIShim instance; it doesn't matter which one. | 61 // Get a GpuProcessHostUIShim instance; it doesn't matter which one. |
60 // Return NULL if none has been created. | 62 // Return NULL if none has been created. |
61 CONTENT_EXPORT static GpuProcessHostUIShim* GetOneInstance(); | 63 CONTENT_EXPORT static GpuProcessHostUIShim* GetOneInstance(); |
62 | 64 |
63 // IPC::Channel::Sender implementation. | 65 // IPC::Sender implementation. |
64 virtual bool Send(IPC::Message* msg) OVERRIDE; | 66 virtual bool Send(IPC::Message* msg) OVERRIDE; |
65 | 67 |
66 // IPC::Channel::Listener implementation. | 68 // IPC::Listener implementation. |
67 // The GpuProcessHost causes this to be called on the UI thread to | 69 // The GpuProcessHost causes this to be called on the UI thread to |
68 // dispatch the incoming messages from the GPU process, which are | 70 // dispatch the incoming messages from the GPU process, which are |
69 // actually received on the IO thread. | 71 // actually received on the IO thread. |
70 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 72 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
71 | 73 |
72 CONTENT_EXPORT void SimulateRemoveAllContext(); | 74 CONTENT_EXPORT void SimulateRemoveAllContext(); |
73 CONTENT_EXPORT void SimulateCrash(); | 75 CONTENT_EXPORT void SimulateCrash(); |
74 CONTENT_EXPORT void SimulateHang(); | 76 CONTENT_EXPORT void SimulateHang(); |
75 | 77 |
76 private: | 78 private: |
(...skipping 27 matching lines...) Expand all Loading... |
104 #if defined(USE_AURA) | 106 #if defined(USE_AURA) |
105 void OnAcceleratedSurfaceRelease( | 107 void OnAcceleratedSurfaceRelease( |
106 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params); | 108 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params); |
107 #endif | 109 #endif |
108 | 110 |
109 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. | 111 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. |
110 int host_id_; | 112 int host_id_; |
111 }; | 113 }; |
112 | 114 |
113 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_UI_SHIM_H_ | 115 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_UI_SHIM_H_ |
OLD | NEW |