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

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmark_collection_view.mm

Issue 2610923005: Replace ObjCPropertyReleaser with ReleaseProperties() project-wide. (Closed)
Patch Set: Yank unrelated changes. Created 3 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 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 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_view.h" 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_view.h"
6 6
7 #import <UIKit/UIGestureRecognizerSubclass.h> 7 #import <UIKit/UIGestureRecognizerSubclass.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/ios/weak_nsobject.h" 12 #include "base/ios/weak_nsobject.h"
13 #include "base/mac/bind_objc_block.h" 13 #include "base/mac/bind_objc_block.h"
14 #include "base/mac/foundation_util.h" 14 #include "base/mac/foundation_util.h"
15 #include "base/mac/objc_property_releaser.h" 15 #include "base/mac/objc_release_properties.h"
16 #include "base/mac/scoped_nsobject.h" 16 #include "base/mac/scoped_nsobject.h"
17 #include "base/strings/sys_string_conversions.h" 17 #include "base/strings/sys_string_conversions.h"
18 #include "components/bookmarks/browser/bookmark_model.h" 18 #include "components/bookmarks/browser/bookmark_model.h"
19 #include "components/bookmarks/browser/bookmark_model_observer.h" 19 #include "components/bookmarks/browser/bookmark_model_observer.h"
20 #include "components/favicon/core/fallback_url_util.h" 20 #include "components/favicon/core/fallback_url_util.h"
21 #include "components/favicon/core/large_icon_service.h" 21 #include "components/favicon/core/large_icon_service.h"
22 #include "components/favicon_base/fallback_icon_style.h" 22 #include "components/favicon_base/fallback_icon_style.h"
23 #include "components/favicon_base/favicon_types.h" 23 #include "components/favicon_base/favicon_types.h"
24 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" 24 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
25 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h" 25 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h"
(...skipping 29 matching lines...) Expand all
55 const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0; 55 const NSTimeInterval kShowEmptyBookmarksBackgroundRefreshDelay = 1.0;
56 56
57 } // namespace 57 } // namespace
58 58
59 @interface BookmarkCollectionView ()<UICollectionViewDataSource, 59 @interface BookmarkCollectionView ()<UICollectionViewDataSource,
60 UICollectionViewDelegateFlowLayout, 60 UICollectionViewDelegateFlowLayout,
61 UIGestureRecognizerDelegate> { 61 UIGestureRecognizerDelegate> {
62 std::unique_ptr<bookmarks::BookmarkModelBridge> _modelBridge; 62 std::unique_ptr<bookmarks::BookmarkModelBridge> _modelBridge;
63 ios::ChromeBrowserState* _browserState; 63 ios::ChromeBrowserState* _browserState;
64 64
65 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkCollectionView;
66
67 // Map of favicon load tasks for each index path. Used to keep track of 65 // Map of favicon load tasks for each index path. Used to keep track of
68 // pending favicon load operations so that they can be cancelled upon cell 66 // pending favicon load operations so that they can be cancelled upon cell
69 // reuse. Keys are (section, item) pairs of cell index paths. 67 // reuse. Keys are (section, item) pairs of cell index paths.
70 std::map<IntegerPair, base::CancelableTaskTracker::TaskId> _faviconLoadTasks; 68 std::map<IntegerPair, base::CancelableTaskTracker::TaskId> _faviconLoadTasks;
71 // Task tracker used for async favicon loads. 69 // Task tracker used for async favicon loads.
72 base::CancelableTaskTracker _faviconTaskTracker; 70 base::CancelableTaskTracker _faviconTaskTracker;
73 } 71 }
74 72
75 // Redefined to be readwrite. 73 // Redefined to be readwrite.
76 @property(nonatomic, assign) bookmarks::BookmarkModel* bookmarkModel; 74 @property(nonatomic, assign) bookmarks::BookmarkModel* bookmarkModel;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 128
131 - (id)initWithFrame:(CGRect)frame { 129 - (id)initWithFrame:(CGRect)frame {
132 NOTREACHED(); 130 NOTREACHED();
133 return nil; 131 return nil;
134 } 132 }
135 133
136 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState 134 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
137 frame:(CGRect)frame { 135 frame:(CGRect)frame {
138 self = [super initWithFrame:frame]; 136 self = [super initWithFrame:frame];
139 if (self) { 137 if (self) {
140 _propertyReleaser_BookmarkCollectionView.Init(
141 self, [BookmarkCollectionView class]);
142
143 _browserState = browserState; 138 _browserState = browserState;
144 139
145 // Set up connection to the BookmarkModel. 140 // Set up connection to the BookmarkModel.
146 _bookmarkModel = 141 _bookmarkModel =
147 ios::BookmarkModelFactory::GetForBrowserState(browserState); 142 ios::BookmarkModelFactory::GetForBrowserState(browserState);
148 143
149 // Set up observers. 144 // Set up observers.
150 _modelBridge.reset( 145 _modelBridge.reset(
151 new bookmarks::BookmarkModelBridge(self, _bookmarkModel)); 146 new bookmarks::BookmarkModelBridge(self, _bookmarkModel));
152 147
(...skipping 10 matching lines...) Expand all
163 // A collection view with a layout that uses a dynamic animator (aka 158 // A collection view with a layout that uses a dynamic animator (aka
164 // something that changes the layout over time) will crash if it is 159 // something that changes the layout over time) will crash if it is
165 // deallocated while the animation is currently playing. 160 // deallocated while the animation is currently playing.
166 // Apparently if a tick has been dispatched it will execute, invoking a 161 // Apparently if a tick has been dispatched it will execute, invoking a
167 // method on the deallocated collection. 162 // method on the deallocated collection.
168 // The only purpose of this block is to retain the collection view for a 163 // The only purpose of this block is to retain the collection view for a
169 // while, giving the layout a chance to perform its last tick. 164 // while, giving the layout a chance to perform its last tick.
170 [moi self]; 165 [moi self];
171 }); 166 });
172 _faviconTaskTracker.TryCancelAll(); 167 _faviconTaskTracker.TryCancelAll();
168 base::mac::ReleaseProperties(self);
173 [super dealloc]; 169 [super dealloc];
174 } 170 }
175 171
176 - (void)setupViews { 172 - (void)setupViews {
177 self.backgroundColor = bookmark_utils_ios::mainBackgroundColor(); 173 self.backgroundColor = bookmark_utils_ios::mainBackgroundColor();
178 base::scoped_nsobject<UICollectionViewFlowLayout> layout( 174 base::scoped_nsobject<UICollectionViewFlowLayout> layout(
179 [[UICollectionViewFlowLayout alloc] init]); 175 [[UICollectionViewFlowLayout alloc] init]);
180 176
181 base::scoped_nsobject<UICollectionView> collectionView( 177 base::scoped_nsobject<UICollectionView> collectionView(
182 [[UICollectionView alloc] initWithFrame:self.bounds 178 [[UICollectionView alloc] initWithFrame:self.bounds
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 846
851 - (BOOL)shouldShowPromoCell { 847 - (BOOL)shouldShowPromoCell {
852 return NO; 848 return NO;
853 } 849 }
854 850
855 - (BOOL)isPromoActive { 851 - (BOOL)isPromoActive {
856 return NO; 852 return NO;
857 } 853 }
858 854
859 @end 855 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698