| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "base/task/cancelable_task_tracker.h" | 16 #include "base/task/cancelable_task_tracker.h" |
| 17 #include "base/timer/timer.h" |
| 17 #include "chrome/browser/jumplist_updater_win.h" | 18 #include "chrome/browser/jumplist_updater_win.h" |
| 18 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 19 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 19 #include "chrome/browser/sessions/tab_restore_service.h" | 20 #include "chrome/browser/sessions/tab_restore_service.h" |
| 20 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 21 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 21 #include "components/history/core/browser/history_service.h" | 22 #include "components/history/core/browser/history_service.h" |
| 22 #include "components/history/core/browser/history_types.h" | 23 #include "components/history/core/browser/history_types.h" |
| 23 #include "components/history/core/browser/top_sites_observer.h" | 24 #include "components/history/core/browser/top_sites_observer.h" |
| 24 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/notification_observer.h" | 26 #include "content/public/browser/notification_observer.h" |
| 26 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // the list. | 119 // the list. |
| 119 void OnMostVisitedURLsAvailable( | 120 void OnMostVisitedURLsAvailable( |
| 120 const history::MostVisitedURLList& data); | 121 const history::MostVisitedURLList& data); |
| 121 | 122 |
| 122 // Callback for changes to the incognito mode availability pref. | 123 // Callback for changes to the incognito mode availability pref. |
| 123 void OnIncognitoAvailabilityChanged(); | 124 void OnIncognitoAvailabilityChanged(); |
| 124 | 125 |
| 125 // Helper for RunUpdate() that determines its parameters. | 126 // Helper for RunUpdate() that determines its parameters. |
| 126 void PostRunUpdate(); | 127 void PostRunUpdate(); |
| 127 | 128 |
| 129 // Called on a timer to invoke RunUpdateOnFileThread() after requests storms |
| 130 // have subsided. |
| 131 void DeferredRunUpdate(); |
| 132 |
| 128 // Runnable method that updates the jumplist, once all the data | 133 // Runnable method that updates the jumplist, once all the data |
| 129 // has been fetched. | 134 // has been fetched. |
| 130 void RunUpdateOnFileThread( | 135 void RunUpdateOnFileThread( |
| 131 IncognitoModePrefs::Availability incognito_availability); | 136 IncognitoModePrefs::Availability incognito_availability); |
| 132 | 137 |
| 133 // Helper method for RunUpdate to create icon files for the asynchrounously | 138 // Helper method for RunUpdate to create icon files for the asynchrounously |
| 134 // loaded icons. | 139 // loaded icons. |
| 135 void CreateIconFiles(const ShellLinkItemList& item_list); | 140 void CreateIconFiles(const ShellLinkItemList& item_list); |
| 136 | 141 |
| 137 // history::TopSitesObserver implementation. | 142 // history::TopSitesObserver implementation. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 155 base::FilePath icon_dir_; | 160 base::FilePath icon_dir_; |
| 156 | 161 |
| 157 // Items in the "Most Visited" category of the application JumpList, | 162 // Items in the "Most Visited" category of the application JumpList, |
| 158 // protected by the list_lock_. | 163 // protected by the list_lock_. |
| 159 ShellLinkItemList most_visited_pages_; | 164 ShellLinkItemList most_visited_pages_; |
| 160 | 165 |
| 161 // Items in the "Recently Closed" category of the application JumpList, | 166 // Items in the "Recently Closed" category of the application JumpList, |
| 162 // protected by the list_lock_. | 167 // protected by the list_lock_. |
| 163 ShellLinkItemList recently_closed_pages_; | 168 ShellLinkItemList recently_closed_pages_; |
| 164 | 169 |
| 170 // Timer for requesting delayed updates of the jumplist. |
| 171 base::OneShotTimer<JumpList> timer_; |
| 172 |
| 165 // A list of URLs we need to retrieve their favicons, | 173 // A list of URLs we need to retrieve their favicons, |
| 166 // protected by the list_lock_. | 174 // protected by the list_lock_. |
| 167 typedef std::pair<std::string, scoped_refptr<ShellLinkItem> > URLPair; | 175 typedef std::pair<std::string, scoped_refptr<ShellLinkItem> > URLPair; |
| 168 std::list<URLPair> icon_urls_; | 176 std::list<URLPair> icon_urls_; |
| 169 | 177 |
| 170 // Id of last favicon task. It's used to cancel current task if a new one | 178 // Id of last favicon task. It's used to cancel current task if a new one |
| 171 // comes in before it finishes. | 179 // comes in before it finishes. |
| 172 base::CancelableTaskTracker::TaskId task_id_; | 180 base::CancelableTaskTracker::TaskId task_id_; |
| 173 | 181 |
| 174 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_ | 182 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_ |
| 175 // as they may be used by up to 3 threads. | 183 // as they may be used by up to 3 threads. |
| 176 base::Lock list_lock_; | 184 base::Lock list_lock_; |
| 177 | 185 |
| 178 // For callbacks may be run after destruction. | 186 // For callbacks may be run after destruction. |
| 179 base::WeakPtrFactory<JumpList> weak_ptr_factory_; | 187 base::WeakPtrFactory<JumpList> weak_ptr_factory_; |
| 180 | 188 |
| 181 DISALLOW_COPY_AND_ASSIGN(JumpList); | 189 DISALLOW_COPY_AND_ASSIGN(JumpList); |
| 182 }; | 190 }; |
| 183 | 191 |
| 184 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_ | 192 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_ |
| OLD | NEW |