Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: chrome/browser/android/thumbnail/thumbnail_cache.h

Issue 2244783005: Android: Don't evict thumbnails for last visible tab on stop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Android: Don't evict thumbnails for last visible tab on stop Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_CACHE_H_ 5 #ifndef CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_CACHE_H_
6 #define CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_CACHE_H_ 6 #define CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_CACHE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <list> 10 #include <list>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/containers/hash_tables.h" 15 #include "base/containers/hash_tables.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/memory_pressure_listener.h"
18 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
19 #include "base/observer_list.h" 20 #include "base/observer_list.h"
20 #include "base/time/time.h" 21 #include "base/time/time.h"
21 #include "chrome/browser/android/thumbnail/scoped_ptr_expiring_cache.h" 22 #include "chrome/browser/android/thumbnail/scoped_ptr_expiring_cache.h"
22 #include "chrome/browser/android/thumbnail/thumbnail.h" 23 #include "chrome/browser/android/thumbnail/thumbnail.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 24 #include "third_party/skia/include/core/SkBitmap.h"
24 #include "third_party/skia/include/core/SkRefCnt.h" 25 #include "third_party/skia/include/core/SkRefCnt.h"
25 #include "ui/android/resources/ui_resource_provider.h" 26 #include "ui/android/resources/ui_resource_provider.h"
26 #include "ui/gfx/geometry/point.h" 27 #include "ui/gfx/geometry/point.h"
27 #include "ui/gfx/geometry/size.h" 28 #include "ui/gfx/geometry/size.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 post_read_task); 141 post_read_task);
141 void PostReadTask(TabId tab_id, 142 void PostReadTask(TabId tab_id,
142 sk_sp<SkPixelRef> compressed_data, 143 sk_sp<SkPixelRef> compressed_data,
143 float scale, 144 float scale,
144 const gfx::Size& content_size); 145 const gfx::Size& content_size);
145 void NotifyObserversOfThumbnailRead(TabId tab_id); 146 void NotifyObserversOfThumbnailRead(TabId tab_id);
146 void RemoveOnMatchedTimeStamp(TabId tab_id, const base::Time& time_stamp); 147 void RemoveOnMatchedTimeStamp(TabId tab_id, const base::Time& time_stamp);
147 static std::pair<SkBitmap, float> CreateApproximation(const SkBitmap& bitmap, 148 static std::pair<SkBitmap, float> CreateApproximation(const SkBitmap& bitmap,
148 float scale); 149 float scale);
149 150
151 void OnMemoryPressure(
152 base::MemoryPressureListener::MemoryPressureLevel level);
153
150 const size_t compression_queue_max_size_; 154 const size_t compression_queue_max_size_;
151 const size_t write_queue_max_size_; 155 const size_t write_queue_max_size_;
152 const bool use_approximation_thumbnail_; 156 const bool use_approximation_thumbnail_;
153 157
154 size_t compression_tasks_count_; 158 size_t compression_tasks_count_;
155 size_t write_tasks_count_; 159 size_t write_tasks_count_;
156 bool read_in_progress_; 160 bool read_in_progress_;
157 161
158 ExpiringThumbnailCache cache_; 162 ExpiringThumbnailCache cache_;
159 ExpiringThumbnailCache approximation_cache_; 163 ExpiringThumbnailCache approximation_cache_;
160 base::ObserverList<ThumbnailCacheObserver> observers_; 164 base::ObserverList<ThumbnailCacheObserver> observers_;
161 ThumbnailMetaDataMap thumbnail_meta_data_; 165 ThumbnailMetaDataMap thumbnail_meta_data_;
162 TabIdList read_queue_; 166 TabIdList read_queue_;
163 TabIdList visible_ids_; 167 TabIdList visible_ids_;
164 168
165 ui::UIResourceProvider* ui_resource_provider_; 169 ui::UIResourceProvider* ui_resource_provider_;
166 170
171 std::unique_ptr<base::MemoryPressureListener> memory_pressure_;
167 base::WeakPtrFactory<ThumbnailCache> weak_factory_; 172 base::WeakPtrFactory<ThumbnailCache> weak_factory_;
168 173
169 DISALLOW_COPY_AND_ASSIGN(ThumbnailCache); 174 DISALLOW_COPY_AND_ASSIGN(ThumbnailCache);
170 }; 175 };
171 176
172 #endif // CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_CACHE_H_ 177 #endif // CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_CACHE_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/thumbnail/scoped_ptr_expiring_cache.h ('k') | chrome/browser/android/thumbnail/thumbnail_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698