Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 10829225: Browser Plugin: Add HTML5-like postMessage support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed crash + cleanup Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "content/browser/browser_plugin/browser_plugin_guest.h" 5 #include "content/browser/browser_plugin/browser_plugin_guest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "content/browser/browser_plugin/browser_plugin_guest_helper.h" 10 #include "content/browser/browser_plugin/browser_plugin_guest_helper.h"
(...skipping 23 matching lines...) Expand all
34 BrowserPluginGuest::BrowserPluginGuest(int instance_id, 34 BrowserPluginGuest::BrowserPluginGuest(int instance_id,
35 WebContentsImpl* web_contents, 35 WebContentsImpl* web_contents,
36 RenderViewHost* render_view_host) 36 RenderViewHost* render_view_host)
37 : WebContentsObserver(web_contents), 37 : WebContentsObserver(web_contents),
38 embedder_render_process_host_(NULL), 38 embedder_render_process_host_(NULL),
39 instance_id_(instance_id), 39 instance_id_(instance_id),
40 #if defined(OS_WIN) 40 #if defined(OS_WIN)
41 damage_buffer_size_(0), 41 damage_buffer_size_(0),
42 #endif 42 #endif
43 pending_update_counter_(0), 43 pending_update_counter_(0),
44 guest_hang_timeout_(kGuestHangTimeout) { 44 guest_hang_timeout_(kGuestHangTimeout),
45 swapped_out_embedder_routing_id_(MSG_ROUTING_NONE),
46 swapped_out_guest_routing_id_(MSG_ROUTING_NONE) {
45 DCHECK(web_contents); 47 DCHECK(web_contents);
46 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper. 48 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper.
47 new BrowserPluginGuestHelper(this, render_view_host); 49 new BrowserPluginGuestHelper(this, render_view_host);
48 } 50 }
49 51
50 BrowserPluginGuest::~BrowserPluginGuest() { 52 BrowserPluginGuest::~BrowserPluginGuest() {
51 } 53 }
52 54
53 // static 55 // static
54 BrowserPluginGuest* BrowserPluginGuest::Create( 56 BrowserPluginGuest* BrowserPluginGuest::Create(
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // TODO(fsamuel): What do we need to do here? This is for keyboard shortcuts. 195 // TODO(fsamuel): What do we need to do here? This is for keyboard shortcuts.
194 if (input_event->type == WebKit::WebInputEvent::RawKeyDown) 196 if (input_event->type == WebKit::WebInputEvent::RawKeyDown)
195 message->WriteBool(false); 197 message->WriteBool(false);
196 bool sent = guest_rvh->Send(message); 198 bool sent = guest_rvh->Send(message);
197 if (!sent) { 199 if (!sent) {
198 // If the embedder is waiting for a previous input ack, a new input message 200 // If the embedder is waiting for a previous input ack, a new input message
199 // won't get sent to the guest, reply immediately with handled = false so 201 // won't get sent to the guest, reply immediately with handled = false so
200 // embedder doesn't hang. 202 // embedder doesn't hang.
201 BrowserPluginHostMsg_HandleInputEvent::WriteReplyParams( 203 BrowserPluginHostMsg_HandleInputEvent::WriteReplyParams(
202 reply_message, false /* handled */, cursor_); 204 reply_message, false /* handled */, cursor_);
203 embedder_render_process_host()->Send(reply_message); 205 SendMessageToEmbedder(reply_message);
204 return; 206 return;
205 } 207 }
206 208
207 pending_input_event_reply_.reset(reply_message); 209 pending_input_event_reply_.reset(reply_message);
208 // Input events are handled synchronously, meaning it blocks the embedder. We 210 // Input events are handled synchronously, meaning it blocks the embedder. We
209 // set a hang monitor here that will kill the guest process (5s timeout) if we 211 // set a hang monitor here that will kill the guest process (5s timeout) if we
210 // don't receive an ack. This will kill all the guests that are running in the 212 // don't receive an ack. This will kill all the guests that are running in the
211 // same process (undesired behavior). 213 // same process (undesired behavior).
212 // TODO(fsamuel,lazyboy): Find a way to get rid of guest process kill 214 // TODO(fsamuel,lazyboy): Find a way to get rid of guest process kill
213 // behavior. http://crbug.com/147272. 215 // behavior. http://crbug.com/147272.
214 guest_rvh->StartHangMonitorTimeout(guest_hang_timeout_); 216 guest_rvh->StartHangMonitorTimeout(guest_hang_timeout_);
215 } 217 }
216 218
219 void BrowserPluginGuest::RouteMessageEvent(
220 const ViewMsg_PostMessage_Params& params) {
221 SendMessageToEmbedder(new BrowserPluginMsg_ReceiveMessage(
222 instance_id(),
223 swapped_out_embedder_routing_id(),
224 params.source_origin,
225 params.data));
226 }
227
217 void BrowserPluginGuest::HandleInputEventAck(RenderViewHost* render_view_host, 228 void BrowserPluginGuest::HandleInputEventAck(RenderViewHost* render_view_host,
218 bool handled) { 229 bool handled) {
219 RenderViewHostImpl* guest_rvh = 230 RenderViewHostImpl* guest_rvh =
220 static_cast<RenderViewHostImpl*>(render_view_host); 231 static_cast<RenderViewHostImpl*>(render_view_host);
221 guest_rvh->StopHangMonitorTimeout(); 232 guest_rvh->StopHangMonitorTimeout();
222 DCHECK(pending_input_event_reply_.get()); 233 DCHECK(pending_input_event_reply_.get());
223 IPC::Message* reply_message = pending_input_event_reply_.release(); 234 IPC::Message* reply_message = pending_input_event_reply_.release();
224 BrowserPluginHostMsg_HandleInputEvent::WriteReplyParams(reply_message, 235 BrowserPluginHostMsg_HandleInputEvent::WriteReplyParams(reply_message,
225 handled, 236 handled,
226 cursor_); 237 cursor_);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 pending_updates_.Remove(iter.GetCurrentKey()); 284 pending_updates_.Remove(iter.GetCurrentKey());
274 iter.Advance(); 285 iter.Advance();
275 } 286 }
276 } 287 }
277 288
278 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { 289 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
279 embedder_render_process_host()->Send(msg); 290 embedder_render_process_host()->Send(msg);
280 } 291 }
281 292
282 } // namespace content 293 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698