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

Side by Side Diff: chrome/browser/android/compositor/tab_content_manager.h

Issue 1124333002: Refactor TabContentManager to async create ThumbnailCache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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_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 "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 19 matching lines...) Expand all
30 namespace android { 30 namespace android {
31 31
32 class ThumbnailLayer; 32 class ThumbnailLayer;
33 33
34 // A native component of the Java TabContentManager class. 34 // A native component of the Java TabContentManager class.
35 class TabContentManager : public ThumbnailCacheObserver { 35 class TabContentManager : public ThumbnailCacheObserver {
36 public: 36 public:
37 static TabContentManager* FromJavaObject(jobject jobj); 37 static TabContentManager* FromJavaObject(jobject jobj);
38 38
39 TabContentManager(JNIEnv* env, 39 TabContentManager(JNIEnv* env,
40 jobject obj, 40 jobject obj);
41 jstring disk_cache_path,
42 jint default_cache_size,
43 jint approximation_cache_size,
44 jint compression_queue_max_size,
45 jint write_queue_max_size,
46 jboolean use_approximation_thumbnail);
47 41
48 virtual ~TabContentManager(); 42 virtual ~TabContentManager();
49 43
50 void Destroy(JNIEnv* env, jobject obj); 44 void Destroy(JNIEnv* env, jobject obj);
51 45
52 void SetUIResourceProvider(JNIEnv* env, 46 void SetUIResourceProvider(JNIEnv* env,
53 jobject obj, 47 jobject obj,
54 jlong ui_resource_provider_ptr); 48 jlong ui_resource_provider_ptr);
55 void SetUIResourceProvider(ui::UIResourceProvider* ui_resource_provider); 49 void SetUIResourceProvider(ui::UIResourceProvider* ui_resource_provider);
56 50
57 // Get the live layer from the cache. 51 // Get the live layer from the cache.
58 scoped_refptr<cc::Layer> GetLiveLayer(int tab_id); 52 scoped_refptr<cc::Layer> GetLiveLayer(int tab_id);
59 53
60 // Get the static thumbnail from the cache, or the NTP. 54 // Get the static thumbnail from the cache, or the NTP.
61 scoped_refptr<ThumbnailLayer> GetStaticLayer(int tab_id, 55 scoped_refptr<ThumbnailLayer> GetStaticLayer(int tab_id,
62 bool force_disk_read); 56 bool force_disk_read);
63 57
64 // Should be called when a tab gets a new live layer that should be served 58 // Should be called when a tab gets a new live layer that should be served
65 // by the cache to the CompositorView. 59 // by the cache to the CompositorView.
66 void AttachLiveLayer(int tab_id, scoped_refptr<cc::Layer> layer); 60 void AttachLiveLayer(int tab_id, scoped_refptr<cc::Layer> layer);
67 61
68 // Should be called when a tab removes a live layer because it should no 62 // Should be called when a tab removes a live layer because it should no
69 // longer be served by the CompositorView. If |layer| is NULL, will 63 // longer be served by the CompositorView. If |layer| is NULL, will
70 // make sure all live layers are detached. 64 // make sure all live layers are detached.
71 void DetachLiveLayer(int tab_id, scoped_refptr<cc::Layer> layer); 65 void DetachLiveLayer(int tab_id, scoped_refptr<cc::Layer> layer);
72 66
73 // Callback for when the thumbnail decompression for tab_id is done. 67 // Callback for when the thumbnail decompression for tab_id is done.
74 void OnFinishDecompressThumbnail(int tab_id, bool success, SkBitmap bitmap); 68 void OnFinishDecompressThumbnail(int tab_id, bool success, SkBitmap bitmap);
75 // JNI methods. 69 // JNI methods.
70 void CreateThumbnailCache(JNIEnv* env,
71 jobject obj,
72 jstring disk_cache_path,
73 jint default_cache_size,
74 jint approximation_cache_size,
75 jint compression_queue_max_size,
76 jint write_queue_max_size,
77 jboolean use_approximation_thumbnail);
76 jboolean HasFullCachedThumbnail(JNIEnv* env, jobject obj, jint tab_id); 78 jboolean HasFullCachedThumbnail(JNIEnv* env, jobject obj, jint tab_id);
77 void CacheTab(JNIEnv* env, 79 void CacheTab(JNIEnv* env,
78 jobject obj, 80 jobject obj,
79 jobject tab, 81 jobject tab,
80 jobject content_view_core, 82 jobject content_view_core,
81 jfloat thumbnail_scale); 83 jfloat thumbnail_scale);
82 void CacheTabWithBitmap(JNIEnv* env, 84 void CacheTabWithBitmap(JNIEnv* env,
83 jobject obj, 85 jobject obj,
84 jobject tab, 86 jobject tab,
85 jobject bitmap, 87 jobject bitmap,
86 jfloat thumbnail_scale); 88 jfloat thumbnail_scale);
87 void InvalidateIfChanged(JNIEnv* env, jobject obj, jint tab_id, jstring jurl); 89 void InvalidateIfChanged(JNIEnv* env, jobject obj, jint tab_id, jstring jurl);
88 void UpdateVisibleIds(JNIEnv* env, jobject obj, jintArray priority); 90 void UpdateVisibleIds(JNIEnv* env, jobject obj, jintArray priority);
89 void RemoveTabThumbnail(JNIEnv* env, jobject obj, jint tab_id); 91 void RemoveTabThumbnail(JNIEnv* env, jobject obj, jint tab_id);
90 void RemoveTabThumbnailFromDiskAtAndAboveId(JNIEnv* env, 92 void RemoveTabThumbnailFromDiskAtAndAboveId(JNIEnv* env,
91 jobject obj, 93 jobject obj,
92 jint min_forbidden_id); 94 jint min_forbidden_id);
93 void GetDecompressedThumbnail(JNIEnv* env, jobject obj, jint tab_id); 95 void GetDecompressedThumbnail(JNIEnv* env, jobject obj, jint tab_id);
94 96
95 // ThumbnailCacheObserver implementation; 97 // ThumbnailCacheObserver implementation;
96 void OnFinishedThumbnailRead(TabId tab_id) override; 98 void OnFinishedThumbnailRead(TabId tab_id) override;
97 99
98 private: 100 private:
99 class TabReadbackRequest; 101 class TabReadbackRequest;
100 typedef base::hash_map<int, scoped_refptr<cc::Layer>> LayerMap; 102 typedef base::hash_map<int, scoped_refptr<cc::Layer>> LayerMap;
101 typedef base::hash_map<int, scoped_refptr<ThumbnailLayer>> ThumbnailLayerMap; 103 typedef base::hash_map<int, scoped_refptr<ThumbnailLayer>> ThumbnailLayerMap;
102 typedef base::ScopedPtrHashMap<int, scoped_ptr<TabReadbackRequest>> 104 typedef base::ScopedPtrHashMap<int, scoped_ptr<TabReadbackRequest>>
103 TabReadbackRequestMap; 105 TabReadbackRequestMap;
104 106
107 ThumbnailCache* GetThumbnailCache();
105 void PutThumbnailIntoCache(int tab_id, 108 void PutThumbnailIntoCache(int tab_id,
106 float thumbnail_scale, 109 float thumbnail_scale,
107 const SkBitmap& bitmap); 110 const SkBitmap& bitmap);
108 111
109 scoped_ptr<ThumbnailCache> thumbnail_cache_; 112 scoped_ptr<ThumbnailCache> thumbnail_cache_;
David Trainor- moved to gerrit 2015/05/07 17:57:36 Lots of comments explaining how (not) to access th
Peter Wen 2015/05/07 22:08:10 Acknowledged.
110 ThumbnailLayerMap static_layer_cache_; 113 ThumbnailLayerMap static_layer_cache_;
111 LayerMap live_layer_list_; 114 LayerMap live_layer_list_;
112 TabReadbackRequestMap pending_tab_readbacks_; 115 TabReadbackRequestMap pending_tab_readbacks_;
113 116
114 JavaObjectWeakGlobalRef weak_java_tab_content_manager_; 117 JavaObjectWeakGlobalRef weak_java_tab_content_manager_;
115 base::WeakPtrFactory<TabContentManager> weak_factory_; 118 base::WeakPtrFactory<TabContentManager> weak_factory_;
116 119
117 DISALLOW_COPY_AND_ASSIGN(TabContentManager); 120 DISALLOW_COPY_AND_ASSIGN(TabContentManager);
118 }; 121 };
119 122
120 bool RegisterTabContentManager(JNIEnv* env); 123 bool RegisterTabContentManager(JNIEnv* env);
121 124
122 } // namespace android 125 } // namespace android
123 } // namespace chrome 126 } // namespace chrome
124 127
125 #endif // CHROME_BROWSER_ANDROID_COMPOSITOR_TAB_CONTENT_MANAGER_H_ 128 #endif // CHROME_BROWSER_ANDROID_COMPOSITOR_TAB_CONTENT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698