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

Unified Diff: chrome/browser/ui/webui/md_downloads/downloads_list_tracker.h

Issue 1492273002: MD Downloads: limit the amount of downloads we send (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-dl-data
Patch Set: self-review Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/md_downloads/downloads_list_tracker.h
diff --git a/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.h b/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.h
index 05399b337b1e1a1b86b6a2bd3618279c98e20a7c..af3b6ab918f4efbad4ee211778a99b54180fcc0d 100644
--- a/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.h
+++ b/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.h
@@ -34,18 +34,18 @@ class DownloadsListTracker : public AllDownloadItemNotifier::Observer {
content::WebUI* web_ui);
~DownloadsListTracker() override;
- // Clears all downloads on the page (if it's ready).
- void CallClearAll();
-
- // Shows only downloads that match |search_terms|. An empty list shows all
- // downloads. Returns whether |search_terms.Equals(&search_terms_)|.
+ // This class only cares about downloads that match |search_terms|.
+ // An empty list shows all downloads (the default). Returns true if
+ // |search_terms| differ from the current ones.
bool SetSearchTerms(const base::ListValue& search_terms);
- // Sends all downloads and enables updates.
- void Start();
+ // Starts sending updates and sends a capped amount of downloads. Tracks which
+ // downloads have been sent. Re-call this to send more.
+ void StartAndSendChunk();
- // Stops sending updates to the page.
- void Stop();
+ // Clears all downloads on the page if currently sending updates, resets chunk
+ // tracking data, and stops sending updates.
+ void Reset();
content::DownloadManager* GetMainNotifierManager() const;
content::DownloadManager* GetOriginalNotifierManager() const;
@@ -80,24 +80,23 @@ class DownloadsListTracker : public AllDownloadItemNotifier::Observer {
// Called by both constructors to initialize common state.
void Init();
- // Clears and re-inserts all visible items in a sorted order into
- // |sorted_visible_items_|.
- void RebuildSortedSet();
+ // Clears and re-inserts all downloads items into |sorted_items_|.
+ void RebuildSortedItems();
// Whether |item| should show on the current page.
bool ShouldShow(const content::DownloadItem& item) const;
- // Gets a page index for |position| from |sorted_visible_items_|.
- int GetIndex(const SortedSet::iterator& position) const;
+ // Returns the index of |item| in |sorted_items_|.
+ size_t GetIndex(const SortedSet::iterator& item) const;
- // Calls "insertItems" if |sending_updates_|.
- void CallInsertItem(const SortedSet::iterator& insert);
+ // Calls "insertItems" if sending updates and the page knows about |insert|.
+ void InsertItem(const SortedSet::iterator& insert);
- // Calls "updateItem" if |sending_updates_|.
- void CallUpdateItem(const SortedSet::iterator& update);
+ // Calls "updateItem" if sending updates and the page knows about |update|.
+ void UpdateItem(const SortedSet::iterator& update);
- // Removes the item that corresponds to |remove| and sends a "removeItems"
- // message to the page if |sending_updates_|.
+ // Removes the item that corresponds to |remove| and sends "removeItems"
+ // if sending updates.
void RemoveItem(const SortedSet::iterator& remove);
AllDownloadItemNotifier main_notifier_;
@@ -114,7 +113,10 @@ class DownloadsListTracker : public AllDownloadItemNotifier::Observer {
// via JavaScript.
bool sending_updates_ = false;
- SortedSet sorted_visible_items_;
+ SortedSet sorted_items_;
+
+ // The number of items sent to the page so far.
+ size_t sent_to_page_ = 0u;
// Current search terms.
std::vector<base::string16> search_terms_;

Powered by Google App Engine
This is Rietveld 408576698