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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 1711103002: Implement lifetime observer on RenderWidgetHostViewBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restructure, and make RWHVB derived classes responsible for early notification. Created 4 years, 10 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 (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/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <OpenGL/gl.h> 8 #include <OpenGL/gl.h>
9 #include <QuartzCore/QuartzCore.h> 9 #include <QuartzCore/QuartzCore.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 556
557 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { 557 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() {
558 gfx::Screen::GetScreen()->RemoveObserver(this); 558 gfx::Screen::GetScreen()->RemoveObserver(this);
559 559
560 // This is being called from |cocoa_view_|'s destructor, so invalidate the 560 // This is being called from |cocoa_view_|'s destructor, so invalidate the
561 // pointer. 561 // pointer.
562 cocoa_view_ = nil; 562 cocoa_view_ = nil;
563 563
564 UnlockMouse(); 564 UnlockMouse();
565 565
566 if (render_widget_host_ && render_widget_host_->delegate() &&
567 render_widget_host_->delegate()->GetInputEventRouter()) {
568 render_widget_host_->delegate()
569 ->GetInputEventRouter()
570 ->RemoveSurfaceIdNamespaceOwner(GetSurfaceIdNamespace());
571 }
572
573 // Ensure that the browser compositor is destroyed in a safe order. 566 // Ensure that the browser compositor is destroyed in a safe order.
574 ShutdownBrowserCompositor(); 567 ShutdownBrowserCompositor();
575 568
576 // We are owned by RenderWidgetHostViewCocoa, so if we go away before the 569 // We are owned by RenderWidgetHostViewCocoa, so if we go away before the
577 // RenderWidgetHost does we need to tell it not to hold a stale pointer to 570 // RenderWidgetHost does we need to tell it not to hold a stale pointer to
578 // us. 571 // us.
579 if (render_widget_host_) { 572 if (render_widget_host_) {
580 // If this is a RenderWidgetHostViewGuest's platform_view_, we're not the 573 // If this is a RenderWidgetHostViewGuest's platform_view_, we're not the
581 // RWH's view, the RenderWidgetHostViewGuest is. So don't reset the RWH's 574 // RWH's view, the RenderWidgetHostViewGuest is. So don't reset the RWH's
582 // view, the RenderWidgetHostViewGuest will do it. 575 // view, the RenderWidgetHostViewGuest will do it.
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 composition_range_ = range; 1042 composition_range_ = range;
1050 composition_bounds_ = character_bounds; 1043 composition_bounds_ = character_bounds;
1051 } 1044 }
1052 1045
1053 void RenderWidgetHostViewMac::RenderProcessGone(base::TerminationStatus status, 1046 void RenderWidgetHostViewMac::RenderProcessGone(base::TerminationStatus status,
1054 int error_code) { 1047 int error_code) {
1055 Destroy(); 1048 Destroy();
1056 } 1049 }
1057 1050
1058 void RenderWidgetHostViewMac::Destroy() { 1051 void RenderWidgetHostViewMac::Destroy() {
1052 // SurfaceIdNames registered with RenderWidgetHostInputEventRouter
kenrb 2016/02/22 17:05:10 nit: s/SurfaceIdNames/SurfaceIdNamespaces
wjmaclean 2016/02/23 13:13:26 Done.
1053 // have already been cleared when RenderWidgetHostViewBase notified its
1054 // observers of our impending destruction.
1059 [[NSNotificationCenter defaultCenter] 1055 [[NSNotificationCenter defaultCenter]
1060 removeObserver:cocoa_view_ 1056 removeObserver:cocoa_view_
1061 name:NSWindowWillCloseNotification 1057 name:NSWindowWillCloseNotification
1062 object:popup_window_]; 1058 object:popup_window_];
1063 1059
1064 // We've been told to destroy. 1060 // We've been told to destroy.
1065 [cocoa_view_ retain]; 1061 [cocoa_view_ retain];
1066 [cocoa_view_ removeFromSuperview]; 1062 [cocoa_view_ removeFromSuperview];
1067 [cocoa_view_ autorelease]; 1063 [cocoa_view_ autorelease];
1068 1064
1069 [popup_window_ close]; 1065 [popup_window_ close];
1070 popup_window_.autorelease(); 1066 popup_window_.autorelease();
1071 1067
1072 [fullscreen_window_manager_ exitFullscreenMode]; 1068 [fullscreen_window_manager_ exitFullscreenMode];
1073 fullscreen_window_manager_.reset(); 1069 fullscreen_window_manager_.reset();
1074 [pepper_fullscreen_window_ close]; 1070 [pepper_fullscreen_window_ close];
1075 1071
1076 // This can be called as part of processing the window's responder 1072 // This can be called as part of processing the window's responder
1077 // chain, for instance |-performKeyEquivalent:|. In that case the 1073 // chain, for instance |-performKeyEquivalent:|. In that case the
1078 // object needs to survive until the stack unwinds. 1074 // object needs to survive until the stack unwinds.
1079 pepper_fullscreen_window_.autorelease(); 1075 pepper_fullscreen_window_.autorelease();
1080 1076
1081 // Clear SurfaceID namespace ownership before we shutdown the
1082 // compositor.
1083 if (render_widget_host_ && render_widget_host_->delegate() &&
1084 render_widget_host_->delegate()->GetInputEventRouter()) {
1085 render_widget_host_->delegate()
1086 ->GetInputEventRouter()
1087 ->RemoveSurfaceIdNamespaceOwner(GetSurfaceIdNamespace());
1088 }
1089
1090 // Delete the delegated frame state, which will reach back into 1077 // Delete the delegated frame state, which will reach back into
1091 // render_widget_host_. 1078 // render_widget_host_.
1092 ShutdownBrowserCompositor(); 1079 ShutdownBrowserCompositor();
1093 1080
1081 // Make sure none of our observers send events for us to process after
1082 // we release render_widget_host_.
1083 NotifyObserversAboutShutdown();
1084
1094 // We get this call just before |render_widget_host_| deletes 1085 // We get this call just before |render_widget_host_| deletes
1095 // itself. But we are owned by |cocoa_view_|, which may be retained 1086 // itself. But we are owned by |cocoa_view_|, which may be retained
1096 // by some other code. Examples are WebContentsViewMac's 1087 // by some other code. Examples are WebContentsViewMac's
1097 // |latent_focus_view_| and TabWindowController's 1088 // |latent_focus_view_| and TabWindowController's
1098 // |cachedContentView_|. 1089 // |cachedContentView_|.
1099 render_widget_host_ = NULL; 1090 render_widget_host_ = NULL;
1100 } 1091 }
1101 1092
1102 // Called from the renderer to tell us what the tooltip text should be. It 1093 // Called from the renderer to tell us what the tooltip text should be. It
1103 // calls us frequently so we need to cache the value to prevent doing a lot 1094 // calls us frequently so we need to cache the value to prevent doing a lot
(...skipping 2341 matching lines...) Expand 10 before | Expand all | Expand 10 after
3445 3436
3446 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3437 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3447 // regions that are not draggable. (See ControlRegionView in 3438 // regions that are not draggable. (See ControlRegionView in
3448 // native_app_window_cocoa.mm). This requires the render host view to be 3439 // native_app_window_cocoa.mm). This requires the render host view to be
3449 // draggable by default. 3440 // draggable by default.
3450 - (BOOL)mouseDownCanMoveWindow { 3441 - (BOOL)mouseDownCanMoveWindow {
3451 return YES; 3442 return YES;
3452 } 3443 }
3453 3444
3454 @end 3445 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698