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

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

Issue 2706343007: Only show Last N Pages in the UI when the corresponding tab is visible. (cont'd) (Closed)
Patch Set: Rebase. 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 8bfb0a37c56181046a4bfd8ed6b18cd10dc8a10c..4fef8e1b5a54b8486f1fea6d5b3b64de21f9878c 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.
@@ -118,12 +122,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;
@@ -163,6 +169,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.
@@ -179,6 +188,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_;
« no previous file with comments | « components/offline_pages/core/BUILD.gn ('k') | components/offline_pages/core/downloads/download_ui_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698