Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: components/ntp_snippets/offline_pages/offline_page_proxy.cc

Issue 2469933002: Offline Pages: Replace Observer::OfflinePageModelChanged with OfflinePageAdded. (Closed)
Patch Set: Touch ups. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "components/ntp_snippets/offline_pages/offline_page_proxy.h" 5 #include "components/ntp_snippets/offline_pages/offline_page_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 8
9 using offline_pages::MultipleOfflinePageItemCallback;
9 using offline_pages::MultipleOfflinePageItemResult; 10 using offline_pages::MultipleOfflinePageItemResult;
10 using offline_pages::MultipleOfflinePageItemCallback; 11 using offline_pages::OfflinePageItem;
11 using offline_pages::OfflinePageModel; 12 using offline_pages::OfflinePageModel;
13 using SavePageResult = offline_pages::SavePageResult;
12 14
13 namespace ntp_snippets { 15 namespace ntp_snippets {
14 16
15 OfflinePageProxy::OfflinePageProxy(OfflinePageModel* offline_page_model) 17 OfflinePageProxy::OfflinePageProxy(OfflinePageModel* offline_page_model)
16 : offline_page_model_(offline_page_model), weak_ptr_factory_(this) { 18 : offline_page_model_(offline_page_model), weak_ptr_factory_(this) {
17 offline_page_model_->AddObserver(this); 19 offline_page_model_->AddObserver(this);
18 } 20 }
19 21
20 void OfflinePageProxy::GetAllPages( 22 void OfflinePageProxy::GetAllPages(
21 const MultipleOfflinePageItemCallback& callback) { 23 const MultipleOfflinePageItemCallback& callback) {
(...skipping 12 matching lines...) Expand all
34 // Private methods 36 // Private methods
35 37
36 OfflinePageProxy::~OfflinePageProxy() { 38 OfflinePageProxy::~OfflinePageProxy() {
37 offline_page_model_->RemoveObserver(this); 39 offline_page_model_->RemoveObserver(this);
38 } 40 }
39 41
40 void OfflinePageProxy::OfflinePageModelLoaded(OfflinePageModel* model) { 42 void OfflinePageProxy::OfflinePageModelLoaded(OfflinePageModel* model) {
41 DCHECK_EQ(offline_page_model_, model); 43 DCHECK_EQ(offline_page_model_, model);
42 } 44 }
43 45
44 void OfflinePageProxy::OfflinePageModelChanged(OfflinePageModel* model) { 46 void OfflinePageProxy::OfflinePageAdded(OfflinePageModel* model,
fgorski 2016/11/02 15:51:06 Please ping the owners of this class, as they may
dewittj 2016/11/02 16:34:37 That's the plan
47 SavePageResult result,
48 const OfflinePageItem* item) {
45 DCHECK_EQ(offline_page_model_, model); 49 DCHECK_EQ(offline_page_model_, model);
46 FetchOfflinePagesAndNotify(); 50 FetchOfflinePagesAndNotify();
47 } 51 }
48 52
49 void OfflinePageProxy::OfflinePageDeleted( 53 void OfflinePageProxy::OfflinePageDeleted(
50 int64_t offline_id, 54 int64_t offline_id,
51 const offline_pages::ClientId& client_id) { 55 const offline_pages::ClientId& client_id) {
52 for (Observer& observer : observers_) 56 for (Observer& observer : observers_)
53 observer.OfflinePageDeleted(offline_id, client_id); 57 observer.OfflinePageDeleted(offline_id, client_id);
54 } 58 }
55 59
56 void OfflinePageProxy::FetchOfflinePagesAndNotify() { 60 void OfflinePageProxy::FetchOfflinePagesAndNotify() {
57 offline_page_model_->GetAllPages(base::Bind( 61 offline_page_model_->GetAllPages(base::Bind(
58 &OfflinePageProxy::OnOfflinePagesLoaded, weak_ptr_factory_.GetWeakPtr())); 62 &OfflinePageProxy::OnOfflinePagesLoaded, weak_ptr_factory_.GetWeakPtr()));
59 } 63 }
60 64
61 void OfflinePageProxy::OnOfflinePagesLoaded( 65 void OfflinePageProxy::OnOfflinePagesLoaded(
62 const MultipleOfflinePageItemResult& result) { 66 const MultipleOfflinePageItemResult& result) {
63 for (Observer& observer : observers_) 67 for (Observer& observer : observers_)
64 observer.OfflinePageModelChanged(result); 68 observer.OfflinePageModelChanged(result);
65 } 69 }
66 70
67 } // namespace ntp_snippets 71 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698