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

Unified Diff: chrome/browser/jumplist_win.h

Issue 7538022: Jumplist Bug (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/jumplist_win.cc » ('j') | chrome/browser/jumplist_win.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/jumplist_win.h
===================================================================
--- chrome/browser/jumplist_win.h (revision 94914)
+++ chrome/browser/jumplist_win.h (working copy)
@@ -12,9 +12,13 @@
#include <vector>
#include "base/memory/ref_counted.h"
+#include "base/synchronization/lock.h"
#include "chrome/browser/history/history.h"
+#include "chrome/browser/history/history_types.h"
+#include "chrome/browser/history/top_sites.h"
MAD 2011/08/15 16:16:16 Do we need this include here?
MAD 2011/08/15 21:52:42 Here...
#include "chrome/browser/sessions/tab_restore_service.h"
#include "chrome/browser/sessions/tab_restore_service_observer.h"
+#include "chrome/browser/ui/webui/ntp/base_most_visited_handler.h"
MAD 2011/08/15 16:16:16 Please remove deprecated most visited base class i
MAD 2011/08/15 21:52:42 Here...
#include "content/browser/cancelable_request.h"
class FilePath;
@@ -96,15 +100,26 @@
// AddObserver() and register this class as an observer, it automatically
// updates a JumpList when a tab is added or removed.
//
+// This class also implements BaseMostVisitedHandler. So by calling
+// AddObserver() we also register for TOP_SITES_CHANGED notifications, and the
+// JumpList is updated when a top site is added or blacklisted.
MAD 2011/08/15 16:16:16 I think this whole paragraph can go away...
MAD 2011/08/15 21:52:42 Here...
+//
// Updating a JumpList requires some file operations and it is not good to
// update it in a UI thread. To solve this problem, this class posts a
// task when it actually updates a JumpList. (This task is implemented in an
MAD 2011/08/15 16:16:16 Please update comment since we now use a runnable
MAD 2011/08/15 21:52:42 Here...
// anomynous namespace in "jumplist_win.cc".)
-class JumpList : public TabRestoreServiceObserver {
+class JumpList : public TabRestoreServiceObserver,
+ public NotificationObserver,
+ public base::RefCountedThreadSafe<JumpList> {
public:
JumpList();
~JumpList();
+ // NotificationObserver implementation.
+ virtual void Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
// Registers (or unregisters) this object as an observer.
// When the TabRestoreService object notifies the tab status is changed, this
// class automatically updates an application JumpList.
@@ -135,12 +150,8 @@
// given list.
// These functions are copied from the RecentlyClosedTabsHandler class for
// compatibility with the new-tab page.
- bool AddTab(const TabRestoreService::Tab* tab,
- ShellLinkItemList* list,
- size_t max_items);
- bool AddWindow(const TabRestoreService::Window* window,
- ShellLinkItemList* list,
- size_t max_items);
+ bool AddTab(const TabRestoreService::Tab* tab, size_t max_items);
+ bool AddWindow(const TabRestoreService::Window* window, size_t max_items);
// Starts loading a favicon for each URL in |icon_urls_|.
// This function just sends a query to HistoryService.
@@ -162,14 +173,34 @@
void OnFaviconDataAvailable(HistoryService::Handle handle,
history::FaviconData favicon);
+ // Callback for TopSites. BaseMostVisitedHandler that notifies when the "Most
MAD 2011/08/15 16:16:16 Please update comment.
MAD 2011/08/15 21:52:42 Here...
+ // Visited" list is available. This function updates the ShellLinkItemList
+ // objects and send another query that retrieves a favicon for each URL in
+ // the list.
+ void OnMostVisitedURLsAvailable(
+ const history::MostVisitedURLList& data);
+
+ // Runnable method that updates the jumplist, once have all the data
+ // has been fetched.
+ void JumpList::RunUpdate();
+
+ // Helper method for RunUpdate to decode the data about the asynchrounously
+ // loaded icons
+ void DecodeIconData(const ShellLinkItemList& item_list);
+
+ // Send a request to the HistoryService to get the most visited pages.
+ void StartQueryForTopSites();
+
private:
// Our consumers for HistoryService.
CancelableRequestConsumer most_visited_consumer_;
CancelableRequestConsumer favicon_consumer_;
+ CancelableRequestConsumer topsites_consumer_;
- // The Profile object used for listening its events.
Profile* profile_;
+ NotificationRegistrar registrar_;
+
// App id to associate with the jump list.
std::wstring app_id_;
@@ -185,6 +216,14 @@
// A list of URLs we need to retrieve their favicons.
typedef std::pair<std::string, scoped_refptr<ShellLinkItem> > URLPair;
std::list<URLPair> icon_urls_;
+
+ // Handle of last favicon request used to cancel if a new request
+ // comes in before the current one returns.
+ FaviconService::Handle handle_;
+
+ // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_
+ // as they may be used by up to 3 threads.
MAD 2011/08/15 16:16:16 Please mention in comments above these data member
MAD 2011/08/15 21:52:42 Here...
+ base::Lock list_lock_;
};
#endif // CHROME_BROWSER_JUMPLIST_WIN_H_
« no previous file with comments | « no previous file | chrome/browser/jumplist_win.cc » ('j') | chrome/browser/jumplist_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698