OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/history/top_sites.h" | 5 #include "chrome/browser/history/top_sites.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 std::vector<unsigned char> data; | 598 std::vector<unsigned char> data; |
599 if (!gfx::JPEGCodec::Encode( | 599 if (!gfx::JPEGCodec::Encode( |
600 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), | 600 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), |
601 gfx::JPEGCodec::FORMAT_BGRA, bitmap.width(), | 601 gfx::JPEGCodec::FORMAT_BGRA, bitmap.width(), |
602 bitmap.height(), | 602 bitmap.height(), |
603 static_cast<int>(bitmap.rowBytes()), 90, | 603 static_cast<int>(bitmap.rowBytes()), 90, |
604 &data)) { | 604 &data)) { |
605 return false; | 605 return false; |
606 } | 606 } |
607 // As we're going to cache this data, make sure the vector is only as big as | 607 // As we're going to cache this data, make sure the vector is only as big as |
608 // it needs to be. | 608 // it needs to be, as JPEGCodec::Encode() over-allocates data.capacity(). |
609 (*bytes)->data = data; | 609 // (In a C++0x future, we can just call shrink_to_fit() in Encode()) |
| 610 (*bytes)->data() = data; |
610 return true; | 611 return true; |
611 } | 612 } |
612 | 613 |
613 void TopSites::RemoveTemporaryThumbnailByURL(const GURL& url) { | 614 void TopSites::RemoveTemporaryThumbnailByURL(const GURL& url) { |
614 for (TempImages::iterator i = temp_images_.begin(); i != temp_images_.end(); | 615 for (TempImages::iterator i = temp_images_.begin(); i != temp_images_.end(); |
615 ++i) { | 616 ++i) { |
616 if (i->first == url) { | 617 if (i->first == url) { |
617 temp_images_.erase(i); | 618 temp_images_.erase(i); |
618 return; | 619 return; |
619 } | 620 } |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 SetTopSites(pages); | 1013 SetTopSites(pages); |
1013 | 1014 |
1014 // Used only in testing. | 1015 // Used only in testing. |
1015 NotificationService::current()->Notify( | 1016 NotificationService::current()->Notify( |
1016 chrome::NOTIFICATION_TOP_SITES_UPDATED, | 1017 chrome::NOTIFICATION_TOP_SITES_UPDATED, |
1017 Source<TopSites>(this), | 1018 Source<TopSites>(this), |
1018 Details<CancelableRequestProvider::Handle>(&handle)); | 1019 Details<CancelableRequestProvider::Handle>(&handle)); |
1019 } | 1020 } |
1020 | 1021 |
1021 } // namespace history | 1022 } // namespace history |
OLD | NEW |