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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm

Issue 2567973002: Mac: Fix lifetime problem under BookmarkBarController stopPulsingBookmarkNode. (Closed)
Patch Set: Guarantee a crash Created 4 years 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 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #import "base/mac/bundle_locations.h" 9 #import "base/mac/bundle_locations.h"
10 #import "base/mac/foundation_util.h" 10 #import "base/mac/foundation_util.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 354
355 node = node->parent(); 355 node = node->parent();
356 } 356 }
357 NOTREACHED(); 357 NOTREACHED();
358 return nil; 358 return nil;
359 } 359 }
360 360
361 - (void)startPulsingBookmarkNode:(const BookmarkNode*)node { 361 - (void)startPulsingBookmarkNode:(const BookmarkNode*)node {
362 [self stopPulsingBookmarkNode]; 362 [self stopPulsingBookmarkNode];
363 363
364 pulsingButton_ = [self bookmarkButtonToPulseForNode:node]; 364 pulsingButton_.reset([self bookmarkButtonToPulseForNode:node],
365 base::scoped_policy::RETAIN);
365 if (!pulsingButton_) 366 if (!pulsingButton_)
366 return; 367 return;
367 368
368 [pulsingButton_ setPulseIsStuckOn:YES]; 369 [pulsingButton_ setPulseIsStuckOn:YES];
369 pulsingBookmarkObserver_.reset( 370 pulsingBookmarkObserver_.reset(
370 new BookmarkModelObserverForCocoa(bookmarkModel_, ^() { 371 new BookmarkModelObserverForCocoa(bookmarkModel_, ^() {
371 // Stop pulsing if anything happened to the node. 372 // Stop pulsing if anything happened to the node.
372 [self stopPulsingBookmarkNode]; 373 [self stopPulsingBookmarkNode];
373 })); 374 }));
374 pulsingBookmarkObserver_->StartObservingNode(node); 375 pulsingBookmarkObserver_->StartObservingNode(node);
375 } 376 }
376 377
377 - (void)stopPulsingBookmarkNode { 378 - (void)stopPulsingBookmarkNode {
378 if (!pulsingButton_) 379 if (!pulsingButton_)
379 return; 380 return;
380 381
381 [pulsingButton_ setPulseIsStuckOn:NO]; 382 [pulsingButton_ setPulseIsStuckOn:NO];
382 pulsingButton_ = nil; 383 pulsingButton_.reset();
383 pulsingBookmarkObserver_.reset(); 384 pulsingBookmarkObserver_.reset();
384 } 385 }
385 386
386 - (void)dealloc { 387 - (void)dealloc {
387 [self browserWillBeDestroyed]; 388 [self browserWillBeDestroyed];
388 [super dealloc]; 389 [super dealloc];
389 } 390 }
390 391
391 - (void)browserWillBeDestroyed { 392 - (void)browserWillBeDestroyed {
392 // If |bridge_| is null it means -viewDidLoad has not yet been called, which 393 // If |bridge_| is null it means -viewDidLoad has not yet been called, which
(...skipping 2612 matching lines...) Expand 10 before | Expand all | Expand 10 after
3005 - (id<BookmarkButtonControllerProtocol>)controllerForNode: 3006 - (id<BookmarkButtonControllerProtocol>)controllerForNode:
3006 (const BookmarkNode*)node { 3007 (const BookmarkNode*)node {
3007 // See if it's in the bar, then if it is in the hierarchy of visible 3008 // See if it's in the bar, then if it is in the hierarchy of visible
3008 // folder menus. 3009 // folder menus.
3009 if (bookmarkModel_->bookmark_bar_node() == node) 3010 if (bookmarkModel_->bookmark_bar_node() == node)
3010 return self; 3011 return self;
3011 return [folderController_ controllerForNode:node]; 3012 return [folderController_ controllerForNode:node];
3012 } 3013 }
3013 3014
3014 @end 3015 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698