| 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 "chrome/browser/sync/glue/favicon_cache.h" | 5 #include "chrome/browser/sync/glue/favicon_cache.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" |
| 7 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 8 #include "chrome/browser/favicon/favicon_service.h" | 9 #include "chrome/browser/favicon/favicon_service.h" |
| 9 #include "chrome/browser/favicon/favicon_service_factory.h" | 10 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 10 #include "chrome/browser/history/history_notifications.h" | 11 #include "chrome/browser/history/history_notifications.h" |
| 11 #include "chrome/browser/history/history_types.h" | 12 #include "chrome/browser/history/history_types.h" |
| 12 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 13 #include "content/public/browser/notification_details.h" | 14 #include "content/public/browser/notification_details.h" |
| 14 #include "content/public/browser/notification_source.h" | 15 #include "content/public/browser/notification_source.h" |
| 15 #include "sync/api/time.h" | 16 #include "sync/api/time.h" |
| 16 #include "sync/protocol/favicon_image_specifics.pb.h" | 17 #include "sync/protocol/favicon_image_specifics.pb.h" |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 SyncedFaviconInfo* favicon_info = GetFaviconInfo(icon_url); | 478 SyncedFaviconInfo* favicon_info = GetFaviconInfo(icon_url); |
| 478 if (!favicon_info) | 479 if (!favicon_info) |
| 479 return; // We reached the in-memory limit. | 480 return; // We reached the in-memory limit. |
| 480 base::RefCountedString* temp_string = new base::RefCountedString(); | 481 base::RefCountedString* temp_string = new base::RefCountedString(); |
| 481 temp_string->data() = icon_bytes; | 482 temp_string->data() = icon_bytes; |
| 482 favicon_info->bitmap_data[SIZE_16].bitmap_data = temp_string; | 483 favicon_info->bitmap_data[SIZE_16].bitmap_data = temp_string; |
| 483 // We assume legacy favicons are 16x16. | 484 // We assume legacy favicons are 16x16. |
| 484 favicon_info->bitmap_data[SIZE_16].pixel_size.set_width(16); | 485 favicon_info->bitmap_data[SIZE_16].pixel_size.set_width(16); |
| 485 favicon_info->bitmap_data[SIZE_16].pixel_size.set_height(16); | 486 favicon_info->bitmap_data[SIZE_16].pixel_size.set_height(16); |
| 486 UpdateFaviconVisitTime(icon_url, syncer::ProtoTimeToTime(visit_time_ms)); | 487 UpdateFaviconVisitTime(icon_url, syncer::ProtoTimeToTime(visit_time_ms)); |
| 487 UpdateSyncState(icon_url, SYNC_BOTH, syncer::SyncChange::ACTION_ADD); | 488 |
| 489 // Post a task, as this can be called while still in a transaction. |
| 490 MessageLoop::current()->PostTask( |
| 491 FROM_HERE, |
| 492 base::Bind(&FaviconCache::UpdateSyncState, |
| 493 weak_ptr_factory_.GetWeakPtr(), |
| 494 icon_url, |
| 495 SYNC_BOTH, |
| 496 syncer::SyncChange::ACTION_ADD)); |
| 488 } | 497 } |
| 489 | 498 |
| 490 void FaviconCache::SetLegacyDelegate(FaviconCacheObserver* observer) { | 499 void FaviconCache::SetLegacyDelegate(FaviconCacheObserver* observer) { |
| 491 legacy_delegate_ = observer; | 500 legacy_delegate_ = observer; |
| 492 } | 501 } |
| 493 | 502 |
| 494 void FaviconCache::RemoveLegacyDelegate() { | 503 void FaviconCache::RemoveLegacyDelegate() { |
| 495 legacy_delegate_ = NULL; | 504 legacy_delegate_ = NULL; |
| 496 } | 505 } |
| 497 | 506 |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 | 920 |
| 912 size_t FaviconCache::NumFaviconsForTest() const { | 921 size_t FaviconCache::NumFaviconsForTest() const { |
| 913 return synced_favicons_.size(); | 922 return synced_favicons_.size(); |
| 914 } | 923 } |
| 915 | 924 |
| 916 size_t FaviconCache::NumTasksForTest() const { | 925 size_t FaviconCache::NumTasksForTest() const { |
| 917 return page_task_map_.size(); | 926 return page_task_map_.size(); |
| 918 } | 927 } |
| 919 | 928 |
| 920 } // namespace browser_sync | 929 } // namespace browser_sync |
| OLD | NEW |