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

Side by Side Diff: ios/chrome/browser/reading_list/reading_list_model_observer.h

Issue 2525663002: Refactor Reading List Model to use URL as key. (Closed)
Patch Set: format Created 4 years, 1 month 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 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_READING_LIST_READING_LIST_MODEL_OBSERVER_H_ 5 #ifndef IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_OBSERVER_H_
6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_OBSERVER_H_ 6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_OBSERVER_H_
7 7
8 #import <set> 8 #import <url/gurl.h>
9 #import <vector>
10 9
11 class ReadingListModel; 10 class ReadingListModel;
12 class ReadingListEntry; 11 class ReadingListEntry;
13 12
14 // Observer for the Reading List model. In the observer methods care should be 13 // Observer for the Reading List model. In the observer methods care should be
15 // taken to not modify the model. 14 // taken to not modify the model.
16 class ReadingListModelObserver { 15 class ReadingListModelObserver {
17 public: 16 public:
18 // Invoked when the model has finished loading. Until this method is called it 17 // Invoked when the model has finished loading. Until this method is called it
19 // is unsafe to use the model. 18 // is unsafe to use the model.
20 virtual void ReadingListModelLoaded(const ReadingListModel* model) = 0; 19 virtual void ReadingListModelLoaded(const ReadingListModel* model) = 0;
21 20
22 // Invoked when the batch updates are about to start. It will only be called 21 // Invoked when the batch updates are about to start. It will only be called
23 // once before ReadingListModelCompletedBatchUpdates, even if several updates 22 // once before ReadingListModelCompletedBatchUpdates, even if several updates
24 // are taking place at the same time. 23 // are taking place at the same time.
25 virtual void ReadingListModelBeganBatchUpdates( 24 virtual void ReadingListModelBeganBatchUpdates(
26 const ReadingListModel* model) {} 25 const ReadingListModel* model) {}
27 26
28 // Invoked when the batch updates have completed. This is called once all 27 // Invoked when the batch updates have completed. This is called once all
29 // batch updates are completed. 28 // batch updates are completed.
30 virtual void ReadingListModelCompletedBatchUpdates( 29 virtual void ReadingListModelCompletedBatchUpdates(
31 const ReadingListModel* model) {} 30 const ReadingListModel* model) {}
32 31
33 // Invoked from the destructor of the model. The model is no longer valid 32 // Invoked from the destructor of the model. The model is no longer valid
34 // after this call. There is no need to call RemoveObserver on the model from 33 // after this call. There is no need to call RemoveObserver on the model from
35 // here, as the observers are automatically deleted. 34 // here, as the observers are automatically deleted.
36 virtual void ReadingListModelBeingDeleted(const ReadingListModel* model) {} 35 virtual void ReadingListModelBeingDeleted(const ReadingListModel* model) {}
37 36
38 // Invoked when elements are about to be removed from the read or unread list. 37 // Invoked when elements are about to be removed from the read or unread list.
39 virtual void ReadingListWillRemoveUnreadEntry(const ReadingListModel* model, 38 virtual void ReadingListWillRemoveEntry(const ReadingListModel* model,
40 size_t index) {} 39 const GURL& url) {}
41 virtual void ReadingListWillRemoveReadEntry(const ReadingListModel* model,
42 size_t index) {}
43 // Invoked when elements are moved from unread to read or from read to unread. 40 // Invoked when elements are moved from unread to read or from read to unread.
44 // |index| is the original position and |read| the origin status. The element 41 // |index| is the original position and |read| the origin status. The element
45 // will change list and/or index but will not be deleted. 42 // will change list and/or index but will not be deleted.
46 virtual void ReadingListWillMoveEntry(const ReadingListModel* model, 43 virtual void ReadingListWillMoveEntry(const ReadingListModel* model,
47 size_t index, 44 const GURL& url) {}
48 bool read) {}
49 45
50 // Invoked when elements are added to the read or the unread list. The new 46 // Invoked when elements are added to the read or the unread list. The new
51 // entries are always added at the beginning. these methods may be called 47 // entries are always added at the beginning. these methods may be called
52 // multiple time (to process changes coming from a synchronization for 48 // multiple time (to process changes coming from a synchronization for
53 // example) and they will be executed in call order, the last call will end up 49 // example) and they will be executed in call order, the last call will end up
54 // in first position. 50 // in first position.
55 virtual void ReadingListWillAddUnreadEntry(const ReadingListModel* model, 51 virtual void ReadingListWillAddEntry(const ReadingListModel* model,
56 const ReadingListEntry& entry) {} 52 const ReadingListEntry& entry) {}
57
58 virtual void ReadingListWillAddReadEntry(const ReadingListModel* model,
59 const ReadingListEntry& entry) {}
60 53
61 // Invoked when an entry is about to change. 54 // Invoked when an entry is about to change.
62 virtual void ReadingListWillUpdateUnreadEntry(const ReadingListModel* model, 55 virtual void ReadingListWillUpdateEntry(const ReadingListModel* model,
63 size_t index) {} 56 const GURL& url) {}
64 virtual void ReadingListWillUpdateReadEntry(const ReadingListModel* model,
65 size_t index) {}
66 57
67 // Called after all the changes signaled by calls to the "Will" methods are 58 // Called after all the changes signaled by calls to the "Will" methods are
68 // done. All the "Will" methods are called as necessary, then the changes 59 // done. All the "Will" methods are called as necessary, then the changes
69 // are applied and then this method is called. 60 // are applied and then this method is called.
70 virtual void ReadingListDidApplyChanges(ReadingListModel* model) {} 61 virtual void ReadingListDidApplyChanges(ReadingListModel* model) {}
71 62
72 protected: 63 protected:
73 ReadingListModelObserver() {} 64 ReadingListModelObserver() {}
74 virtual ~ReadingListModelObserver() {} 65 virtual ~ReadingListModelObserver() {}
75 66
76 DISALLOW_COPY_AND_ASSIGN(ReadingListModelObserver); 67 DISALLOW_COPY_AND_ASSIGN(ReadingListModelObserver);
77 }; 68 };
78 69
79 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_OBSERVER_H_ 70 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698