| Index: ios/chrome/browser/ui/history/history_entry_inserter.h
|
| diff --git a/ios/chrome/browser/ui/history/history_entry_inserter.h b/ios/chrome/browser/ui/history/history_entry_inserter.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d34fc98cdc8b2bbc217eccfe429736a4328b8392
|
| --- /dev/null
|
| +++ b/ios/chrome/browser/ui/history/history_entry_inserter.h
|
| @@ -0,0 +1,66 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_ENTRY_INSERTER_H_
|
| +#define IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_ENTRY_INSERTER_H_
|
| +
|
| +#import <Foundation/Foundation.h>
|
| +
|
| +#import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
|
| +
|
| +namespace base {
|
| +class Time;
|
| +}
|
| +@class CollectionViewModel;
|
| +@class HistoryEntryInserter;
|
| +@class HistoryEntryItem;
|
| +
|
| +// Delegate for HistoryEntryInserter. Provides callbacks for completion of item
|
| +// and section insertion and deletion.
|
| +@protocol HistoryEntryInserterDelegate<NSObject>
|
| +// Invoked when the inserter has finished inserting an item.
|
| +- (void)historyEntryInserter:(HistoryEntryInserter*)inserter
|
| + didInsertItemAtIndexPath:(NSIndexPath*)indexPath;
|
| +// Invoked when the inserter has finished inserting a section.
|
| +- (void)historyEntryInserter:(HistoryEntryInserter*)inserter
|
| + didInsertSectionAtIndex:(NSInteger)sectionIndex;
|
| +// Invoked when the inserter has finished removing a section.
|
| +- (void)historyEntryInserter:(HistoryEntryInserter*)inserter
|
| + didRemoveSectionAtIndex:(NSInteger)sectionIndex;
|
| +@end
|
| +
|
| +// Object for ensuring history entry items are kept in order as they are added
|
| +// to the CollectionViewModel.
|
| +@interface HistoryEntryInserter : NSObject
|
| +
|
| +// Delegate for the HistoryEntryInserter. Receives callbacks upon item and
|
| +// section insertion and removal.
|
| +@property(nonatomic, assign) id<HistoryEntryInserterDelegate> delegate;
|
| +
|
| +// Designated initializer for HistoryEntryInserter. collectionViewModel is the
|
| +// model into which entries are inserted. Sections for history entries are
|
| +// appended to the model. Sections already in the model at initialization
|
| +// of the inserter should not be removed, and sections should not be added
|
| +// except by the inserter. Duplicate entries are not inserted.
|
| +- (instancetype)initWithModel:(CollectionViewModel*)collectionViewModel
|
| + NS_DESIGNATED_INITIALIZER;
|
| +- (instancetype)init NS_UNAVAILABLE;
|
| +
|
| +// Inserts a history entry into the model at the correct sorted index path.
|
| +// History entries in the model are sorted from most to least recent, and
|
| +// grouped into section by date. Duplicate entries are not inserted. Invokes
|
| +// delegate callback when insertion is complete.
|
| +- (void)insertHistoryEntryItem:(HistoryEntryItem*)item;
|
| +
|
| +// Returns section identifier for provided timestamp. Adds section for date if
|
| +// not found, and invokes delegate callback.
|
| +- (NSUInteger)sectionIdentifierForTimestamp:(base::Time)timestamp;
|
| +
|
| +// Removes section at |sectionIndex|, and invokes delegate callback when removal
|
| +// is complete.
|
| +- (void)removeSection:(NSInteger)sectionIndex;
|
| +
|
| +@end
|
| +
|
| +#endif // IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_ENTRY_INSERTER_H_
|
|
|