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

Unified Diff: components/offline_pages/core/downloads/download_ui_adapter.h

Issue 2684973014: Only show Last N Pages in the UI when the corresponding tab is visible. (Closed)
Patch Set: Add unit tests Created 3 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: components/offline_pages/core/downloads/download_ui_adapter.h
diff --git a/components/offline_pages/core/downloads/download_ui_adapter.h b/components/offline_pages/core/downloads/download_ui_adapter.h
index abf413a139e814ef4480f9766b8916a31590c9ec..112356cdfde58648cf4a44b217b6785cdea6f872 100644
--- a/components/offline_pages/core/downloads/download_ui_adapter.h
+++ b/components/offline_pages/core/downloads/download_ui_adapter.h
@@ -113,12 +113,14 @@ class DownloadUIAdapter : public OfflinePageModel::Observer,
// change.
void TemporaryHiddenStatusChanged(const ClientId& client_id);
+ Delegate* delegate() { return delegate_.get(); }
+
private:
enum class State { NOT_LOADED, LOADING_PAGES, LOADING_REQUESTS, LOADED };
struct ItemInfo {
- explicit ItemInfo(const OfflinePageItem& page);
- explicit ItemInfo(const SavePageRequest& request);
+ ItemInfo(Delegate* delegate, const OfflinePageItem& page);
Dmitry Titov 2017/02/14 23:01:03 It'd be nice to avoid passing a delegate simply to
dewittj 2017/02/15 19:49:45 Done.
+ ItemInfo(Delegate* delegate, const SavePageRequest& request);
~ItemInfo();
std::unique_ptr<DownloadUIItem> ui_item;
@@ -158,6 +160,9 @@ class DownloadUIAdapter : public OfflinePageModel::Observer,
void OnDeletePagesDone(DeletePageResult result);
void AddItemHelper(std::unique_ptr<ItemInfo> item_info);
+ // This function is not re-entrant. It temporarily sets |deleting_item_|
+ // while it runs, so that functions such as |GetOfflineIdByGuid| will work
+ // during the |ItemDeleted| callback.
void DeleteItemHelper(const std::string& guid);
// Always valid, this class is a member of the model.
@@ -174,6 +179,8 @@ class DownloadUIAdapter : public OfflinePageModel::Observer,
// The cache of UI items. The key is DownloadUIItem.guid.
DownloadUIItems items_;
+ std::unique_ptr<ItemInfo> deleting_item_;
+
// The observers.
base::ObserverList<Observer> observers_;
int observers_count_;

Powered by Google App Engine
This is Rietveld 408576698