| 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_WIN_JUMPLIST_H_ | 5 #ifndef CHROME_BROWSER_WIN_JUMPLIST_H_ |
| 6 #define CHROME_BROWSER_WIN_JUMPLIST_H_ | 6 #define CHROME_BROWSER_WIN_JUMPLIST_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 | 14 |
| 15 #include "base/containers/flat_map.h" | 15 #include "base/containers/flat_map.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/sequence_checker.h" |
| 20 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
| 21 #include "base/synchronization/lock.h" | 22 #include "base/synchronization/lock.h" |
| 22 #include "base/task/cancelable_task_tracker.h" | 23 #include "base/task/cancelable_task_tracker.h" |
| 23 #include "base/timer/timer.h" | 24 #include "base/timer/timer.h" |
| 24 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 25 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 25 #include "chrome/browser/win/jumplist_updater.h" | 26 #include "chrome/browser/win/jumplist_updater.h" |
| 26 #include "components/history/core/browser/history_service.h" | 27 #include "components/history/core/browser/history_service.h" |
| 27 #include "components/history/core/browser/history_types.h" | 28 #include "components/history/core/browser/history_types.h" |
| 28 #include "components/history/core/browser/top_sites_observer.h" | 29 #include "components/history/core/browser/top_sites_observer.h" |
| 29 #include "components/keyed_service/core/refcounted_keyed_service.h" | 30 #include "components/keyed_service/core/refcounted_keyed_service.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 57 // the JumpList whenever a change is detected. | 58 // the JumpList whenever a change is detected. |
| 58 // | 59 // |
| 59 // Updating a JumpList requires some file operations and it is not good to | 60 // Updating a JumpList requires some file operations and it is not good to |
| 60 // update it in a UI thread. To solve this problem, this class posts to a | 61 // update it in a UI thread. To solve this problem, this class posts to a |
| 61 // runnable method when it actually updates a JumpList. | 62 // runnable method when it actually updates a JumpList. |
| 62 // | 63 // |
| 63 // Note. base::CancelableTaskTracker is not thread safe, so we | 64 // Note. base::CancelableTaskTracker is not thread safe, so we |
| 64 // always delete JumpList on UI thread (the same thread it got constructed on). | 65 // always delete JumpList on UI thread (the same thread it got constructed on). |
| 65 class JumpList : public sessions::TabRestoreServiceObserver, | 66 class JumpList : public sessions::TabRestoreServiceObserver, |
| 66 public history::TopSitesObserver, | 67 public history::TopSitesObserver, |
| 67 public RefcountedKeyedService, | 68 public RefcountedKeyedService { |
| 68 public base::NonThreadSafe { | |
| 69 public: | 69 public: |
| 70 struct JumpListData { | 70 struct JumpListData { |
| 71 JumpListData(); | 71 JumpListData(); |
| 72 ~JumpListData(); | 72 ~JumpListData(); |
| 73 | 73 |
| 74 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_ | 74 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_ |
| 75 // as they may be used by up to 2 threads. | 75 // as they may be used by up to 2 threads. |
| 76 base::Lock list_lock_; | 76 base::Lock list_lock_; |
| 77 | 77 |
| 78 // A list of URLs we need to retrieve their favicons, | 78 // A list of URLs we need to retrieve their favicons, |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // comes in before it finishes. | 265 // comes in before it finishes. |
| 266 base::CancelableTaskTracker::TaskId task_id_; | 266 base::CancelableTaskTracker::TaskId task_id_; |
| 267 | 267 |
| 268 // A task runner running tasks to update the JumpList. | 268 // A task runner running tasks to update the JumpList. |
| 269 scoped_refptr<base::SingleThreadTaskRunner> update_jumplist_task_runner_; | 269 scoped_refptr<base::SingleThreadTaskRunner> update_jumplist_task_runner_; |
| 270 | 270 |
| 271 // A task runner running tasks to delete JumpListIcons directory and | 271 // A task runner running tasks to delete JumpListIcons directory and |
| 272 // JumpListIconsOld directory. | 272 // JumpListIconsOld directory. |
| 273 scoped_refptr<base::SequencedTaskRunner> delete_jumplisticons_task_runner_; | 273 scoped_refptr<base::SequencedTaskRunner> delete_jumplisticons_task_runner_; |
| 274 | 274 |
| 275 SEQUENCE_CHECKER(sequence_checker_); |
| 276 |
| 275 // For callbacks may be run after destruction. | 277 // For callbacks may be run after destruction. |
| 276 base::WeakPtrFactory<JumpList> weak_ptr_factory_; | 278 base::WeakPtrFactory<JumpList> weak_ptr_factory_; |
| 277 | 279 |
| 278 DISALLOW_COPY_AND_ASSIGN(JumpList); | 280 DISALLOW_COPY_AND_ASSIGN(JumpList); |
| 279 }; | 281 }; |
| 280 | 282 |
| 281 #endif // CHROME_BROWSER_WIN_JUMPLIST_H_ | 283 #endif // CHROME_BROWSER_WIN_JUMPLIST_H_ |
| OLD | NEW |