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

Side by Side Diff: content/browser/frame_host/render_widget_host_view_child_frame.cc

Issue 2112923002: Fix crash when destroying a RenderWidgetHost that holds the pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/frame_host/render_widget_host_view_child_frame.h" 5 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (parent_surface_client_id_) { 70 if (parent_surface_client_id_) {
71 GetSurfaceManager()->UnregisterSurfaceNamespaceHierarchy( 71 GetSurfaceManager()->UnregisterSurfaceNamespaceHierarchy(
72 parent_surface_client_id_, GetSurfaceClientId()); 72 parent_surface_client_id_, GetSurfaceClientId());
73 } 73 }
74 // Unregister the client here, as it is not guaranteed in tests that the 74 // Unregister the client here, as it is not guaranteed in tests that the
75 // destructor will be called. 75 // destructor will be called.
76 GetSurfaceManager()->UnregisterSurfaceFactoryClient( 76 GetSurfaceManager()->UnregisterSurfaceFactoryClient(
77 id_allocator_->client_id()); 77 id_allocator_->client_id());
78 78
79 parent_surface_client_id_ = 0; 79 parent_surface_client_id_ = 0;
80
81 // After the RenderWidgetHostViewChildFrame loses the frame_connector, it
82 // won't be able to walk up the frame tree anymore. Clean up anything that
83 // needs to be done through the CrossProcessFrameConnector before it's gone.
84
85 // Unlocks the mouse if this RenderWidgetHostView holds the lock.
86 UnlockMouse();
80 } 87 }
81 frame_connector_ = frame_connector; 88 frame_connector_ = frame_connector;
82 if (frame_connector_) { 89 if (frame_connector_) {
83 GetSurfaceManager()->RegisterSurfaceFactoryClient( 90 GetSurfaceManager()->RegisterSurfaceFactoryClient(
84 id_allocator_->client_id(), this); 91 id_allocator_->client_id(), this);
85 RenderWidgetHostViewBase* parent_view = 92 RenderWidgetHostViewBase* parent_view =
86 frame_connector_->GetParentRenderWidgetHostView(); 93 frame_connector_->GetParentRenderWidgetHostView();
87 if (parent_view) { 94 if (parent_view) {
88 parent_surface_client_id_ = parent_view->GetSurfaceClientId(); 95 parent_surface_client_id_ = parent_view->GetSurfaceClientId();
89 DCHECK_NE(parent_surface_client_id_, 0u); 96 DCHECK_NE(parent_surface_client_id_, 0u);
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 frame_connector_->ForwardProcessAckedTouchEvent(touch, ack_result); 458 frame_connector_->ForwardProcessAckedTouchEvent(touch, ack_result);
452 } 459 }
453 460
454 bool RenderWidgetHostViewChildFrame::LockMouse() { 461 bool RenderWidgetHostViewChildFrame::LockMouse() {
455 if (frame_connector_) 462 if (frame_connector_)
456 return frame_connector_->LockMouse(); 463 return frame_connector_->LockMouse();
457 return false; 464 return false;
458 } 465 }
459 466
460 void RenderWidgetHostViewChildFrame::UnlockMouse() { 467 void RenderWidgetHostViewChildFrame::UnlockMouse() {
468 if (host_->delegate() && host_->delegate()->HasMouseLock(host_) &&
469 frame_connector_)
470 frame_connector_->UnlockMouse();
461 } 471 }
462 472
463 bool RenderWidgetHostViewChildFrame::IsMouseLocked() { 473 bool RenderWidgetHostViewChildFrame::IsMouseLocked() {
464 if (!frame_connector_) 474 if (!host_->delegate())
465 return false; 475 return false;
466 476
467 RenderWidgetHostViewBase* root_view = 477 return host_->delegate()->HasMouseLock(host_);
468 frame_connector_->GetRootRenderWidgetHostView();
469
470 if (root_view)
471 return root_view->IsMouseLocked();
472
473 return false;
474 } 478 }
475 479
476 uint32_t RenderWidgetHostViewChildFrame::GetSurfaceClientId() { 480 uint32_t RenderWidgetHostViewChildFrame::GetSurfaceClientId() {
477 return id_allocator_->client_id(); 481 return id_allocator_->client_id();
478 } 482 }
479 483
480 void RenderWidgetHostViewChildFrame::ProcessKeyboardEvent( 484 void RenderWidgetHostViewChildFrame::ProcessKeyboardEvent(
481 const NativeWebKeyboardEvent& event) { 485 const NativeWebKeyboardEvent& event) {
482 host_->ForwardKeyboardEvent(event); 486 host_->ForwardKeyboardEvent(event);
483 } 487 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 681
678 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { 682 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const {
679 return true; 683 return true;
680 } 684 }
681 685
682 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { 686 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const {
683 return surface_id_; 687 return surface_id_;
684 }; 688 };
685 689
686 } // namespace content 690 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698