OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "components/sync_sessions/favicon_cache.h" | 5 #include "components/sync_sessions/favicon_cache.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 merge_result.set_num_items_added(merge_result.num_items_added() + 1); | 273 merge_result.set_num_items_added(merge_result.num_items_added() + 1); |
274 } | 274 } |
275 } | 275 } |
276 | 276 |
277 // Rather than trigger a bunch of deletions when we set up sync, we drop | 277 // Rather than trigger a bunch of deletions when we set up sync, we drop |
278 // local favicons. Those pages that are currently open are likely to result in | 278 // local favicons. Those pages that are currently open are likely to result in |
279 // loading new favicons/refreshing old favicons anyways, at which point | 279 // loading new favicons/refreshing old favicons anyways, at which point |
280 // they'll be re-added and the appropriate synced favicons will be evicted. | 280 // they'll be re-added and the appropriate synced favicons will be evicted. |
281 // TODO(zea): implement a smarter ordering of the which favicons to drop. | 281 // TODO(zea): implement a smarter ordering of the which favicons to drop. |
282 int available_favicons = max_sync_favicon_limit_ - initial_sync_data.size(); | 282 int available_favicons = max_sync_favicon_limit_ - initial_sync_data.size(); |
283 UMA_HISTOGRAM_BOOLEAN("Sync.FaviconsAvailableAtMerge", | |
284 available_favicons > 0); | |
285 for (std::set<GURL>::const_iterator iter = unsynced_favicon_urls.begin(); | 283 for (std::set<GURL>::const_iterator iter = unsynced_favicon_urls.begin(); |
286 iter != unsynced_favicon_urls.end(); ++iter) { | 284 iter != unsynced_favicon_urls.end(); ++iter) { |
287 if (available_favicons > 0) { | 285 if (available_favicons > 0) { |
288 local_changes.push_back( | 286 local_changes.push_back( |
289 syncer::SyncChange(FROM_HERE, | 287 syncer::SyncChange(FROM_HERE, |
290 syncer::SyncChange::ACTION_ADD, | 288 syncer::SyncChange::ACTION_ADD, |
291 CreateSyncDataFromLocalFavicon(type, *iter))); | 289 CreateSyncDataFromLocalFavicon(type, *iter))); |
292 available_favicons--; | 290 available_favicons--; |
293 } else { | 291 } else { |
294 FaviconMap::iterator favicon_iter = synced_favicons_.find(*iter); | 292 FaviconMap::iterator favicon_iter = synced_favicons_.find(*iter); |
295 DVLOG(1) << "Dropping local favicon " | 293 DVLOG(1) << "Dropping local favicon " |
296 << favicon_iter->second->favicon_url.spec(); | 294 << favicon_iter->second->favicon_url.spec(); |
297 DropPartialFavicon(favicon_iter, type); | 295 DropPartialFavicon(favicon_iter, type); |
298 merge_result.set_num_items_deleted(merge_result.num_items_deleted() + 1); | 296 merge_result.set_num_items_deleted(merge_result.num_items_deleted() + 1); |
299 } | 297 } |
300 } | 298 } |
301 UMA_HISTOGRAM_COUNTS_10000("Sync.FaviconCount", synced_favicons_.size()); | |
302 merge_result.set_num_items_after_association(synced_favicons_.size()); | 299 merge_result.set_num_items_after_association(synced_favicons_.size()); |
303 | 300 |
304 if (type == syncer::FAVICON_IMAGES) { | 301 if (type == syncer::FAVICON_IMAGES) { |
305 favicon_images_sync_processor_->ProcessSyncChanges(FROM_HERE, | 302 favicon_images_sync_processor_->ProcessSyncChanges(FROM_HERE, |
306 local_changes); | 303 local_changes); |
307 } else { | 304 } else { |
308 favicon_tracking_sync_processor_->ProcessSyncChanges(FROM_HERE, | 305 favicon_tracking_sync_processor_->ProcessSyncChanges(FROM_HERE, |
309 local_changes); | 306 local_changes); |
310 } | 307 } |
311 return merge_result; | 308 return merge_result; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 | 611 |
615 for (std::map<GURL, LocalFaviconUpdateInfo>::const_iterator | 612 for (std::map<GURL, LocalFaviconUpdateInfo>::const_iterator |
616 iter = favicon_updates.begin(); iter != favicon_updates.end(); | 613 iter = favicon_updates.begin(); iter != favicon_updates.end(); |
617 ++iter) { | 614 ++iter) { |
618 SyncedFaviconInfo* favicon_info = iter->second.favicon_info; | 615 SyncedFaviconInfo* favicon_info = iter->second.favicon_info; |
619 const GURL& favicon_url = favicon_info->favicon_url; | 616 const GURL& favicon_url = favicon_info->favicon_url; |
620 | 617 |
621 // TODO(zea): support multiple favicon urls per page. | 618 // TODO(zea): support multiple favicon urls per page. |
622 page_favicon_map_[page_url] = favicon_url; | 619 page_favicon_map_[page_url] = favicon_url; |
623 | 620 |
624 if (!favicon_info->last_visit_time.is_null()) { | |
625 UMA_HISTOGRAM_COUNTS_10000( | |
626 "Sync.FaviconVisitPeriod", | |
627 (now - favicon_info->last_visit_time).InHours()); | |
628 } | |
629 favicon_info->received_local_update = true; | 621 favicon_info->received_local_update = true; |
630 UpdateFaviconVisitTime(favicon_url, now); | 622 UpdateFaviconVisitTime(favicon_url, now); |
631 | 623 |
632 syncer::SyncChange::SyncChangeType image_change = | 624 syncer::SyncChange::SyncChangeType image_change = |
633 syncer::SyncChange::ACTION_INVALID; | 625 syncer::SyncChange::ACTION_INVALID; |
634 if (iter->second.new_image) | 626 if (iter->second.new_image) |
635 image_change = syncer::SyncChange::ACTION_ADD; | 627 image_change = syncer::SyncChange::ACTION_ADD; |
636 else if (iter->second.image_needs_rewrite) | 628 else if (iter->second.image_needs_rewrite) |
637 image_change = syncer::SyncChange::ACTION_UPDATE; | 629 image_change = syncer::SyncChange::ACTION_UPDATE; |
638 syncer::SyncChange::SyncChangeType tracking_change = | 630 syncer::SyncChange::SyncChangeType tracking_change = |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 favicon_images_sync_processor_->ProcessSyncChanges(FROM_HERE, | 1041 favicon_images_sync_processor_->ProcessSyncChanges(FROM_HERE, |
1050 image_deletions); | 1042 image_deletions); |
1051 } | 1043 } |
1052 if (favicon_tracking_sync_processor_.get()) { | 1044 if (favicon_tracking_sync_processor_.get()) { |
1053 favicon_tracking_sync_processor_->ProcessSyncChanges(FROM_HERE, | 1045 favicon_tracking_sync_processor_->ProcessSyncChanges(FROM_HERE, |
1054 tracking_deletions); | 1046 tracking_deletions); |
1055 } | 1047 } |
1056 } | 1048 } |
1057 | 1049 |
1058 } // namespace browser_sync | 1050 } // namespace browser_sync |
OLD | NEW |