OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_SYNC_GLUE_FAVICON_CACHE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_FAVICON_CACHE_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_FAVICON_CACHE_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_FAVICON_CACHE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/ref_counted_memory.h" | 15 #include "base/memory/ref_counted_memory.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/task/cancelable_task_tracker.h" |
18 #include "chrome/browser/history/history_types.h" | 19 #include "chrome/browser/history/history_types.h" |
19 #include "chrome/browser/sessions/session_id.h" | 20 #include "chrome/browser/sessions/session_id.h" |
20 #include "chrome/common/cancelable_task_tracker.h" | |
21 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
22 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
23 #include "sync/api/sync_change.h" | 23 #include "sync/api/sync_change.h" |
24 #include "sync/api/sync_error_factory.h" | 24 #include "sync/api/sync_error_factory.h" |
25 #include "sync/api/syncable_service.h" | 25 #include "sync/api/syncable_service.h" |
26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
27 | 27 |
28 class Profile; | 28 class Profile; |
29 | 29 |
30 namespace chrome { | 30 namespace chrome { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 bool operator()(const linked_ptr<SyncedFaviconInfo>& lhs, | 110 bool operator()(const linked_ptr<SyncedFaviconInfo>& lhs, |
111 const linked_ptr<SyncedFaviconInfo>& rhs) const; | 111 const linked_ptr<SyncedFaviconInfo>& rhs) const; |
112 }; | 112 }; |
113 | 113 |
114 | 114 |
115 // Map of favicon url to favicon image. | 115 // Map of favicon url to favicon image. |
116 typedef std::map<GURL, linked_ptr<SyncedFaviconInfo> > FaviconMap; | 116 typedef std::map<GURL, linked_ptr<SyncedFaviconInfo> > FaviconMap; |
117 typedef std::set<linked_ptr<SyncedFaviconInfo>, | 117 typedef std::set<linked_ptr<SyncedFaviconInfo>, |
118 FaviconRecencyFunctor> RecencySet; | 118 FaviconRecencyFunctor> RecencySet; |
119 // Map of page url to task id (for favicon loading). | 119 // Map of page url to task id (for favicon loading). |
120 typedef std::map<GURL, CancelableTaskTracker::TaskId> PageTaskMap; | 120 typedef std::map<GURL, base::CancelableTaskTracker::TaskId> PageTaskMap; |
121 // Map of page url to favicon url. | 121 // Map of page url to favicon url. |
122 typedef std::map<GURL, GURL> PageFaviconMap; | 122 typedef std::map<GURL, GURL> PageFaviconMap; |
123 | 123 |
124 // Helper method to perform OnReceivedSyncFavicon work without worrying about | 124 // Helper method to perform OnReceivedSyncFavicon work without worrying about |
125 // whether caller holds a sync transaction. | 125 // whether caller holds a sync transaction. |
126 void OnReceivedSyncFaviconImpl(const GURL& icon_url, | 126 void OnReceivedSyncFaviconImpl(const GURL& icon_url, |
127 const std::string& icon_bytes, | 127 const std::string& icon_bytes, |
128 int64 visit_time_ms); | 128 int64 visit_time_ms); |
129 | 129 |
130 // Callback method to store a tab's favicon into its sync node once it becomes | 130 // Callback method to store a tab's favicon into its sync node once it becomes |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 syncer::SyncChangeList* tracking_changes); | 187 syncer::SyncChangeList* tracking_changes); |
188 | 188 |
189 // Locally drops the favicon pointed to by |favicon_iter|. | 189 // Locally drops the favicon pointed to by |favicon_iter|. |
190 void DropSyncedFavicon(FaviconMap::iterator favicon_iter); | 190 void DropSyncedFavicon(FaviconMap::iterator favicon_iter); |
191 | 191 |
192 // For testing only. | 192 // For testing only. |
193 size_t NumFaviconsForTest() const; | 193 size_t NumFaviconsForTest() const; |
194 size_t NumTasksForTest() const; | 194 size_t NumTasksForTest() const; |
195 | 195 |
196 // Trask tracker for loading favicons. | 196 // Trask tracker for loading favicons. |
197 CancelableTaskTracker cancelable_task_tracker_; | 197 base::CancelableTaskTracker cancelable_task_tracker_; |
198 | 198 |
199 // Our actual cached favicon data. | 199 // Our actual cached favicon data. |
200 FaviconMap synced_favicons_; | 200 FaviconMap synced_favicons_; |
201 | 201 |
202 // An LRU ordering of the favicons comprising |synced_favicons_| (oldest to | 202 // An LRU ordering of the favicons comprising |synced_favicons_| (oldest to |
203 // newest). | 203 // newest). |
204 RecencySet recent_favicons_; | 204 RecencySet recent_favicons_; |
205 | 205 |
206 // Our set of pending favicon loads, indexed by page url. | 206 // Our set of pending favicon loads, indexed by page url. |
207 PageTaskMap page_task_map_; | 207 PageTaskMap page_task_map_; |
(...skipping 17 matching lines...) Expand all Loading... |
225 | 225 |
226 // Weak pointer factory for favicon loads. | 226 // Weak pointer factory for favicon loads. |
227 base::WeakPtrFactory<FaviconCache> weak_ptr_factory_; | 227 base::WeakPtrFactory<FaviconCache> weak_ptr_factory_; |
228 | 228 |
229 DISALLOW_COPY_AND_ASSIGN(FaviconCache); | 229 DISALLOW_COPY_AND_ASSIGN(FaviconCache); |
230 }; | 230 }; |
231 | 231 |
232 } // namespace browser_sync | 232 } // namespace browser_sync |
233 | 233 |
234 #endif // CHROME_BROWSER_SYNC_GLUE_FAVICON_CACHE_H_ | 234 #endif // CHROME_BROWSER_SYNC_GLUE_FAVICON_CACHE_H_ |
OLD | NEW |