| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_ENTRY_INSERTER_H_ | 5 #ifndef IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_ENTRY_INSERTER_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_ENTRY_INSERTER_H_ | 6 #define IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_ENTRY_INSERTER_H_ |
| 7 | 7 |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 | 9 |
| 10 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" | 10 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 - (void)historyEntryInserter:(HistoryEntryInserter*)inserter | 29 - (void)historyEntryInserter:(HistoryEntryInserter*)inserter |
| 30 didRemoveSectionAtIndex:(NSInteger)sectionIndex; | 30 didRemoveSectionAtIndex:(NSInteger)sectionIndex; |
| 31 @end | 31 @end |
| 32 | 32 |
| 33 // Object for ensuring history entry items are kept in order as they are added | 33 // Object for ensuring history entry items are kept in order as they are added |
| 34 // to the CollectionViewModel. | 34 // to the CollectionViewModel. |
| 35 @interface HistoryEntryInserter : NSObject | 35 @interface HistoryEntryInserter : NSObject |
| 36 | 36 |
| 37 // Delegate for the HistoryEntryInserter. Receives callbacks upon item and | 37 // Delegate for the HistoryEntryInserter. Receives callbacks upon item and |
| 38 // section insertion and removal. | 38 // section insertion and removal. |
| 39 @property(nonatomic, assign) id<HistoryEntryInserterDelegate> delegate; | 39 @property(nonatomic, weak) id<HistoryEntryInserterDelegate> delegate; |
| 40 | 40 |
| 41 // Designated initializer for HistoryEntryInserter. collectionViewModel is the | 41 // Designated initializer for HistoryEntryInserter. collectionViewModel is the |
| 42 // model into which entries are inserted. Sections for history entries are | 42 // model into which entries are inserted. Sections for history entries are |
| 43 // appended to the model. Sections already in the model at initialization | 43 // appended to the model. Sections already in the model at initialization |
| 44 // of the inserter should not be removed, and sections should not be added | 44 // of the inserter should not be removed, and sections should not be added |
| 45 // except by the inserter. Duplicate entries are not inserted. | 45 // except by the inserter. Duplicate entries are not inserted. |
| 46 - (instancetype)initWithModel:(CollectionViewModel*)collectionViewModel | 46 - (instancetype)initWithModel:(CollectionViewModel*)collectionViewModel |
| 47 NS_DESIGNATED_INITIALIZER; | 47 NS_DESIGNATED_INITIALIZER; |
| 48 - (instancetype)init NS_UNAVAILABLE; | 48 - (instancetype)init NS_UNAVAILABLE; |
| 49 | 49 |
| 50 // Inserts a history entry into the model at the correct sorted index path. | 50 // Inserts a history entry into the model at the correct sorted index path. |
| 51 // History entries in the model are sorted from most to least recent, and | 51 // History entries in the model are sorted from most to least recent, and |
| 52 // grouped into section by date. Duplicate entries are not inserted. Invokes | 52 // grouped into section by date. Duplicate entries are not inserted. Invokes |
| 53 // delegate callback when insertion is complete. | 53 // delegate callback when insertion is complete. |
| 54 - (void)insertHistoryEntryItem:(HistoryEntryItem*)item; | 54 - (void)insertHistoryEntryItem:(HistoryEntryItem*)item; |
| 55 | 55 |
| 56 // Returns section identifier for provided timestamp. Adds section for date if | 56 // Returns section identifier for provided timestamp. Adds section for date if |
| 57 // not found, and invokes delegate callback. | 57 // not found, and invokes delegate callback. |
| 58 - (NSUInteger)sectionIdentifierForTimestamp:(base::Time)timestamp; | 58 - (NSUInteger)sectionIdentifierForTimestamp:(base::Time)timestamp; |
| 59 | 59 |
| 60 // Removes section at |sectionIndex|, and invokes delegate callback when removal | 60 // Removes section at |sectionIndex|, and invokes delegate callback when removal |
| 61 // is complete. | 61 // is complete. |
| 62 - (void)removeSection:(NSInteger)sectionIndex; | 62 - (void)removeSection:(NSInteger)sectionIndex; |
| 63 | 63 |
| 64 @end | 64 @end |
| 65 | 65 |
| 66 #endif // IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_ENTRY_INSERTER_H_ | 66 #endif // IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_ENTRY_INSERTER_H_ |
| OLD | NEW |