| 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/message_loop/message_loop.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/favicon/favicon_service.h" | 10 #include "chrome/browser/favicon/favicon_service.h" |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 page_task_map_[page_url] = 0; // For testing only. | 460 page_task_map_[page_url] = 0; // For testing only. |
| 461 return; | 461 return; |
| 462 } | 462 } |
| 463 FaviconService* favicon_service = | 463 FaviconService* favicon_service = |
| 464 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 464 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 465 if (!favicon_service) | 465 if (!favicon_service) |
| 466 return; | 466 return; |
| 467 // TODO(zea): This appears to only fetch one favicon (best match based on | 467 // TODO(zea): This appears to only fetch one favicon (best match based on |
| 468 // desired_size_in_dip). Figure out a way to fetch all favicons we support. | 468 // desired_size_in_dip). Figure out a way to fetch all favicons we support. |
| 469 // See crbug.com/181068. | 469 // See crbug.com/181068. |
| 470 CancelableTaskTracker::TaskId id = favicon_service->GetFaviconForURL( | 470 base::CancelableTaskTracker::TaskId id = favicon_service->GetFaviconForURL( |
| 471 FaviconService::FaviconForURLParams(page_url, SupportedFaviconTypes(), | 471 FaviconService::FaviconForURLParams( |
| 472 kMaxFaviconResolution), | 472 page_url, SupportedFaviconTypes(), kMaxFaviconResolution), |
| 473 base::Bind(&FaviconCache::OnFaviconDataAvailable, | 473 base::Bind(&FaviconCache::OnFaviconDataAvailable, |
| 474 weak_ptr_factory_.GetWeakPtr(), page_url), | 474 weak_ptr_factory_.GetWeakPtr(), |
| 475 page_url), |
| 475 &cancelable_task_tracker_); | 476 &cancelable_task_tracker_); |
| 476 page_task_map_[page_url] = id; | 477 page_task_map_[page_url] = id; |
| 477 } | 478 } |
| 478 | 479 |
| 479 void FaviconCache::OnFaviconVisited(const GURL& page_url, | 480 void FaviconCache::OnFaviconVisited(const GURL& page_url, |
| 480 const GURL& favicon_url) { | 481 const GURL& favicon_url) { |
| 481 DCHECK(page_url.is_valid()); | 482 DCHECK(page_url.is_valid()); |
| 482 if (!favicon_url.is_valid() || | 483 if (!favicon_url.is_valid() || |
| 483 synced_favicons_.find(favicon_url) == synced_favicons_.end()) { | 484 synced_favicons_.find(favicon_url) == synced_favicons_.end()) { |
| 484 // TODO(zea): consider triggering a favicon load if we have some but not | 485 // TODO(zea): consider triggering a favicon load if we have some but not |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 | 1035 |
| 1035 size_t FaviconCache::NumFaviconsForTest() const { | 1036 size_t FaviconCache::NumFaviconsForTest() const { |
| 1036 return synced_favicons_.size(); | 1037 return synced_favicons_.size(); |
| 1037 } | 1038 } |
| 1038 | 1039 |
| 1039 size_t FaviconCache::NumTasksForTest() const { | 1040 size_t FaviconCache::NumTasksForTest() const { |
| 1040 return page_task_map_.size(); | 1041 return page_task_map_.size(); |
| 1041 } | 1042 } |
| 1042 | 1043 |
| 1043 } // namespace browser_sync | 1044 } // namespace browser_sync |
| OLD | NEW |