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

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

Issue 1369603003: Remove 2-stage RenderWidget initialization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use_offscreen_contexts
Patch Set: review comments Created 5 years, 2 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
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, 478 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
479 blink::WebPopupType popup_type, 479 blink::WebPopupType popup_type,
480 const blink::WebScreenInfo& screen_info, 480 const blink::WebScreenInfo& screen_info,
481 bool swapped_out, 481 bool swapped_out,
482 bool hidden, 482 bool hidden,
483 bool never_visible) 483 bool never_visible)
484 : routing_id_(MSG_ROUTING_NONE), 484 : routing_id_(MSG_ROUTING_NONE),
485 compositor_deps_(compositor_deps), 485 compositor_deps_(compositor_deps),
486 webwidget_(nullptr), 486 webwidget_(nullptr),
487 opener_id_(MSG_ROUTING_NONE), 487 opener_id_(MSG_ROUTING_NONE),
488 init_complete_(false),
489 top_controls_shrink_blink_size_(false), 488 top_controls_shrink_blink_size_(false),
490 top_controls_height_(0.f), 489 top_controls_height_(0.f),
491 next_paint_flags_(0), 490 next_paint_flags_(0),
492 auto_resize_mode_(false), 491 auto_resize_mode_(false),
493 need_update_rect_for_auto_resize_(false), 492 need_update_rect_for_auto_resize_(false),
494 did_show_(false), 493 did_show_(false),
495 is_hidden_(hidden), 494 is_hidden_(hidden),
496 never_visible_(never_visible), 495 never_visible_(never_visible),
497 is_fullscreen_granted_(false), 496 is_fullscreen_granted_(false),
498 display_mode_(blink::WebDisplayModeUndefined), 497 display_mode_(blink::WebDisplayModeUndefined),
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 scoped_refptr<RenderWidget> widget( 565 scoped_refptr<RenderWidget> widget(
567 new RenderWidget(compositor_deps, blink::WebPopupTypeNone, screen_info, 566 new RenderWidget(compositor_deps, blink::WebPopupTypeNone, screen_info,
568 false, hidden, false)); 567 false, hidden, false));
569 widget->routing_id_ = routing_id; 568 widget->routing_id_ = routing_id;
570 widget->for_oopif_ = true; 569 widget->for_oopif_ = true;
571 // DoInit increments the reference count on |widget|, keeping it alive after 570 // DoInit increments the reference count on |widget|, keeping it alive after
572 // this function returns. 571 // this function returns.
573 if (widget->DoInit(MSG_ROUTING_NONE, 572 if (widget->DoInit(MSG_ROUTING_NONE,
574 RenderWidget::CreateWebFrameWidget(widget.get(), frame), 573 RenderWidget::CreateWebFrameWidget(widget.get(), frame),
575 nullptr)) { 574 nullptr)) {
576 widget->CompleteInit();
577 return widget.get(); 575 return widget.get();
578 } 576 }
579 return nullptr; 577 return nullptr;
580 } 578 }
581 579
582 // static 580 // static
583 blink::WebWidget* RenderWidget::CreateWebFrameWidget( 581 blink::WebWidget* RenderWidget::CreateWebFrameWidget(
584 RenderWidget* render_widget, 582 RenderWidget* render_widget,
585 blink::WebLocalFrame* frame) { 583 blink::WebLocalFrame* frame) {
586 return blink::WebFrameWidget::create(render_widget, frame); 584 return blink::WebFrameWidget::create(render_widget, frame);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 if (is_hidden_) 631 if (is_hidden_)
634 RenderThreadImpl::current()->WidgetHidden(); 632 RenderThreadImpl::current()->WidgetHidden();
635 } 633 }
636 return true; 634 return true;
637 } else { 635 } else {
638 // The above Send can fail when the tab is closing. 636 // The above Send can fail when the tab is closing.
639 return false; 637 return false;
640 } 638 }
641 } 639 }
642 640
643 // This is used to complete pending inits and non-pending inits.
644 void RenderWidget::CompleteInit() {
645 DCHECK(routing_id_ != MSG_ROUTING_NONE);
646
647 init_complete_ = true;
648
649 // TODO(piman): do we still need the 2-stage initialization? crbug.com/535339
650 if (compositor_)
651 StartCompositor();
652
653 Send(new ViewHostMsg_RenderViewReady(routing_id_));
654 }
655
656 void RenderWidget::SetSwappedOut(bool is_swapped_out) { 641 void RenderWidget::SetSwappedOut(bool is_swapped_out) {
657 // We should only toggle between states. 642 // We should only toggle between states.
658 DCHECK(is_swapped_out_ != is_swapped_out); 643 DCHECK(is_swapped_out_ != is_swapped_out);
659 is_swapped_out_ = is_swapped_out; 644 is_swapped_out_ = is_swapped_out;
660 645
661 // If we are swapping out, we will call ReleaseProcess, allowing the process 646 // If we are swapping out, we will call ReleaseProcess, allowing the process
662 // to exit if all of its RenderViews are swapped out. We wait until the 647 // to exit if all of its RenderViews are swapped out. We wait until the
663 // WasSwappedOut call to do this, to allow the unload handler to finish. 648 // WasSwappedOut call to do this, to allow the unload handler to finish.
664 // If we are swapping in, we call AddRefProcess to prevent the process from 649 // If we are swapping in, we call AddRefProcess to prevent the process from
665 // exiting. 650 // exiting.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) 702 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent)
718 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, 703 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange,
719 OnCursorVisibilityChange) 704 OnCursorVisibilityChange)
720 IPC_MESSAGE_HANDLER(InputMsg_ImeSetComposition, OnImeSetComposition) 705 IPC_MESSAGE_HANDLER(InputMsg_ImeSetComposition, OnImeSetComposition)
721 IPC_MESSAGE_HANDLER(InputMsg_ImeConfirmComposition, OnImeConfirmComposition) 706 IPC_MESSAGE_HANDLER(InputMsg_ImeConfirmComposition, OnImeConfirmComposition)
722 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) 707 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost)
723 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) 708 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus)
724 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted, 709 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted,
725 OnSyntheticGestureCompleted) 710 OnSyntheticGestureCompleted)
726 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) 711 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
727 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck)
728 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) 712 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize)
729 IPC_MESSAGE_HANDLER(ViewMsg_EnableDeviceEmulation, 713 IPC_MESSAGE_HANDLER(ViewMsg_EnableDeviceEmulation,
730 OnEnableDeviceEmulation) 714 OnEnableDeviceEmulation)
731 IPC_MESSAGE_HANDLER(ViewMsg_DisableDeviceEmulation, 715 IPC_MESSAGE_HANDLER(ViewMsg_DisableDeviceEmulation,
732 OnDisableDeviceEmulation) 716 OnDisableDeviceEmulation)
733 IPC_MESSAGE_HANDLER(ViewMsg_ColorProfile, OnColorProfile) 717 IPC_MESSAGE_HANDLER(ViewMsg_ColorProfile, OnColorProfile)
734 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) 718 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect)
735 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) 719 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden)
736 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) 720 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown)
737 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) 721 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint)
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 // now. Post a task that only gets invoked when there are no nested message 863 // now. Post a task that only gets invoked when there are no nested message
880 // loops. 864 // loops.
881 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( 865 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask(
882 FROM_HERE, base::Bind(&RenderWidget::Close, this)); 866 FROM_HERE, base::Bind(&RenderWidget::Close, this));
883 } 867 }
884 868
885 // Balances the AddRef taken when we called AddRoute. 869 // Balances the AddRef taken when we called AddRoute.
886 Release(); 870 Release();
887 } 871 }
888 872
889 // Got a response from the browser after the renderer decided to create a new
890 // view.
891 void RenderWidget::OnCreatingNewAck() {
892 DCHECK(routing_id_ != MSG_ROUTING_NONE);
893
894 CompleteInit();
895 }
896
897 void RenderWidget::OnResize(const ViewMsg_Resize_Params& params) { 873 void RenderWidget::OnResize(const ViewMsg_Resize_Params& params) {
898 if (resizing_mode_selector_->ShouldAbortOnResize(this, params)) 874 if (resizing_mode_selector_->ShouldAbortOnResize(this, params))
899 return; 875 return;
900 876
901 if (screen_metrics_emulator_) { 877 if (screen_metrics_emulator_) {
902 screen_metrics_emulator_->OnResizeMessage(params); 878 screen_metrics_emulator_->OnResizeMessage(params);
903 return; 879 return;
904 } 880 }
905 881
906 bool orientation_changed = 882 bool orientation_changed =
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 physical_backing_size_ = gfx::ScaleToCeiledSize(size_, device_scale_factor_); 1332 physical_backing_size_ = gfx::ScaleToCeiledSize(size_, device_scale_factor_);
1357 if (compositor_) 1333 if (compositor_)
1358 compositor_->setViewportSize(size_, physical_backing_size_); 1334 compositor_->setViewportSize(size_, physical_backing_size_);
1359 } 1335 }
1360 1336
1361 void RenderWidget::initializeLayerTreeView() { 1337 void RenderWidget::initializeLayerTreeView() {
1362 DCHECK(!host_closing_); 1338 DCHECK(!host_closing_);
1363 1339
1364 compositor_ = RenderWidgetCompositor::Create(this, compositor_deps_); 1340 compositor_ = RenderWidgetCompositor::Create(this, compositor_deps_);
1365 compositor_->setViewportSize(size_, physical_backing_size_); 1341 compositor_->setViewportSize(size_, physical_backing_size_);
1366 if (init_complete_) 1342 StartCompositor();
1367 StartCompositor();
1368 } 1343 }
1369 1344
1370 void RenderWidget::WillCloseLayerTreeView() { 1345 void RenderWidget::WillCloseLayerTreeView() {
1371 if (host_closing_) 1346 if (host_closing_)
1372 return; 1347 return;
1373 1348
1374 // Prevent new compositors or output surfaces from being created. 1349 // Prevent new compositors or output surfaces from being created.
1375 host_closing_ = true; 1350 host_closing_ = true;
1376 1351
1377 // Always send this notification to prevent new layer tree views from 1352 // Always send this notification to prevent new layer tree views from
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { 2385 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) {
2411 video_hole_frames_.AddObserver(frame); 2386 video_hole_frames_.AddObserver(frame);
2412 } 2387 }
2413 2388
2414 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { 2389 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) {
2415 video_hole_frames_.RemoveObserver(frame); 2390 video_hole_frames_.RemoveObserver(frame);
2416 } 2391 }
2417 #endif // defined(VIDEO_HOLE) 2392 #endif // defined(VIDEO_HOLE)
2418 2393
2419 } // namespace content 2394 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698