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 "chrome/browser/favicon/favicon_service.h" | 5 #include "chrome/browser/favicon/favicon_service.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/hash.h" | 9 #include "base/hash.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 void FaviconService::RunFaviconRawBitmapCallbackWithBitmapResults( | 396 void FaviconService::RunFaviconRawBitmapCallbackWithBitmapResults( |
397 const favicon_base::FaviconRawBitmapCallback& callback, | 397 const favicon_base::FaviconRawBitmapCallback& callback, |
398 int desired_size_in_pixel, | 398 int desired_size_in_pixel, |
399 const std::vector<favicon_base::FaviconRawBitmapResult>& | 399 const std::vector<favicon_base::FaviconRawBitmapResult>& |
400 favicon_bitmap_results) { | 400 favicon_bitmap_results) { |
401 if (favicon_bitmap_results.empty() || !favicon_bitmap_results[0].is_valid()) { | 401 if (favicon_bitmap_results.empty() || !favicon_bitmap_results[0].is_valid()) { |
402 callback.Run(favicon_base::FaviconRawBitmapResult()); | 402 callback.Run(favicon_base::FaviconRawBitmapResult()); |
403 return; | 403 return; |
404 } | 404 } |
405 | 405 |
406 DCHECK_EQ(1u, favicon_bitmap_results.size()); | |
407 favicon_base::FaviconRawBitmapResult bitmap_result = | 406 favicon_base::FaviconRawBitmapResult bitmap_result = |
408 favicon_bitmap_results[0]; | 407 favicon_bitmap_results[0]; |
409 | 408 |
410 // If the desired size is 0, SelectFaviconFrames() will return the largest | 409 // If the desired size is 0, SelectFaviconFrames() will return the largest |
411 // bitmap without doing any resizing. As |favicon_bitmap_results| has bitmap | 410 // bitmap without doing any resizing. As |favicon_bitmap_results| has bitmap |
412 // data for a single bitmap, return it and avoid an unnecessary decode. | 411 // data for a single bitmap, return it and avoid an unnecessary decode. |
413 if (desired_size_in_pixel == 0) { | 412 if (desired_size_in_pixel == 0) { |
414 callback.Run(bitmap_result); | 413 callback.Run(bitmap_result); |
415 return; | 414 return; |
416 } | 415 } |
(...skipping 16 matching lines...) Expand all Loading... |
433 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, | 432 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, |
434 &resized_bitmap_data)) { | 433 &resized_bitmap_data)) { |
435 callback.Run(favicon_base::FaviconRawBitmapResult()); | 434 callback.Run(favicon_base::FaviconRawBitmapResult()); |
436 return; | 435 return; |
437 } | 436 } |
438 | 437 |
439 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( | 438 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( |
440 &resized_bitmap_data); | 439 &resized_bitmap_data); |
441 callback.Run(bitmap_result); | 440 callback.Run(bitmap_result); |
442 } | 441 } |
OLD | NEW |