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

Side by Side Diff: components/reading_list/ios/reading_list_model_observer.h

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

Powered by Google App Engine
This is Rietveld 408576698