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_COMPOSITOR_TAB_CONTENT_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_COMPOSITOR_TAB_CONTENT_MANAGER_H_ |
6 #define CHROME_BROWSER_ANDROID_COMPOSITOR_TAB_CONTENT_MANAGER_H_ | 6 #define CHROME_BROWSER_ANDROID_COMPOSITOR_TAB_CONTENT_MANAGER_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include <unordered_map> | 10 #include <map> |
11 | 11 |
12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
13 #include "base/android/jni_weak_ref.h" | 13 #include "base/android/jni_weak_ref.h" |
14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/flat_map.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "cc/layers/ui_resource_layer.h" | 17 #include "cc/layers/ui_resource_layer.h" |
18 #include "chrome/browser/android/thumbnail/thumbnail_cache.h" | 18 #include "chrome/browser/android/thumbnail/thumbnail_cache.h" |
19 | 19 |
20 using base::android::ScopedJavaLocalRef; | 20 using base::android::ScopedJavaLocalRef; |
21 | 21 |
22 namespace cc { | 22 namespace cc { |
23 class Layer; | 23 class Layer; |
24 } | 24 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 void GetDecompressedThumbnail(JNIEnv* env, | 98 void GetDecompressedThumbnail(JNIEnv* env, |
99 const base::android::JavaParamRef<jobject>& obj, | 99 const base::android::JavaParamRef<jobject>& obj, |
100 jint tab_id); | 100 jint tab_id); |
101 void OnUIResourcesWereEvicted(); | 101 void OnUIResourcesWereEvicted(); |
102 | 102 |
103 // ThumbnailCacheObserver implementation; | 103 // ThumbnailCacheObserver implementation; |
104 void OnFinishedThumbnailRead(TabId tab_id) override; | 104 void OnFinishedThumbnailRead(TabId tab_id) override; |
105 | 105 |
106 private: | 106 private: |
107 class TabReadbackRequest; | 107 class TabReadbackRequest; |
108 using LayerMap = base::hash_map<int, scoped_refptr<cc::Layer>>; | 108 // TODO(bug 714384) check sizes and consider using base::flat_map if these |
109 using ThumbnailLayerMap = base::hash_map<int, scoped_refptr<ThumbnailLayer>>; | 109 // layer maps are small. |
| 110 using LayerMap = std::map<int, scoped_refptr<cc::Layer>>; |
| 111 using ThumbnailLayerMap = std::map<int, scoped_refptr<ThumbnailLayer>>; |
110 using TabReadbackRequestMap = | 112 using TabReadbackRequestMap = |
111 std::unordered_map<int, std::unique_ptr<TabReadbackRequest>>; | 113 base::flat_map<int, std::unique_ptr<TabReadbackRequest>>; |
112 | 114 |
113 void PutThumbnailIntoCache(int tab_id, | 115 void PutThumbnailIntoCache(int tab_id, |
114 float thumbnail_scale, | 116 float thumbnail_scale, |
115 const SkBitmap& bitmap); | 117 const SkBitmap& bitmap); |
116 | 118 |
117 std::unique_ptr<ThumbnailCache> thumbnail_cache_; | 119 std::unique_ptr<ThumbnailCache> thumbnail_cache_; |
118 ThumbnailLayerMap static_layer_cache_; | 120 ThumbnailLayerMap static_layer_cache_; |
119 LayerMap live_layer_list_; | 121 LayerMap live_layer_list_; |
120 TabReadbackRequestMap pending_tab_readbacks_; | 122 TabReadbackRequestMap pending_tab_readbacks_; |
121 | 123 |
122 JavaObjectWeakGlobalRef weak_java_tab_content_manager_; | 124 JavaObjectWeakGlobalRef weak_java_tab_content_manager_; |
123 base::WeakPtrFactory<TabContentManager> weak_factory_; | 125 base::WeakPtrFactory<TabContentManager> weak_factory_; |
124 | 126 |
125 DISALLOW_COPY_AND_ASSIGN(TabContentManager); | 127 DISALLOW_COPY_AND_ASSIGN(TabContentManager); |
126 }; | 128 }; |
127 | 129 |
128 bool RegisterTabContentManager(JNIEnv* env); | 130 bool RegisterTabContentManager(JNIEnv* env); |
129 | 131 |
130 } // namespace android | 132 } // namespace android |
131 | 133 |
132 #endif // CHROME_BROWSER_ANDROID_COMPOSITOR_TAB_CONTENT_MANAGER_H_ | 134 #endif // CHROME_BROWSER_ANDROID_COMPOSITOR_TAB_CONTENT_MANAGER_H_ |
OLD | NEW |