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 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 | 127 |
128 // Map of favicon url to favicon image. | 128 // Map of favicon url to favicon image. |
129 typedef std::map<GURL, linked_ptr<SyncedFaviconInfo> > FaviconMap; | 129 typedef std::map<GURL, linked_ptr<SyncedFaviconInfo> > FaviconMap; |
130 typedef std::set<linked_ptr<SyncedFaviconInfo>, | 130 typedef std::set<linked_ptr<SyncedFaviconInfo>, |
131 FaviconRecencyFunctor> RecencySet; | 131 FaviconRecencyFunctor> RecencySet; |
132 // Map of page url to task id (for favicon loading). | 132 // Map of page url to task id (for favicon loading). |
133 typedef std::map<GURL, CancelableTaskTracker::TaskId> PageTaskMap; | 133 typedef std::map<GURL, CancelableTaskTracker::TaskId> PageTaskMap; |
134 // Map of page url to favicon url. | 134 // Map of page url to favicon url. |
135 typedef std::map<GURL, GURL> PageFaviconMap; | 135 typedef std::map<GURL, GURL> PageFaviconMap; |
136 | 136 |
137 // Enum used to decide which sync datatypes to update on a favicon change. | |
138 enum SyncState { | |
139 SYNC_IMAGE, | |
140 SYNC_TRACKING, | |
141 SYNC_BOTH | |
142 }; | |
143 | |
144 // Helper method to perform OnReceivedSyncFavicon work without worrying about | 137 // Helper method to perform OnReceivedSyncFavicon work without worrying about |
145 // whether caller holds a sync transaction. | 138 // whether caller holds a sync transaction. |
146 void OnReceivedSyncFaviconImpl(const GURL& icon_url, | 139 void OnReceivedSyncFaviconImpl(const GURL& icon_url, |
147 const std::string& icon_bytes, | 140 const std::string& icon_bytes, |
148 int64 visit_time_ms); | 141 int64 visit_time_ms); |
149 | 142 |
150 // Callback method to store a tab's favicon into its sync node once it becomes | 143 // Callback method to store a tab's favicon into its sync node once it becomes |
151 // available. Does nothing if no favicon data was available. | 144 // available. Does nothing if no favicon data was available. |
152 void OnFaviconDataAvailable( | 145 void OnFaviconDataAvailable( |
153 const GURL& page_url, | 146 const GURL& page_url, |
154 const std::vector<history::FaviconBitmapResult>& bitmap_result); | 147 const std::vector<history::FaviconBitmapResult>& bitmap_result); |
155 | 148 |
156 // Helper method to update the sync state of the favicon at |icon_url|. | 149 // Helper method to update the sync state of the favicon at |icon_url|. If |
150 // either |image_change_type| or |tracking_change_type| is ACITON_INVALID, | |
rlarocque
2013/04/04 23:29:07
typo: ACTION_INVALID.
Nicolas Zea
2013/04/04 23:42:29
Done.
| |
151 // the corresponding datatype won't be updated. | |
157 // Note: should only be called after both FAVICON_IMAGES and FAVICON_TRACKING | 152 // Note: should only be called after both FAVICON_IMAGES and FAVICON_TRACKING |
158 // have been successfully set up. | 153 // have been successfully set up. |
159 void UpdateSyncState(const GURL& icon_url, | 154 void UpdateSyncState(const GURL& icon_url, |
160 SyncState state_to_update, | 155 syncer::SyncChange::SyncChangeType image_change_type, |
161 syncer::SyncChange::SyncChangeType change_type); | 156 syncer::SyncChange::SyncChangeType tracking_change_type); |
162 | 157 |
163 // Helper method to get favicon info from |synced_favicons_|. If no info | 158 // Helper method to get favicon info from |synced_favicons_|. If no info |
164 // exists for |icon_url|, creates a new SyncedFaviconInfo in both | 159 // exists for |icon_url|, creates a new SyncedFaviconInfo in both |
165 // |synced_favicons_| and |recent_favicons_| and returns it. | 160 // |synced_favicons_| and |recent_favicons_| and returns it. |
166 SyncedFaviconInfo* GetFaviconInfo(const GURL& icon_url); | 161 SyncedFaviconInfo* GetFaviconInfo(const GURL& icon_url); |
167 | 162 |
168 // Updates the last visit time for the favicon at |icon_url| to |time| (and | 163 // Updates the last visit time for the favicon at |icon_url| to |time| (and |
169 // correspondly updates position in |recent_favicons_|. | 164 // correspondly updates position in |recent_favicons_|. |
170 void UpdateFaviconVisitTime(const GURL& icon_url, base::Time time); | 165 void UpdateFaviconVisitTime(const GURL& icon_url, base::Time time); |
171 | 166 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 | 244 |
250 // Maximum number of favicons to sync. 0 means no limit. | 245 // Maximum number of favicons to sync. 0 means no limit. |
251 const size_t max_sync_favicon_limit_; | 246 const size_t max_sync_favicon_limit_; |
252 | 247 |
253 DISALLOW_COPY_AND_ASSIGN(FaviconCache); | 248 DISALLOW_COPY_AND_ASSIGN(FaviconCache); |
254 }; | 249 }; |
255 | 250 |
256 } // namespace browser_sync | 251 } // namespace browser_sync |
257 | 252 |
258 #endif // CHROME_BROWSER_SYNC_GLUE_FAVICON_CACHE_H_ | 253 #endif // CHROME_BROWSER_SYNC_GLUE_FAVICON_CACHE_H_ |
OLD | NEW |