| 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 COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_DELEGATE_H_ | 5 #ifndef COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_DELEGATE_H_ |
| 6 #define COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_DELEGATE_H_ | 6 #define COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 | 11 |
| 12 class ReadingListEntry; | 12 class ReadingListEntry; |
| 13 | 13 |
| 14 // The delegate to handle callbacks from the ReadingListStore. | 14 // The delegate to handle callbacks from the ReadingListStore. |
| 15 class ReadingListStoreDelegate { | 15 class ReadingListStoreDelegate { |
| 16 public: | 16 public: |
| 17 ReadingListStoreDelegate() {} | |
| 18 virtual ~ReadingListStoreDelegate() {} | |
| 19 | |
| 20 using ReadingListEntries = std::map<GURL, ReadingListEntry>; | 17 using ReadingListEntries = std::map<GURL, ReadingListEntry>; |
| 21 // These three methods handle callbacks from a ReadingListStore. | 18 // These three methods handle callbacks from a ReadingListStore. |
| 22 // This method is called when the local store is loaded. |entries| contains | 19 // This method is called when the local store is loaded. |entries| contains |
| 23 // the ReadingListEntry present on the device before sync starts. | 20 // the ReadingListEntry present on the device before sync starts. |
| 24 virtual void StoreLoaded(std::unique_ptr<ReadingListEntries> entries) = 0; | 21 virtual void StoreLoaded(std::unique_ptr<ReadingListEntries> entries) = 0; |
| 25 // Handle sync events. | 22 // Handle sync events. |
| 26 // Called to add a new entry to the model. | 23 // Called to add a new entry to the model. |
| 27 // |entry| must not already exist in the model. | 24 // |entry| must not already exist in the model. |
| 28 virtual void SyncAddEntry(std::unique_ptr<ReadingListEntry> entry) = 0; | 25 virtual void SyncAddEntry(std::unique_ptr<ReadingListEntry> entry) = 0; |
| 29 | 26 |
| 30 // Called to merge a sync entry with a local entry in the model. | 27 // Called to merge a sync entry with a local entry in the model. |
| 31 // A local entry with the same URL must exist in the local store and have an | 28 // A local entry with the same URL must exist in the local store and have an |
| 32 // older UpdateTime. | 29 // older UpdateTime. |
| 33 // Return a pointer to the merged entry. | 30 // Return a pointer to the merged entry. |
| 34 virtual ReadingListEntry* SyncMergeEntry( | 31 virtual ReadingListEntry* SyncMergeEntry( |
| 35 std::unique_ptr<ReadingListEntry> entry) = 0; | 32 std::unique_ptr<ReadingListEntry> entry) = 0; |
| 36 | 33 |
| 37 // Called to remove an entry to the model. | 34 // Called to remove an entry to the model. |
| 38 virtual void SyncRemoveEntry(const GURL& url) = 0; | 35 virtual void SyncRemoveEntry(const GURL& url) = 0; |
| 36 |
| 37 protected: |
| 38 ReadingListStoreDelegate() {} |
| 39 virtual ~ReadingListStoreDelegate() {} |
| 40 |
| 39 private: | 41 private: |
| 40 DISALLOW_COPY_AND_ASSIGN(ReadingListStoreDelegate); | 42 DISALLOW_COPY_AND_ASSIGN(ReadingListStoreDelegate); |
| 41 }; | 43 }; |
| 42 | 44 |
| 43 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_DELEGATE_H_ | 45 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_DELEGATE_H_ |
| OLD | NEW |