OLD | NEW |
| (Empty) |
1 | |
2 // Copyright 2016 The Chromium Authors. All rights reserved. | |
3 // Use of this source code is governed by a BSD-style license that can be | |
4 // found in the LICENSE file. | |
5 | |
6 #ifndef COMPONENTS_READING_LIST_READING_LIST_MODEL_BRIDGE_OBSERVER_H_ | |
7 #define COMPONENTS_READING_LIST_READING_LIST_MODEL_BRIDGE_OBSERVER_H_ | |
8 | |
9 #import <Foundation/Foundation.h> | |
10 | |
11 #include "base/macros.h" | |
12 #include "components/reading_list/reading_list_model_observer.h" | |
13 | |
14 // Protocol duplicating all Reading List Model Observer methods in Objective-C. | |
15 @protocol ReadingListModelBridgeObserver<NSObject> | |
16 | |
17 @required | |
18 - (void)readingListModelLoaded:(const ReadingListModel*)model; | |
19 - (void)readingListModelDidApplyChanges:(const ReadingListModel*)model; | |
20 | |
21 @optional | |
22 - (void)readingListModel:(const ReadingListModel*)model | |
23 willRemoveUnreadEntryAtIndex:(size_t)index; | |
24 - (void)readingListModel:(const ReadingListModel*)model | |
25 willRemoveReadEntryAtIndex:(size_t)index; | |
26 | |
27 - (void)readingListModel:(const ReadingListModel*)model | |
28 willMoveEntry:(size_t)unreadIndex | |
29 isRead:(BOOL)read; | |
30 | |
31 - (void)readingListModel:(const ReadingListModel*)model | |
32 willAddUnreadEntry:(const ReadingListEntry&)entry; | |
33 - (void)readingListModel:(const ReadingListModel*)model | |
34 willAddReadEntry:(const ReadingListEntry&)entry; | |
35 | |
36 - (void)readingListModelBeganBatchUpdates:(const ReadingListModel*)model; | |
37 - (void)readingListModelCompletedBatchUpdates:(const ReadingListModel*)model; | |
38 | |
39 - (void)readingListModelBeingDeleted:(const ReadingListModel*)model; | |
40 | |
41 - (void)readingListModel:(const ReadingListModel*)model | |
42 willUpdateUnreadEntryAtIndex:(size_t)index; | |
43 - (void)readingListModel:(const ReadingListModel*)model | |
44 willUpdateReadEntryAtIndex:(size_t)index; | |
45 | |
46 @end | |
47 | |
48 // Observer for the Reading List model that translates all the callbacks to | |
49 // Objective-C calls. | |
50 class ReadingListModelBridge : public ReadingListModelObserver { | |
51 public: | |
52 explicit ReadingListModelBridge(id<ReadingListModelBridgeObserver> observer, | |
53 ReadingListModel* model); | |
54 ~ReadingListModelBridge() override; | |
55 | |
56 private: | |
57 void ReadingListModelBeganBatchUpdates( | |
58 const ReadingListModel* model) override; | |
59 | |
60 void ReadingListModelCompletedBatchUpdates( | |
61 const ReadingListModel* model) override; | |
62 void ReadingListModelLoaded(const ReadingListModel* model) override; | |
63 void ReadingListModelBeingDeleted(const ReadingListModel* model) override; | |
64 void ReadingListWillRemoveUnreadEntry(const ReadingListModel* model, | |
65 size_t index) override; | |
66 void ReadingListWillRemoveReadEntry(const ReadingListModel* model, | |
67 size_t index) override; | |
68 void ReadingListWillMoveEntry(const ReadingListModel* model, | |
69 size_t index, | |
70 bool read) override; | |
71 void ReadingListWillAddUnreadEntry(const ReadingListModel* model, | |
72 const ReadingListEntry& entry) override; | |
73 void ReadingListWillAddReadEntry(const ReadingListModel* model, | |
74 const ReadingListEntry& entry) override; | |
75 void ReadingListDidApplyChanges(ReadingListModel* model) override; | |
76 void ReadingListWillUpdateUnreadEntry(const ReadingListModel* model, | |
77 size_t index) override; | |
78 void ReadingListWillUpdateReadEntry(const ReadingListModel* model, | |
79 size_t index) override; | |
80 | |
81 __unsafe_unretained id<ReadingListModelBridgeObserver> observer_; | |
82 ReadingListModel* model_; // weak | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(ReadingListModelBridge); | |
85 }; | |
86 | |
87 #endif // COMPONENTS_READING_LIST_READING_LIST_MODEL_BRIDGE_OBSERVER_H_ | |
OLD | NEW |