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

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: Move impl out 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..a8562be7bfc6bf156ff51e429c9d3a2e8d3cc4ea 100644
--- a/components/offline_pages/core/downloads/download_ui_adapter.h
+++ b/components/offline_pages/core/downloads/download_ui_adapter.h
@@ -1,4 +1,4 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
+// Copyright 2017 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.
@@ -48,6 +48,10 @@ class DownloadUIAdapter : public OfflinePageModel::Observer,
// of temporary visibility changes, the Delegate is supposed to call
// DownloadUIAdapter::TemporarilyHiddenStatusChanged().
virtual bool IsTemporarilyHiddenInUI(const ClientId& client_id) = 0;
+
+ // Delegates need a reference to the UI adapter in order to notify it about
+ // visibility changes.
+ virtual void SetUIAdapter(DownloadUIAdapter* ui_adapter) = 0;
};
// Observer, normally implemented by UI or a Bridge.
@@ -113,12 +117,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(const OfflinePageItem& page, bool temporarily_hidden);
+ ItemInfo(const SavePageRequest& request, bool temporarily_hidden);
~ItemInfo();
std::unique_ptr<DownloadUIItem> ui_item;
@@ -158,6 +164,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 +183,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