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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 10965048: [BrowserTag] Send dib info with NavigateGuest message, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Unit test now checks for damage_buffer to be of correct size. 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/renderer/browser_plugin/browser_plugin.h" 5 #include "content/renderer/browser_plugin/browser_plugin.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #if defined (OS_WIN) 9 #if defined (OS_WIN)
10 #include "base/sys_info.h" 10 #include "base/sys_info.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void BrowserPlugin::SetSrcAttribute(const std::string& src) { 95 void BrowserPlugin::SetSrcAttribute(const std::string& src) {
96 if (src == src_ && !guest_crashed_) 96 if (src == src_ && !guest_crashed_)
97 return; 97 return;
98 if (!src.empty() || navigate_src_sent_) { 98 if (!src.empty() || navigate_src_sent_) {
99 BrowserPluginManager::Get()->Send( 99 BrowserPluginManager::Get()->Send(
100 new BrowserPluginHostMsg_NavigateGuest( 100 new BrowserPluginHostMsg_NavigateGuest(
101 render_view_->GetRoutingID(), 101 render_view_->GetRoutingID(),
102 instance_id_, 102 instance_id_,
103 parent_frame_, 103 parent_frame_,
104 src, 104 src,
105 gfx::Size(width(), height()))); 105 *GetPendingResizeParams()));
Fady Samuel 2012/09/24 22:16:58 Shouldn't this get freed after we send it?
lazyboy 2012/09/25 17:57:22 Done.
106 // Record that we sent a NavigateGuest message to embedder. Once we send 106 // Record that we sent a NavigateGuest message to embedder. Once we send
107 // such a message, subsequent SetSrcAttribute() calls must always send 107 // such a message, subsequent SetSrcAttribute() calls must always send
108 // NavigateGuest messages to the embedder (even if |src| is empty), so 108 // NavigateGuest messages to the embedder (even if |src| is empty), so
109 // resize works correctly for all cases (e.g. The embedder can reset the 109 // resize works correctly for all cases (e.g. The embedder can reset the
110 // guest's |src| to empty value, resize and then set the |src| to a 110 // guest's |src| to empty value, resize and then set the |src| to a
111 // non-empty value). 111 // non-empty value).
112 navigate_src_sent_ = true; 112 navigate_src_sent_ = true;
113 } 113 }
114 src_ = src; 114 src_ = src;
115 guest_crashed_ = false; 115 guest_crashed_ = false;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 const WebRect& clip_rect, 355 const WebRect& clip_rect,
356 const WebVector<WebRect>& cut_outs_rects, 356 const WebVector<WebRect>& cut_outs_rects,
357 bool is_visible) { 357 bool is_visible) {
358 int old_width = width(); 358 int old_width = width();
359 int old_height = height(); 359 int old_height = height();
360 plugin_rect_ = window_rect; 360 plugin_rect_ = window_rect;
361 if (old_width == window_rect.width && 361 if (old_width == window_rect.width &&
362 old_height == window_rect.height) { 362 old_height == window_rect.height) {
363 return; 363 return;
364 } 364 }
365 // Until an actual navigation occurs, there is no browser side embedder
366 // present to notify about geometry updates. In this case, after we've updated
367 // the BrowserPlugin's state we are done and can return immediately.
368 if (!navigate_src_sent_)
369 return;
370 365
371 const size_t stride = skia::PlatformCanvas::StrideForWidth(window_rect.width); 366 const size_t stride = skia::PlatformCanvas::StrideForWidth(window_rect.width);
372 // Make sure the size of the damage buffer is at least four bytes so that we 367 // Make sure the size of the damage buffer is at least four bytes so that we
373 // can fit in a magic word to verify that the memory is shared correctly. 368 // can fit in a magic word to verify that the memory is shared correctly.
374 size_t size = 369 size_t size =
375 std::max(sizeof(unsigned int), 370 std::max(sizeof(unsigned int),
376 static_cast<size_t>(window_rect.height * 371 static_cast<size_t>(window_rect.height *
377 stride * 372 stride *
378 GetDeviceScaleFactor() * 373 GetDeviceScaleFactor() *
379 GetDeviceScaleFactor())); 374 GetDeviceScaleFactor()));
(...skipping 12 matching lines...) Expand all
392 new_damage_buffer = TransportDIB::Map(shared_mem.handle()); 387 new_damage_buffer = TransportDIB::Map(shared_mem.handle());
393 #else 388 #else
394 new_damage_buffer = RenderProcess::current()->CreateTransportDIB(size); 389 new_damage_buffer = RenderProcess::current()->CreateTransportDIB(size);
395 #endif 390 #endif
396 if (!new_damage_buffer) 391 if (!new_damage_buffer)
397 NOTREACHED() << "Unable to create damage buffer"; 392 NOTREACHED() << "Unable to create damage buffer";
398 DCHECK(new_damage_buffer->memory()); 393 DCHECK(new_damage_buffer->memory());
399 // Insert the magic word. 394 // Insert the magic word.
400 *static_cast<unsigned int*>(new_damage_buffer->memory()) = 0xdeadbeef; 395 *static_cast<unsigned int*>(new_damage_buffer->memory()) = 0xdeadbeef;
401 396
402 BrowserPluginHostMsg_ResizeGuest_Params params;
403 params.damage_buffer_id = new_damage_buffer->id();
404 #if defined(OS_WIN)
405 params.damage_buffer_size = size;
406 #endif
407 params.width = window_rect.width;
408 params.height = window_rect.height;
409 params.resize_pending = resize_pending_;
410 params.scale_factor = GetDeviceScaleFactor();
411 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest(
412 render_view_->GetRoutingID(),
413 instance_id_,
414 params));
415 resize_pending_ = true;
416
417 if (damage_buffer_) { 397 if (damage_buffer_) {
418 RenderProcess::current()->FreeTransportDIB(damage_buffer_); 398 RenderProcess::current()->FreeTransportDIB(damage_buffer_);
419 damage_buffer_ = NULL; 399 damage_buffer_ = NULL;
420 } 400 }
421 damage_buffer_ = new_damage_buffer; 401 damage_buffer_ = new_damage_buffer;
402
403 pending_resize_params_.reset();
404
405 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params(
406 new BrowserPluginHostMsg_ResizeGuest_Params);
407 params->damage_buffer_id = new_damage_buffer->id();
408 #if defined(OS_WIN)
409 params->damage_buffer_size = size;
410 #endif
411 params->width = window_rect.width;
412 params->height = window_rect.height;
413 params->resize_pending = resize_pending_;
414 params->scale_factor = GetDeviceScaleFactor();
415
416 // Until an actual navigation occurs, there is no browser side embedder
417 // present to notify about geometry updates. In this case, after we've updated
418 // the BrowserPlugin's state we are done and we do not send a resize message
419 // to the browser.
420 if (navigate_src_sent_) {
421 resize_pending_ = true;
422 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest(
423 render_view_->GetRoutingID(),
424 instance_id_,
425 *(params.get())));
426 } else {
427 pending_resize_params_.reset(params.release());
428 }
429 }
430
431 BrowserPluginHostMsg_ResizeGuest_Params*
432 BrowserPlugin::GetPendingResizeParams() {
433 if (pending_resize_params_.get()) {
434 return pending_resize_params_.release();
435 } else {
436 BrowserPluginHostMsg_ResizeGuest_Params* params =
437 new BrowserPluginHostMsg_ResizeGuest_Params;
438
439 // We don't have a pending resize to send, so we send an invalid transport
440 // dib Id.
441 params->damage_buffer_id = TransportDIB::Id();
442 params->width = width();
443 params->height = height();
444 return params;
445 }
422 } 446 }
423 447
424 void BrowserPlugin::updateFocus(bool focused) { 448 void BrowserPlugin::updateFocus(bool focused) {
425 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetFocus( 449 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetFocus(
426 render_view_->GetRoutingID(), 450 render_view_->GetRoutingID(),
427 instance_id_, 451 instance_id_,
428 focused)); 452 focused));
429 } 453 }
430 454
431 void BrowserPlugin::updateVisibility(bool visible) { 455 void BrowserPlugin::updateVisibility(bool visible) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 void* notify_data) { 496 void* notify_data) {
473 } 497 }
474 498
475 void BrowserPlugin::didFailLoadingFrameRequest( 499 void BrowserPlugin::didFailLoadingFrameRequest(
476 const WebKit::WebURL& url, 500 const WebKit::WebURL& url,
477 void* notify_data, 501 void* notify_data,
478 const WebKit::WebURLError& error) { 502 const WebKit::WebURLError& error) {
479 } 503 }
480 504
481 } // namespace content 505 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698