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 #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 <map> |
11 #include <set> | 12 #include <set> |
12 #include <string> | 13 #include <string> |
13 | 14 |
14 #include "base/bind.h" | 15 #include "base/bind.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/memory_pressure_listener.h" |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
20 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "chrome/browser/android/thumbnail/scoped_ptr_expiring_cache.h" | 22 #include "chrome/browser/android/thumbnail/scoped_ptr_expiring_cache.h" |
23 #include "chrome/browser/android/thumbnail/thumbnail.h" | 23 #include "chrome/browser/android/thumbnail/thumbnail.h" |
24 #include "third_party/skia/include/core/SkBitmap.h" | 24 #include "third_party/skia/include/core/SkBitmap.h" |
25 #include "third_party/skia/include/core/SkRefCnt.h" | 25 #include "third_party/skia/include/core/SkRefCnt.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 ThumbnailMetaData(); | 83 ThumbnailMetaData(); |
84 ThumbnailMetaData(const base::Time& current_time, const GURL& url); | 84 ThumbnailMetaData(const base::Time& current_time, const GURL& url); |
85 const GURL& url() const { return url_; } | 85 const GURL& url() const { return url_; } |
86 base::Time capture_time() const { return capture_time_; } | 86 base::Time capture_time() const { return capture_time_; } |
87 | 87 |
88 private: | 88 private: |
89 base::Time capture_time_; | 89 base::Time capture_time_; |
90 GURL url_; | 90 GURL url_; |
91 }; | 91 }; |
92 | 92 |
93 typedef ScopedPtrExpiringCache<TabId, Thumbnail> ExpiringThumbnailCache; | 93 using ExpiringThumbnailCache = ScopedPtrExpiringCache<TabId, Thumbnail>; |
94 typedef base::hash_map<TabId, ThumbnailMetaData> ThumbnailMetaDataMap; | 94 using ThumbnailMetaDataMap = std::map<TabId, ThumbnailMetaData>; |
95 | 95 |
96 void RemoveFromDisk(TabId tab_id); | 96 void RemoveFromDisk(TabId tab_id); |
97 static void RemoveFromDiskTask(TabId tab_id); | 97 static void RemoveFromDiskTask(TabId tab_id); |
98 void WriteThumbnailIfNecessary(TabId tab_id, | 98 void WriteThumbnailIfNecessary(TabId tab_id, |
99 sk_sp<SkPixelRef> compressed_data, | 99 sk_sp<SkPixelRef> compressed_data, |
100 float scale, | 100 float scale, |
101 const gfx::Size& content_size); | 101 const gfx::Size& content_size); |
102 void CompressThumbnailIfNecessary(TabId tab_id, | 102 void CompressThumbnailIfNecessary(TabId tab_id, |
103 const base::Time& time_stamp, | 103 const base::Time& time_stamp, |
104 const SkBitmap& bitmap, | 104 const SkBitmap& bitmap, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 ui::UIResourceProvider* ui_resource_provider_; | 165 ui::UIResourceProvider* ui_resource_provider_; |
166 | 166 |
167 std::unique_ptr<base::MemoryPressureListener> memory_pressure_; | 167 std::unique_ptr<base::MemoryPressureListener> memory_pressure_; |
168 base::WeakPtrFactory<ThumbnailCache> weak_factory_; | 168 base::WeakPtrFactory<ThumbnailCache> weak_factory_; |
169 | 169 |
170 DISALLOW_COPY_AND_ASSIGN(ThumbnailCache); | 170 DISALLOW_COPY_AND_ASSIGN(ThumbnailCache); |
171 }; | 171 }; |
172 | 172 |
173 #endif // CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_CACHE_H_ | 173 #endif // CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_CACHE_H_ |
OLD | NEW |