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_RENDER_WIDGET_HELPER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HELPER_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HELPER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/atomic_sequence_num.h" | 11 #include "base/atomic_sequence_num.h" |
12 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/process.h" | 14 #include "base/process.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
17 #include "content/common/window_container_type.h" | 17 #include "content/common/window_container_type.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" |
| 19 #include "ui/gfx/native_widget_types.h" |
19 #include "ui/gfx/surface/transport_dib.h" | 20 #include "ui/gfx/surface/transport_dib.h" |
20 | 21 |
21 namespace IPC { | 22 namespace IPC { |
22 class Message; | 23 class Message; |
23 } | 24 } |
24 | 25 |
25 namespace base { | 26 namespace base { |
26 class TimeDelta; | 27 class TimeDelta; |
27 } | 28 } |
28 | 29 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 void CrossSiteSwapOutACK(const ViewMsg_SwapOut_Params& params); | 111 void CrossSiteSwapOutACK(const ViewMsg_SwapOut_Params& params); |
111 bool WaitForUpdateMsg(int render_widget_id, | 112 bool WaitForUpdateMsg(int render_widget_id, |
112 const base::TimeDelta& max_delay, | 113 const base::TimeDelta& max_delay, |
113 IPC::Message* msg); | 114 IPC::Message* msg); |
114 | 115 |
115 #if defined(OS_MACOSX) | 116 #if defined(OS_MACOSX) |
116 // Given the id of a transport DIB, return a mapping to it or NULL on error. | 117 // Given the id of a transport DIB, return a mapping to it or NULL on error. |
117 TransportDIB* MapTransportDIB(TransportDIB::Id dib_id); | 118 TransportDIB* MapTransportDIB(TransportDIB::Id dib_id); |
118 #endif | 119 #endif |
119 | 120 |
| 121 // Set a mapping from a RenderWidgetHost to a compositing surface. Pass a null |
| 122 // handle to remove the mapping. |
| 123 void SetCompositingSurface(int render_widget_id, |
| 124 gfx::PluginWindowHandle compositing_surface); |
120 | 125 |
121 // IO THREAD ONLY ----------------------------------------------------------- | 126 // IO THREAD ONLY ----------------------------------------------------------- |
122 | 127 |
123 // Called on the IO thread when a UpdateRect message is received. | 128 // Called on the IO thread when a UpdateRect message is received. |
124 void DidReceiveUpdateMsg(const IPC::Message& msg); | 129 void DidReceiveUpdateMsg(const IPC::Message& msg); |
125 | 130 |
126 void CreateNewWindow(const ViewHostMsg_CreateWindow_Params& params, | 131 void CreateNewWindow(const ViewHostMsg_CreateWindow_Params& params, |
127 base::ProcessHandle render_process, | 132 base::ProcessHandle render_process, |
128 int* route_id); | 133 int* route_id); |
129 void CreateNewWidget(int opener_id, | 134 void CreateNewWidget(int opener_id, |
130 WebKit::WebPopupType popup_type, | 135 WebKit::WebPopupType popup_type, |
131 int* route_id); | 136 int* route_id); |
132 void CreateNewFullscreenWidget(int opener_id, int* route_id); | 137 void CreateNewFullscreenWidget(int opener_id, int* route_id); |
133 | 138 |
134 #if defined(OS_MACOSX) | 139 #if defined(OS_MACOSX) |
135 // Called on the IO thread to handle the allocation of a TransportDIB. If | 140 // Called on the IO thread to handle the allocation of a TransportDIB. If |
136 // |cache_in_browser| is |true|, then a copy of the shmem is kept by the | 141 // |cache_in_browser| is |true|, then a copy of the shmem is kept by the |
137 // browser, and it is the caller's repsonsibility to call | 142 // browser, and it is the caller's repsonsibility to call |
138 // FreeTransportDIB(). In all cases, the caller is responsible for deleting | 143 // FreeTransportDIB(). In all cases, the caller is responsible for deleting |
139 // the resulting TransportDIB. | 144 // the resulting TransportDIB. |
140 void AllocTransportDIB(size_t size, | 145 void AllocTransportDIB(size_t size, |
141 bool cache_in_browser, | 146 bool cache_in_browser, |
142 TransportDIB::Handle* result); | 147 TransportDIB::Handle* result); |
143 | 148 |
144 // Called on the IO thread to handle the freeing of a transport DIB | 149 // Called on the IO thread to handle the freeing of a transport DIB |
145 void FreeTransportDIB(TransportDIB::Id dib_id); | 150 void FreeTransportDIB(TransportDIB::Id dib_id); |
146 #endif | 151 #endif |
147 | 152 |
| 153 // Lookup the compositing surface corresponding to a widget ID. |
| 154 gfx::PluginWindowHandle LookupCompositingSurface(int render_widget_id); |
| 155 |
148 private: | 156 private: |
149 // A class used to proxy a paint message. PaintMsgProxy objects are created | 157 // A class used to proxy a paint message. PaintMsgProxy objects are created |
150 // on the IO thread and destroyed on the UI thread. | 158 // on the IO thread and destroyed on the UI thread. |
151 class UpdateMsgProxy; | 159 class UpdateMsgProxy; |
152 friend class UpdateMsgProxy; | 160 friend class UpdateMsgProxy; |
153 friend class base::RefCountedThreadSafe<RenderWidgetHelper>; | 161 friend class base::RefCountedThreadSafe<RenderWidgetHelper>; |
154 | 162 |
155 // Map from render_widget_id to live PaintMsgProxy instance. | 163 // Map from render_widget_id to live PaintMsgProxy instance. |
156 typedef base::hash_map<int, UpdateMsgProxy*> UpdateMsgProxyMap; | 164 typedef base::hash_map<int, UpdateMsgProxy*> UpdateMsgProxyMap; |
157 | 165 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 base::Lock allocated_dibs_lock_; | 201 base::Lock allocated_dibs_lock_; |
194 std::map<TransportDIB::Id, int> allocated_dibs_; | 202 std::map<TransportDIB::Id, int> allocated_dibs_; |
195 #endif | 203 #endif |
196 | 204 |
197 // A map of live paint messages. Must hold pending_paints_lock_ to access. | 205 // A map of live paint messages. Must hold pending_paints_lock_ to access. |
198 // The UpdateMsgProxy objects are not owned by this map. (See UpdateMsgProxy | 206 // The UpdateMsgProxy objects are not owned by this map. (See UpdateMsgProxy |
199 // for details about how the lifetime of instances are managed.) | 207 // for details about how the lifetime of instances are managed.) |
200 UpdateMsgProxyMap pending_paints_; | 208 UpdateMsgProxyMap pending_paints_; |
201 base::Lock pending_paints_lock_; | 209 base::Lock pending_paints_lock_; |
202 | 210 |
| 211 // Maps from view ID to compositing surface. |
| 212 typedef std::map<int, gfx::PluginWindowHandle> ViewCompositingSurfaceMap; |
| 213 ViewCompositingSurfaceMap view_compositing_surface_map_; |
| 214 base::Lock view_compositing_surface_map_lock_; |
| 215 |
203 int render_process_id_; | 216 int render_process_id_; |
204 | 217 |
205 // Event used to implement WaitForUpdateMsg. | 218 // Event used to implement WaitForUpdateMsg. |
206 base::WaitableEvent event_; | 219 base::WaitableEvent event_; |
207 | 220 |
208 // The next routing id to use. | 221 // The next routing id to use. |
209 base::AtomicSequenceNumber next_routing_id_; | 222 base::AtomicSequenceNumber next_routing_id_; |
210 | 223 |
211 ResourceDispatcherHost* resource_dispatcher_host_; | 224 ResourceDispatcherHost* resource_dispatcher_host_; |
212 | 225 |
213 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHelper); | 226 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHelper); |
214 }; | 227 }; |
215 | 228 |
216 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HELPER_H_ | 229 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HELPER_H_ |
OLD | NEW |