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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/jumplist_win.cc » ('j') | chrome/browser/jumplist_win.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_JUMPLIST_WIN_H_ 5 #ifndef CHROME_BROWSER_JUMPLIST_WIN_H_
6 #define CHROME_BROWSER_JUMPLIST_WIN_H_ 6 #define CHROME_BROWSER_JUMPLIST_WIN_H_
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/synchronization/lock.h"
15 #include "chrome/browser/history/history.h" 16 #include "chrome/browser/history/history.h"
17 #include "chrome/browser/history/history_types.h"
18 #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...
16 #include "chrome/browser/sessions/tab_restore_service.h" 19 #include "chrome/browser/sessions/tab_restore_service.h"
17 #include "chrome/browser/sessions/tab_restore_service_observer.h" 20 #include "chrome/browser/sessions/tab_restore_service_observer.h"
21 #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...
18 #include "content/browser/cancelable_request.h" 22 #include "content/browser/cancelable_request.h"
19 23
20 class FilePath; 24 class FilePath;
21 class Profile; 25 class Profile;
22 class PageUsageData; 26 class PageUsageData;
23 27
24 // Represents a class used for creating an IShellLink object by the utility 28 // Represents a class used for creating an IShellLink object by the utility
25 // functions in this file. 29 // functions in this file.
26 // This class consists of three strings and a integer. 30 // This class consists of three strings and a integer.
27 // * arguments (std::wstring) 31 // * arguments (std::wstring)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // JumpList: 93 // JumpList:
90 // * Retrieving "Most Visited" pages from HistoryService; 94 // * Retrieving "Most Visited" pages from HistoryService;
91 // * Retrieving strings from the application resource; 95 // * Retrieving strings from the application resource;
92 // * Creatng COM objects used by JumpList from PageUsageData objects; 96 // * Creatng COM objects used by JumpList from PageUsageData objects;
93 // * Adding COM objects to JumpList, etc. 97 // * Adding COM objects to JumpList, etc.
94 // 98 //
95 // This class also implements TabRestoreServiceObserver. So, once we call 99 // This class also implements TabRestoreServiceObserver. So, once we call
96 // AddObserver() and register this class as an observer, it automatically 100 // AddObserver() and register this class as an observer, it automatically
97 // updates a JumpList when a tab is added or removed. 101 // updates a JumpList when a tab is added or removed.
98 // 102 //
103 // This class also implements BaseMostVisitedHandler. So by calling
104 // AddObserver() we also register for TOP_SITES_CHANGED notifications, and the
105 // 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...
106 //
99 // Updating a JumpList requires some file operations and it is not good to 107 // Updating a JumpList requires some file operations and it is not good to
100 // update it in a UI thread. To solve this problem, this class posts a 108 // update it in a UI thread. To solve this problem, this class posts a
101 // task when it actually updates a JumpList. (This task is implemented in an 109 // 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...
102 // anomynous namespace in "jumplist_win.cc".) 110 // anomynous namespace in "jumplist_win.cc".)
103 class JumpList : public TabRestoreServiceObserver { 111 class JumpList : public TabRestoreServiceObserver,
112 public NotificationObserver,
113 public base::RefCountedThreadSafe<JumpList> {
104 public: 114 public:
105 JumpList(); 115 JumpList();
106 ~JumpList(); 116 ~JumpList();
107 117
118 // NotificationObserver implementation.
119 virtual void Observe(int type,
120 const NotificationSource& source,
121 const NotificationDetails& details);
122
108 // Registers (or unregisters) this object as an observer. 123 // Registers (or unregisters) this object as an observer.
109 // When the TabRestoreService object notifies the tab status is changed, this 124 // When the TabRestoreService object notifies the tab status is changed, this
110 // class automatically updates an application JumpList. 125 // class automatically updates an application JumpList.
111 bool AddObserver(Profile* profile); 126 bool AddObserver(Profile* profile);
112 void RemoveObserver(); 127 void RemoveObserver();
113 128
114 // Observer callback for TabRestoreService::Observer to notify when a tab is 129 // Observer callback for TabRestoreService::Observer to notify when a tab is
115 // added or removed. 130 // added or removed.
116 // This function sends a query that retrieves "Most Visited" pages to 131 // This function sends a query that retrieves "Most Visited" pages to
117 // HistoryService. When the query finishes successfully, HistoryService call 132 // HistoryService. When the query finishes successfully, HistoryService call
(...skipping 10 matching lines...) Expand all
128 // * Chromium is lauched without a "--disable-custom-jumplist" option. 143 // * Chromium is lauched without a "--disable-custom-jumplist" option.
129 // TODO(hbono): to be enabled by default when we finalize the categories and 144 // TODO(hbono): to be enabled by default when we finalize the categories and
130 // items of our JumpList. 145 // items of our JumpList.
131 static bool Enabled(); 146 static bool Enabled();
132 147
133 protected: 148 protected:
134 // Creates a ShellLinkItem object from a tab (or a window) and add it to the 149 // Creates a ShellLinkItem object from a tab (or a window) and add it to the
135 // given list. 150 // given list.
136 // These functions are copied from the RecentlyClosedTabsHandler class for 151 // These functions are copied from the RecentlyClosedTabsHandler class for
137 // compatibility with the new-tab page. 152 // compatibility with the new-tab page.
138 bool AddTab(const TabRestoreService::Tab* tab, 153 bool AddTab(const TabRestoreService::Tab* tab, size_t max_items);
139 ShellLinkItemList* list, 154 bool AddWindow(const TabRestoreService::Window* window, size_t max_items);
140 size_t max_items);
141 bool AddWindow(const TabRestoreService::Window* window,
142 ShellLinkItemList* list,
143 size_t max_items);
144 155
145 // Starts loading a favicon for each URL in |icon_urls_|. 156 // Starts loading a favicon for each URL in |icon_urls_|.
146 // This function just sends a query to HistoryService. 157 // This function just sends a query to HistoryService.
147 bool StartLoadingFavicon(); 158 bool StartLoadingFavicon();
148 159
149 // A callback function for HistoryService that notify when the "Most Visited" 160 // A callback function for HistoryService that notify when the "Most Visited"
150 // list is available. 161 // list is available.
151 // This function updates the ShellLinkItemList objects and send another query 162 // This function updates the ShellLinkItemList objects and send another query
152 // that retrieves a favicon for each URL in the list. 163 // that retrieves a favicon for each URL in the list.
153 void OnSegmentUsageAvailable(CancelableRequestProvider::Handle handle, 164 void OnSegmentUsageAvailable(CancelableRequestProvider::Handle handle,
154 std::vector<PageUsageData*>* data); 165 std::vector<PageUsageData*>* data);
155 166
156 // A callback function for HistoryService that notify when a requested favicon 167 // A callback function for HistoryService that notify when a requested favicon
157 // is available. 168 // is available.
158 // To avoid file operations, this function just attaches the given data to 169 // To avoid file operations, this function just attaches the given data to
159 // a ShellLinkItem object. 170 // a ShellLinkItem object.
160 // When finishing loading all favicons, this function posts a task that 171 // When finishing loading all favicons, this function posts a task that
161 // decompresses collected favicons and updates a JumpList. 172 // decompresses collected favicons and updates a JumpList.
162 void OnFaviconDataAvailable(HistoryService::Handle handle, 173 void OnFaviconDataAvailable(HistoryService::Handle handle,
163 history::FaviconData favicon); 174 history::FaviconData favicon);
164 175
176 // 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...
177 // Visited" list is available. This function updates the ShellLinkItemList
178 // objects and send another query that retrieves a favicon for each URL in
179 // the list.
180 void OnMostVisitedURLsAvailable(
181 const history::MostVisitedURLList& data);
182
183 // Runnable method that updates the jumplist, once have all the data
184 // has been fetched.
185 void JumpList::RunUpdate();
186
187 // Helper method for RunUpdate to decode the data about the asynchrounously
188 // loaded icons
189 void DecodeIconData(const ShellLinkItemList& item_list);
190
191 // Send a request to the HistoryService to get the most visited pages.
192 void StartQueryForTopSites();
193
165 private: 194 private:
166 // Our consumers for HistoryService. 195 // Our consumers for HistoryService.
167 CancelableRequestConsumer most_visited_consumer_; 196 CancelableRequestConsumer most_visited_consumer_;
168 CancelableRequestConsumer favicon_consumer_; 197 CancelableRequestConsumer favicon_consumer_;
198 CancelableRequestConsumer topsites_consumer_;
169 199
170 // The Profile object used for listening its events.
171 Profile* profile_; 200 Profile* profile_;
172 201
202 NotificationRegistrar registrar_;
203
173 // App id to associate with the jump list. 204 // App id to associate with the jump list.
174 std::wstring app_id_; 205 std::wstring app_id_;
175 206
176 // The directory which contains JumpList icons. 207 // The directory which contains JumpList icons.
177 FilePath icon_dir_; 208 FilePath icon_dir_;
178 209
179 // Items in the "Most Visited" category of the application JumpList. 210 // Items in the "Most Visited" category of the application JumpList.
180 ShellLinkItemList most_visited_pages_; 211 ShellLinkItemList most_visited_pages_;
181 212
182 // Items in the "Recently Closed" category of the application JumpList. 213 // Items in the "Recently Closed" category of the application JumpList.
183 ShellLinkItemList recently_closed_pages_; 214 ShellLinkItemList recently_closed_pages_;
184 215
185 // A list of URLs we need to retrieve their favicons. 216 // A list of URLs we need to retrieve their favicons.
186 typedef std::pair<std::string, scoped_refptr<ShellLinkItem> > URLPair; 217 typedef std::pair<std::string, scoped_refptr<ShellLinkItem> > URLPair;
187 std::list<URLPair> icon_urls_; 218 std::list<URLPair> icon_urls_;
219
220 // Handle of last favicon request used to cancel if a new request
221 // comes in before the current one returns.
222 FaviconService::Handle handle_;
223
224 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_
225 // 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...
226 base::Lock list_lock_;
188 }; 227 };
189 228
190 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_ 229 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_
OLDNEW
« 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