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

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: Fix race condition. 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 SetThumbnailCache(JNIEnv* env,
71 jobject obj,
72 jlong thumbnail_cache_ptr);
76 jboolean HasFullCachedThumbnail(JNIEnv* env, jobject obj, jint tab_id); 73 jboolean HasFullCachedThumbnail(JNIEnv* env, jobject obj, jint tab_id);
77 void CacheTab(JNIEnv* env, 74 void CacheTab(JNIEnv* env,
78 jobject obj, 75 jobject obj,
79 jobject tab, 76 jobject tab,
80 jobject content_view_core, 77 jobject content_view_core,
81 jfloat thumbnail_scale); 78 jfloat thumbnail_scale);
82 void CacheTabWithBitmap(JNIEnv* env, 79 void CacheTabWithBitmap(JNIEnv* env,
83 jobject obj, 80 jobject obj,
84 jobject tab, 81 jobject tab,
85 jobject bitmap, 82 jobject bitmap,
(...skipping 13 matching lines...) Expand all
99 class TabReadbackRequest; 96 class TabReadbackRequest;
100 typedef base::hash_map<int, scoped_refptr<cc::Layer>> LayerMap; 97 typedef base::hash_map<int, scoped_refptr<cc::Layer>> LayerMap;
101 typedef base::hash_map<int, scoped_refptr<ThumbnailLayer>> ThumbnailLayerMap; 98 typedef base::hash_map<int, scoped_refptr<ThumbnailLayer>> ThumbnailLayerMap;
102 typedef base::ScopedPtrHashMap<int, scoped_ptr<TabReadbackRequest>> 99 typedef base::ScopedPtrHashMap<int, scoped_ptr<TabReadbackRequest>>
103 TabReadbackRequestMap; 100 TabReadbackRequestMap;
104 101
105 void PutThumbnailIntoCache(int tab_id, 102 void PutThumbnailIntoCache(int tab_id,
106 float thumbnail_scale, 103 float thumbnail_scale,
107 const SkBitmap& bitmap); 104 const SkBitmap& bitmap);
108 105
106 // Do not access directly as it may not be initialized yet, use the getter.
109 scoped_ptr<ThumbnailCache> thumbnail_cache_; 107 scoped_ptr<ThumbnailCache> thumbnail_cache_;
108 ThumbnailCache* GetThumbnailCache();
109
110 ThumbnailLayerMap static_layer_cache_; 110 ThumbnailLayerMap static_layer_cache_;
111 LayerMap live_layer_list_; 111 LayerMap live_layer_list_;
112 TabReadbackRequestMap pending_tab_readbacks_; 112 TabReadbackRequestMap pending_tab_readbacks_;
113 113
114 JavaObjectWeakGlobalRef weak_java_tab_content_manager_; 114 JavaObjectWeakGlobalRef weak_java_tab_content_manager_;
115 base::WeakPtrFactory<TabContentManager> weak_factory_; 115 base::WeakPtrFactory<TabContentManager> weak_factory_;
116 116
117 DISALLOW_COPY_AND_ASSIGN(TabContentManager); 117 DISALLOW_COPY_AND_ASSIGN(TabContentManager);
118 }; 118 };
119 119
120 bool RegisterTabContentManager(JNIEnv* env); 120 bool RegisterTabContentManager(JNIEnv* env);
121 121
122 } // namespace android 122 } // namespace android
123 } // namespace chrome 123 } // namespace chrome
124 124
125 #endif // CHROME_BROWSER_ANDROID_COMPOSITOR_TAB_CONTENT_MANAGER_H_ 125 #endif // CHROME_BROWSER_ANDROID_COMPOSITOR_TAB_CONTENT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698