summaryrefslogtreecommitdiffstats
path: root/ios/chrome/browser/reading_list/reading_list_model_observer.h
blob: 250e47b95ba6522dfdc8a4f239436114d2886ae3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_OBSERVER_H_
#define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_OBSERVER_H_

#import <set>
#import <vector>

class ReadingListModel;
class ReadingListEntry;

// Observer for the Reading List model. In the observer methods care should be
// taken to not modify the model.
class ReadingListModelObserver {
 public:
  // Invoked when the model has finished loading. Until this method is called it
  // is unsafe to use the model.
  virtual void ReadingListModelLoaded(const ReadingListModel* model) = 0;

  // Invoked when the batch updates are about to start. It will only be called
  // once before ReadingListModelCompletedBatchUpdates, even if several updates
  // are taking place at the same time.
  virtual void ReadingListModelBeganBatchUpdates(
      const ReadingListModel* model) {}

  // Invoked when the batch updates have completed. This is called once all
  // batch updates are completed.
  virtual void ReadingListModelCompletedBatchUpdates(
      const ReadingListModel* model) {}

  // Invoked from the destructor of the model. The model is no longer valid
  // after this call.
  virtual void ReadingListModelBeingDeleted(const ReadingListModel* model) {}

  // Invoked when elements are about to be removed from the read or unread list.
  virtual void ReadingListWillRemoveUnreadEntry(const ReadingListModel* model,
                                                size_t index) {}
  virtual void ReadingListWillRemoveReadEntry(const ReadingListModel* model,
                                              size_t index) {}

  // Invoked when elements are added to the read or the unread list. The new
  // entries are always added at the beginning. these methods may be called
  // multiple time (to process changes coming from a synchronization for
  // example) and they will be executed in call order, the last call will end up
  // in first position.
  virtual void ReadingListWillAddUnreadEntry(const ReadingListModel* model,
                                             const ReadingListEntry& entry) {}

  virtual void ReadingListWillAddReadEntry(const ReadingListModel* model,
                                           const ReadingListEntry& entry) {}

  // Called after all th"e changes signaled by calls to the "Will" methods are
  // done. All the "Will" methods are called as necessary, then the changes
  // are applied and then this method is called.
  virtual void ReadingListDidApplyChanges(ReadingListModel* model) {}

 protected:
  ReadingListModelObserver() {}
  virtual ~ReadingListModelObserver() {}

  DISALLOW_COPY_AND_ASSIGN(ReadingListModelObserver);
};

#endif  // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_OBSERVER_H_