reading_list_store_delegate.h 1.7 KB

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