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

Side by Side Diff: components/offline_pages/core/downloads/download_ui_adapter.cc

Issue 2564163002: [Offline Pages] Remove load state from public OfflinePageModel API. (Closed)
Patch Set: Fix broken tests. Created 4 years 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/offline_pages/core/downloads/download_ui_adapter.h" 5 #include "components/offline_pages/core/downloads/download_ui_adapter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 DCHECK(observer); 68 DCHECK(observer);
69 if (!observers_.HasObserver(observer)) 69 if (!observers_.HasObserver(observer))
70 return; 70 return;
71 observers_.RemoveObserver(observer); 71 observers_.RemoveObserver(observer);
72 --observers_count_; 72 --observers_count_;
73 // Once the last observer is gone, clear cached data. 73 // Once the last observer is gone, clear cached data.
74 if (observers_count_ == 0) 74 if (observers_count_ == 0)
75 ClearCache(); 75 ClearCache();
76 } 76 }
77 77
78 void DownloadUIAdapter::OfflinePageModelLoaded(OfflinePageModel* model) {
79 // This signal is not used here.
80 }
81
82 void DownloadUIAdapter::OfflinePageAdded(OfflinePageModel* model, 78 void DownloadUIAdapter::OfflinePageAdded(OfflinePageModel* model,
83 const OfflinePageItem& added_page) { 79 const OfflinePageItem& added_page) {
84 DCHECK(model == model_); 80 DCHECK(model == model_);
85 if (!IsVisibleInUI(added_page.client_id)) 81 if (!IsVisibleInUI(added_page.client_id))
86 return; 82 return;
87 83
88 const std::string& guid = added_page.client_id.id; 84 const std::string& guid = added_page.client_id.id;
89 DCHECK(items_.find(guid) == items_.end()); 85 DCHECK(items_.find(guid) == items_.end());
90 86
91 items_[guid] = base::MakeUnique<ItemInfo>(added_page); 87 items_[guid] = base::MakeUnique<ItemInfo>(added_page);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // TODO(dimich): Consider adding UMA to record user actions. 188 // TODO(dimich): Consider adding UMA to record user actions.
193 } 189 }
194 190
195 bool DownloadUIAdapter::IsVisibleInUI(const ClientId& client_id) { 191 bool DownloadUIAdapter::IsVisibleInUI(const ClientId& client_id) {
196 const std::string& name_space = client_id.name_space; 192 const std::string& name_space = client_id.name_space;
197 return model_->GetPolicyController()->IsSupportedByDownload(name_space) && 193 return model_->GetPolicyController()->IsSupportedByDownload(name_space) &&
198 base::IsValidGUID(client_id.id); 194 base::IsValidGUID(client_id.id);
199 } 195 }
200 196
201 } // namespace offline_pages 197 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698