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 #import "components/reading_list/ios/reading_list_model_bridge_observer.h" | 5 #import "components/reading_list/ios/reading_list_model_bridge_observer.h" |
6 | 6 |
7 #include "components/reading_list/core/reading_list_entry.h" | 7 #include "components/reading_list/core/reading_list_entry.h" |
8 #include "components/reading_list/core/reading_list_model.h" | 8 #include "components/reading_list/core/reading_list_model.h" |
9 | 9 |
10 ReadingListModelBridge::ReadingListModelBridge( | 10 ReadingListModelBridge::ReadingListModelBridge( |
11 id<ReadingListModelBridgeObserver> observer, | 11 id<ReadingListModelBridgeObserver> observer, |
12 ReadingListModel* model) | 12 ReadingListModel* model) |
13 : observer_(observer), model_(model) { | 13 : observer_(observer), model_(model) { |
14 DCHECK(model); | 14 DCHECK(model); |
15 model_->AddObserver(this); | 15 model_->AddObserver(this); |
16 } | 16 } |
17 | 17 |
18 ReadingListModelBridge::~ReadingListModelBridge() { | 18 ReadingListModelBridge::~ReadingListModelBridge() { |
19 if (model_) { | 19 if (model_) { |
20 model_->RemoveObserver(this); | 20 model_->RemoveObserver(this); |
21 } | 21 } |
22 } | 22 } |
23 | 23 |
24 void ReadingListModelBridge::ReadingListModelLoaded( | 24 void ReadingListModelBridge::ReadingListModelLoaded( |
25 const ReadingListModel* model) { | 25 const ReadingListModel* model) { |
26 [observer_ readingListModelLoaded:model]; | 26 [observer_ readingListModelLoaded:model]; |
27 } | 27 } |
28 | 28 |
| 29 void ReadingListModelBridge::ReadingListModelBeingShutdown( |
| 30 const ReadingListModel* model) { |
| 31 if ([observer_ |
| 32 respondsToSelector:@selector(readingListModelBeingShutdown:)]) { |
| 33 [observer_ readingListModelBeingShutdown:model]; |
| 34 } |
| 35 } |
| 36 |
29 void ReadingListModelBridge::ReadingListModelBeingDeleted( | 37 void ReadingListModelBridge::ReadingListModelBeingDeleted( |
30 const ReadingListModel* model) { | 38 const ReadingListModel* model) { |
31 if ([observer_ respondsToSelector:@selector(readingListModelBeingDeleted:)]) { | 39 if ([observer_ respondsToSelector:@selector(readingListModelBeingDeleted:)]) { |
32 [observer_ readingListModelBeingDeleted:model]; | 40 [observer_ readingListModelBeingDeleted:model]; |
33 } | 41 } |
34 model_ = nullptr; | 42 model_ = nullptr; |
35 } | 43 } |
36 | 44 |
37 void ReadingListModelBridge::ReadingListWillRemoveEntry( | 45 void ReadingListModelBridge::ReadingListWillRemoveEntry( |
38 const ReadingListModel* model, | 46 const ReadingListModel* model, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 103 } |
96 | 104 |
97 void ReadingListModelBridge::ReadingListWillUpdateEntry( | 105 void ReadingListModelBridge::ReadingListWillUpdateEntry( |
98 const ReadingListModel* model, | 106 const ReadingListModel* model, |
99 const GURL& url) { | 107 const GURL& url) { |
100 if ([observer_ | 108 if ([observer_ |
101 respondsToSelector:@selector(readingListModel:willUpdateEntry:)]) { | 109 respondsToSelector:@selector(readingListModel:willUpdateEntry:)]) { |
102 [observer_ readingListModel:model willUpdateEntry:url]; | 110 [observer_ readingListModel:model willUpdateEntry:url]; |
103 } | 111 } |
104 } | 112 } |
OLD | NEW |