| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/favicon/core/favicon_handler.h" | 5 #include "components/favicon/core/favicon_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 service_->GetFavicon( | 469 service_->GetFavicon( |
| 470 icon_url, icon_type, preferred_icon_size(), | 470 icon_url, icon_type, preferred_icon_size(), |
| 471 base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)), | 471 base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)), |
| 472 &cancelable_task_tracker_); | 472 &cancelable_task_tracker_); |
| 473 } else { | 473 } else { |
| 474 // Ask the history service for the icon. This does two things: | 474 // Ask the history service for the icon. This does two things: |
| 475 // 1. Attempts to fetch the favicon data from the database. | 475 // 1. Attempts to fetch the favicon data from the database. |
| 476 // 2. If the favicon exists in the database, this updates the database to | 476 // 2. If the favicon exists in the database, this updates the database to |
| 477 // include the mapping between the page url and the favicon url. | 477 // include the mapping between the page url and the favicon url. |
| 478 // This is asynchronous. The history service will call back when done. | 478 // This is asynchronous. The history service will call back when done. |
| 479 // TODO(pkotwicz): pass in all of |image_urls_| to | |
| 480 // UpdateFaviconMappingsAndFetch(). | |
| 481 service_->UpdateFaviconMappingsAndFetch( | 479 service_->UpdateFaviconMappingsAndFetch( |
| 482 url_, {icon_url}, icon_type, preferred_icon_size(), | 480 url_, icon_url, icon_type, preferred_icon_size(), |
| 483 base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)), | 481 base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)), |
| 484 &cancelable_task_tracker_); | 482 &cancelable_task_tracker_); |
| 485 } | 483 } |
| 486 } | 484 } |
| 487 } | 485 } |
| 488 | 486 |
| 489 void FaviconHandler::OnFaviconData(const std::vector< | 487 void FaviconHandler::OnFaviconData(const std::vector< |
| 490 favicon_base::FaviconRawBitmapResult>& favicon_bitmap_results) { | 488 favicon_base::FaviconRawBitmapResult>& favicon_bitmap_results) { |
| 491 bool has_results = !favicon_bitmap_results.empty(); | 489 bool has_results = !favicon_bitmap_results.empty(); |
| 492 bool has_valid_result = HasValidResult(favicon_bitmap_results); | 490 bool has_valid_result = HasValidResult(favicon_bitmap_results); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 // A max bitmap size is specified to avoid receiving huge bitmaps in | 530 // A max bitmap size is specified to avoid receiving huge bitmaps in |
| 533 // OnDidDownloadFavicon(). See FaviconDriver::StartDownload() | 531 // OnDidDownloadFavicon(). See FaviconDriver::StartDownload() |
| 534 // for more details about the max bitmap size. | 532 // for more details about the max bitmap size. |
| 535 const int download_id = | 533 const int download_id = |
| 536 delegate_->DownloadImage(image_url, GetMaximalIconSize(handler_type_), | 534 delegate_->DownloadImage(image_url, GetMaximalIconSize(handler_type_), |
| 537 download_request_.callback()); | 535 download_request_.callback()); |
| 538 DCHECK_NE(download_id, 0); | 536 DCHECK_NE(download_id, 0); |
| 539 } | 537 } |
| 540 | 538 |
| 541 } // namespace favicon | 539 } // namespace favicon |
| OLD | NEW |