| 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/message_loop.h" | 7 #include "base/location.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" |
| 9 #include "chrome/browser/favicon/favicon_service_factory.h" | 11 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 10 #include "chrome/browser/history/history_service_factory.h" | 12 #include "chrome/browser/history/history_service_factory.h" |
| 11 #include "components/favicon/core/favicon_service.h" | 13 #include "components/favicon/core/favicon_service.h" |
| 12 #include "components/history/core/browser/history_service.h" | 14 #include "components/history/core/browser/history_service.h" |
| 13 #include "components/history/core/browser/history_types.h" | 15 #include "components/history/core/browser/history_types.h" |
| 14 #include "sync/api/time.h" | 16 #include "sync/api/time.h" |
| 15 #include "sync/protocol/favicon_image_specifics.pb.h" | 17 #include "sync/protocol/favicon_image_specifics.pb.h" |
| 16 #include "sync/protocol/favicon_tracking_specifics.pb.h" | 18 #include "sync/protocol/favicon_tracking_specifics.pb.h" |
| 17 #include "sync/protocol/sync.pb.h" | 19 #include "sync/protocol/sync.pb.h" |
| 18 #include "ui/gfx/favicon_size.h" | 20 #include "ui/gfx/favicon_size.h" |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 page_favicon_map_[page_url] = icon_url; | 528 page_favicon_map_[page_url] = icon_url; |
| 527 | 529 |
| 528 // If there is no actual image, it means there either is no synced | 530 // If there is no actual image, it means there either is no synced |
| 529 // favicon, or it's on its way (race condition). | 531 // favicon, or it's on its way (race condition). |
| 530 // TODO(zea): potentially trigger a favicon web download here (delayed?). | 532 // TODO(zea): potentially trigger a favicon web download here (delayed?). |
| 531 if (icon_bytes.size() == 0) | 533 if (icon_bytes.size() == 0) |
| 532 return; | 534 return; |
| 533 | 535 |
| 534 // Post a task to do the actual association because this method may have been | 536 // Post a task to do the actual association because this method may have been |
| 535 // called while in a transaction. | 537 // called while in a transaction. |
| 536 base::MessageLoop::current()->PostTask( | 538 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 537 FROM_HERE, | 539 FROM_HERE, base::Bind(&FaviconCache::OnReceivedSyncFaviconImpl, |
| 538 base::Bind(&FaviconCache::OnReceivedSyncFaviconImpl, | 540 weak_ptr_factory_.GetWeakPtr(), icon_url, |
| 539 weak_ptr_factory_.GetWeakPtr(), | 541 icon_bytes, visit_time_ms)); |
| 540 icon_url, | |
| 541 icon_bytes, | |
| 542 visit_time_ms)); | |
| 543 } | 542 } |
| 544 | 543 |
| 545 void FaviconCache::OnReceivedSyncFaviconImpl( | 544 void FaviconCache::OnReceivedSyncFaviconImpl( |
| 546 const GURL& icon_url, | 545 const GURL& icon_url, |
| 547 const std::string& icon_bytes, | 546 const std::string& icon_bytes, |
| 548 int64 visit_time_ms) { | 547 int64 visit_time_ms) { |
| 549 // If this favicon is already synced, do nothing else. | 548 // If this favicon is already synced, do nothing else. |
| 550 if (synced_favicons_.find(icon_url) != synced_favicons_.end()) | 549 if (synced_favicons_.find(icon_url) != synced_favicons_.end()) |
| 551 return; | 550 return; |
| 552 | 551 |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 favicon_images_sync_processor_->ProcessSyncChanges(FROM_HERE, | 1059 favicon_images_sync_processor_->ProcessSyncChanges(FROM_HERE, |
| 1061 image_deletions); | 1060 image_deletions); |
| 1062 } | 1061 } |
| 1063 if (favicon_tracking_sync_processor_.get()) { | 1062 if (favicon_tracking_sync_processor_.get()) { |
| 1064 favicon_tracking_sync_processor_->ProcessSyncChanges(FROM_HERE, | 1063 favicon_tracking_sync_processor_->ProcessSyncChanges(FROM_HERE, |
| 1065 tracking_deletions); | 1064 tracking_deletions); |
| 1066 } | 1065 } |
| 1067 } | 1066 } |
| 1068 | 1067 |
| 1069 } // namespace browser_sync | 1068 } // namespace browser_sync |
| OLD | NEW |