Chromium Code Reviews| 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 // This file defines utility functions for sending notifications (calling | 5 // This file defines utility functions for sending notifications (calling |
| 6 // methods that return void and do not have out params) to the RenderViewHost | 6 // methods that return void and do not have out params) to the RenderViewHost |
| 7 // or one of its delegate interfaces. The notifications are dispatched | 7 // or one of its delegate interfaces. The notifications are dispatched |
| 8 // asynchronously, and only if the specified RenderViewHost still exists. | 8 // asynchronously, and only if the specified RenderViewHost still exists. |
| 9 | 9 |
| 10 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_NOTIFICATION_TASK_H_ | 10 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_NOTIFICATION_TASK_H_ |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 Method method, const Params& params) { | 64 Method method, const Params& params) { |
| 65 using content::BrowserThread; | 65 using content::BrowserThread; |
| 66 BrowserThread::PostTask( | 66 BrowserThread::PostTask( |
| 67 BrowserThread::UI, FROM_HERE, | 67 BrowserThread::UI, FROM_HERE, |
| 68 new RenderViewHostNotificationTask<Method, Params>(render_process_id, | 68 new RenderViewHostNotificationTask<Method, Params>(render_process_id, |
| 69 render_view_id, | 69 render_view_id, |
| 70 method, | 70 method, |
| 71 params)); | 71 params)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 class RenderViewHostToDelegate { | |
| 75 public: | |
| 76 typedef RenderViewHostDelegate MappedType; | |
| 77 static MappedType* Map(RenderViewHost* rvh) { | |
| 78 return rvh ? rvh->delegate() : NULL; | |
| 79 } | |
| 80 }; | |
| 81 | |
| 82 template <typename Method, typename Params> | |
| 83 inline void CallRenderViewHostDelegateHelper( | |
| 84 int render_process_id, | |
| 85 int render_view_id, | |
| 86 Method method, | |
| 87 const Params& params) { | |
| 88 BrowserThread::PostTask( | |
| 89 BrowserThread::UI, FROM_HERE, | |
| 90 new RenderViewHostNotificationTask< | |
| 91 Method, Params, RenderViewHostToDelegate>( | |
| 92 render_process_id, | |
| 93 render_view_id, | |
| 94 method, | |
| 95 params)); | |
| 96 } | |
|
Matt Perry
2011/11/23 02:51:20
this stuff is only necessary for step 1 of the hac
| |
| 97 | |
| 74 // For proxying calls to RenderViewHostDelegate::RendererManagement | 98 // For proxying calls to RenderViewHostDelegate::RendererManagement |
| 75 | 99 |
| 76 class RenderViewHostToRendererManagementDelegate { | 100 class RenderViewHostToRendererManagementDelegate { |
| 77 public: | 101 public: |
| 78 typedef RenderViewHostDelegate::RendererManagement MappedType; | 102 typedef RenderViewHostDelegate::RendererManagement MappedType; |
| 79 static MappedType* Map(RenderViewHost* rvh) { | 103 static MappedType* Map(RenderViewHost* rvh) { |
| 80 return rvh ? rvh->delegate()->GetRendererManagementDelegate() : NULL; | 104 return rvh ? rvh->delegate()->GetRendererManagementDelegate() : NULL; |
| 81 } | 105 } |
| 82 }; | 106 }; |
| 83 | 107 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 Method method, | 154 Method method, |
| 131 const A& a, | 155 const A& a, |
| 132 const B& b) { | 156 const B& b) { |
| 133 internal::CallRenderViewHostHelper(render_process_id, | 157 internal::CallRenderViewHostHelper(render_process_id, |
| 134 render_view_id, | 158 render_view_id, |
| 135 method, | 159 method, |
| 136 MakeTuple(a, b)); | 160 MakeTuple(a, b)); |
| 137 } | 161 } |
| 138 | 162 |
| 139 // ---------------------------------------------------------------------------- | 163 // ---------------------------------------------------------------------------- |
| 164 // Proxy calls to the specified RenderViewHostDelegate. | |
| 165 | |
| 166 template <typename Method> | |
| 167 inline void CallRenderViewHostDelegate(int render_process_id, | |
| 168 int render_view_id, | |
| 169 Method method) { | |
| 170 internal::CallRenderViewHostDelegateHelper(render_process_id, | |
| 171 render_view_id, | |
| 172 method, | |
| 173 MakeTuple()); | |
| 174 } | |
| 175 | |
| 176 template <typename Method, typename A> | |
| 177 inline void CallRenderViewHostDelegate(int render_process_id, | |
| 178 int render_view_id, | |
| 179 Method method, | |
| 180 const A& a) { | |
| 181 internal::CallRenderViewHostDelegateHelper(render_process_id, | |
| 182 render_view_id, | |
| 183 method, | |
| 184 MakeTuple(a)); | |
| 185 } | |
| 186 | |
| 187 template <typename Method, typename A, typename B> | |
| 188 inline void CallRenderViewHostDelegate(int render_process_id, | |
| 189 int render_view_id, | |
| 190 Method method, | |
| 191 const A& a, | |
| 192 const B& b) { | |
| 193 internal::CallRenderViewHostDelegateHelper(render_process_id, | |
| 194 render_view_id, | |
| 195 method, | |
| 196 MakeTuple(a, b)); | |
| 197 } | |
| 198 | |
| 199 template <typename Method, typename A, typename B, typename C> | |
| 200 inline void CallRenderViewHostDelegate(int render_process_id, | |
| 201 int render_view_id, | |
| 202 Method method, | |
| 203 const A& a, | |
| 204 const B& b, | |
| 205 const C& c) { | |
| 206 internal::CallRenderViewHostDelegateHelper(render_process_id, | |
| 207 render_view_id, | |
| 208 method, | |
| 209 MakeTuple(a, b, c)); | |
| 210 } | |
| 211 | |
| 212 template <typename Method, typename A, typename B, typename C, typename D> | |
| 213 inline void CallRenderViewHostDelegate(int render_process_id, | |
| 214 int render_view_id, | |
| 215 Method method, | |
| 216 const A& a, | |
| 217 const B& b, | |
| 218 const C& c, | |
| 219 const D& d) { | |
| 220 internal::CallRenderViewHostDelegateHelper(render_process_id, | |
| 221 render_view_id, | |
| 222 method, | |
| 223 MakeTuple(a, b, c, d)); | |
| 224 } | |
| 225 // ---------------------------------------------------------------------------- | |
| 140 // Proxy calls to the specified RenderViewHost's RendererManagement delegate. | 226 // Proxy calls to the specified RenderViewHost's RendererManagement delegate. |
| 141 | 227 |
| 142 template <typename Method> | 228 template <typename Method> |
| 143 inline void CallRenderViewHostRendererManagementDelegate(int render_process_id, | 229 inline void CallRenderViewHostRendererManagementDelegate(int render_process_id, |
| 144 int render_view_id, | 230 int render_view_id, |
| 145 Method method) { | 231 Method method) { |
| 146 internal::CallRenderViewHostRendererManagementDelegateHelper( | 232 internal::CallRenderViewHostRendererManagementDelegateHelper( |
| 147 render_process_id, | 233 render_process_id, |
| 148 render_view_id, | 234 render_view_id, |
| 149 method, | 235 method, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 171 internal::CallRenderViewHostRendererManagementDelegateHelper( | 257 internal::CallRenderViewHostRendererManagementDelegateHelper( |
| 172 render_process_id, | 258 render_process_id, |
| 173 render_view_id, | 259 render_view_id, |
| 174 method, | 260 method, |
| 175 MakeTuple(a, b)); | 261 MakeTuple(a, b)); |
| 176 } | 262 } |
| 177 | 263 |
| 178 // ---------------------------------------------------------------------------- | 264 // ---------------------------------------------------------------------------- |
| 179 | 265 |
| 180 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_NOTIFICATION_TASK_H_ | 266 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_NOTIFICATION_TASK_H_ |
| OLD | NEW |