OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/android/thumbnail/thumbnail_cache.h" | 5 #include "chrome/browser/android/thumbnail/thumbnail_cache.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 content_size)); | 783 content_size)); |
784 } | 784 } |
785 } | 785 } |
786 | 786 |
787 void ThumbnailCache::PostReadTask(TabId tab_id, | 787 void ThumbnailCache::PostReadTask(TabId tab_id, |
788 sk_sp<SkPixelRef> compressed_data, | 788 sk_sp<SkPixelRef> compressed_data, |
789 float scale, | 789 float scale, |
790 const gfx::Size& content_size) { | 790 const gfx::Size& content_size) { |
791 read_in_progress_ = false; | 791 read_in_progress_ = false; |
792 | 792 |
793 TabIdList::iterator iter = | 793 if (!base::ContainsValue(read_queue_, tab_id)) { |
794 std::find(read_queue_.begin(), read_queue_.end(), tab_id); | |
795 if (iter == read_queue_.end()) { | |
796 ReadNextThumbnail(); | 794 ReadNextThumbnail(); |
797 return; | 795 return; |
798 } | 796 } |
799 | 797 |
800 read_queue_.erase(iter); | 798 read_queue_.erase(iter); |
801 | 799 |
802 if (!cache_.Get(tab_id) && compressed_data) { | 800 if (!cache_.Get(tab_id) && compressed_data) { |
803 ThumbnailMetaDataMap::iterator meta_iter = | 801 ThumbnailMetaDataMap::iterator meta_iter = |
804 thumbnail_meta_data_.find(tab_id); | 802 thumbnail_meta_data_.find(tab_id); |
805 base::Time time_stamp = base::Time::Now(); | 803 base::Time time_stamp = base::Time::Now(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 return std::make_pair(dst_bitmap, new_scale * scale); | 919 return std::make_pair(dst_bitmap, new_scale * scale); |
922 } | 920 } |
923 | 921 |
924 void ThumbnailCache::OnMemoryPressure( | 922 void ThumbnailCache::OnMemoryPressure( |
925 base::MemoryPressureListener::MemoryPressureLevel level) { | 923 base::MemoryPressureListener::MemoryPressureLevel level) { |
926 if (level == base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { | 924 if (level == base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { |
927 cache_.Clear(); | 925 cache_.Clear(); |
928 approximation_cache_.Clear(); | 926 approximation_cache_.Clear(); |
929 } | 927 } |
930 } | 928 } |
OLD | NEW |