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

Unified Diff: chrome/browser/ui/cocoa/download/download_shelf_controller.mm

Issue 1221173003: [Mac] Inform reference counted objects that hold a weak Browser* when the Browser is being destroye… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/download/download_shelf_controller.mm
diff --git a/chrome/browser/ui/cocoa/download/download_shelf_controller.mm b/chrome/browser/ui/cocoa/download/download_shelf_controller.mm
index ebebb03f18c96560117ed7c28b07ca535c560912..fafbb78d8d59b9a92fa75c743133c378e3d56390 100644
--- a/chrome/browser/ui/cocoa/download/download_shelf_controller.mm
+++ b/chrome/browser/ui/cocoa/download/download_shelf_controller.mm
@@ -142,13 +142,26 @@ const NSSize kHoverCloseButtonDefaultSize = { 18, 18 };
}
- (void)dealloc {
+ [self browserWillBeDestroyed];
+ [super dealloc];
+}
+
+- (void)browserWillBeDestroyed {
[[NSNotificationCenter defaultCenter] removeObserver:self];
- [self cancelAutoClose];
+
+ // We need to explicitly release our download controllers here since they need
+ // to remove themselves as observers before the remaining shutdown happens.
+ [[self animatableView] stopAnimation];
[self removeTrackingArea];
+ [self cancelAutoClose];
+ while ([downloadItemControllers_ count] > 0) {
+ [self removeDownload:[downloadItemControllers_ lastObject]
+ isShelfClosing:YES];
+ }
+ downloadItemControllers_.reset();
- // The controllers will unregister themselves as observers when they are
- // deallocated. No need to do that here.
- [super dealloc];
+ bridge_.reset();
+ navigator_ = nullptr;
}
// Called after the frame's rect has changed; usually when the height is
@@ -213,19 +226,6 @@ const NSSize kHoverCloseButtonDefaultSize = { 18, 18 };
[self maybeAutoCloseAfterDelay];
}
-// We need to explicitly release our download controllers here since they need
-// to remove themselves as observers before the remaining shutdown happens.
-- (void)exiting {
- [[self animatableView] stopAnimation];
- [self removeTrackingArea];
- [self cancelAutoClose];
- while ([downloadItemControllers_ count] > 0) {
- [self removeDownload:[downloadItemControllers_ lastObject]
- isShelfClosing:YES];
- }
- downloadItemControllers_.reset();
-}
-
- (void)showDownloadShelf:(BOOL)show
isUserAction:(BOOL)isUserAction {
[self cancelAutoClose];

Powered by Google App Engine
This is Rietveld 408576698