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()); | 406 DCHECK_LE(1u, favicon_bitmap_results.size()); |
stevenjb
2014/07/25 18:45:19
We early exit above if favicon_bitmap_results.empt
stevenjb
2014/07/25 18:47:31
I *think* (it's been a long time) was that the exp
Daniel Nishi
2014/07/25 21:13:37
Yeah, you're right. I've changed it back to the re
| |
407 favicon_base::FaviconRawBitmapResult bitmap_result = | 407 favicon_base::FaviconRawBitmapResult bitmap_result = |
408 favicon_bitmap_results[0]; | 408 favicon_bitmap_results[0]; |
409 | 409 |
410 // If the desired size is 0, SelectFaviconFrames() will return the largest | 410 // If the desired size is 0, SelectFaviconFrames() will return the largest |
411 // bitmap without doing any resizing. As |favicon_bitmap_results| has bitmap | 411 // bitmap without doing any resizing. As |favicon_bitmap_results| has bitmap |
412 // data for a single bitmap, return it and avoid an unnecessary decode. | 412 // data for a single bitmap, return it and avoid an unnecessary decode. |
413 if (desired_size_in_pixel == 0) { | 413 if (desired_size_in_pixel == 0) { |
414 callback.Run(bitmap_result); | 414 callback.Run(bitmap_result); |
415 return; | 415 return; |
416 } | 416 } |
(...skipping 16 matching lines...) Expand all Loading... | |
433 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, | 433 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, |
434 &resized_bitmap_data)) { | 434 &resized_bitmap_data)) { |
435 callback.Run(favicon_base::FaviconRawBitmapResult()); | 435 callback.Run(favicon_base::FaviconRawBitmapResult()); |
436 return; | 436 return; |
437 } | 437 } |
438 | 438 |
439 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( | 439 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( |
440 &resized_bitmap_data); | 440 &resized_bitmap_data); |
441 callback.Run(bitmap_result); | 441 callback.Run(bitmap_result); |
442 } | 442 } |
OLD | NEW |