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 #include "chrome/browser/android/compositor/tab_content_manager.h" | 5 #include "chrome/browser/android/compositor/tab_content_manager.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 } | 143 } |
144 | 144 |
145 TabContentManager::~TabContentManager() { | 145 TabContentManager::~TabContentManager() { |
146 } | 146 } |
147 | 147 |
148 void TabContentManager::Destroy(JNIEnv* env, jobject obj) { | 148 void TabContentManager::Destroy(JNIEnv* env, jobject obj) { |
149 thumbnail_cache_->RemoveThumbnailCacheObserver(this); | 149 thumbnail_cache_->RemoveThumbnailCacheObserver(this); |
150 delete this; | 150 delete this; |
151 } | 151 } |
152 | 152 |
153 void TabContentManager::SetUIResourceProvider(JNIEnv* env, | |
154 jobject obj, | |
155 jlong ui_resource_provider_ptr) { | |
156 ui::UIResourceProvider* ui_resource_provider = | |
157 reinterpret_cast<ui::UIResourceProvider*>(ui_resource_provider_ptr); | |
158 SetUIResourceProvider(ui_resource_provider); | |
159 } | |
160 | |
161 void TabContentManager::SetUIResourceProvider( | 153 void TabContentManager::SetUIResourceProvider( |
162 ui::UIResourceProvider* ui_resource_provider) { | 154 ui::UIResourceProvider* ui_resource_provider) { |
163 thumbnail_cache_->SetUIResourceProvider(ui_resource_provider); | 155 thumbnail_cache_->SetUIResourceProvider(ui_resource_provider); |
164 } | 156 } |
165 | 157 |
166 scoped_refptr<cc::Layer> TabContentManager::GetLiveLayer(int tab_id) { | 158 scoped_refptr<cc::Layer> TabContentManager::GetLiveLayer(int tab_id) { |
167 scoped_refptr<cc::Layer> layer = live_layer_list_[tab_id]; | 159 scoped_refptr<cc::Layer> layer = live_layer_list_[tab_id]; |
168 if (!layer.get()) | 160 if (!layer.get()) |
169 return NULL; | 161 return NULL; |
170 | 162 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 void TabContentManager::GetDecompressedThumbnail(JNIEnv* env, | 327 void TabContentManager::GetDecompressedThumbnail(JNIEnv* env, |
336 jobject obj, | 328 jobject obj, |
337 jint tab_id) { | 329 jint tab_id) { |
338 base::Callback<void(bool, SkBitmap)> decompress_done_callback = | 330 base::Callback<void(bool, SkBitmap)> decompress_done_callback = |
339 base::Bind(&TabContentManager::OnFinishDecompressThumbnail, | 331 base::Bind(&TabContentManager::OnFinishDecompressThumbnail, |
340 weak_factory_.GetWeakPtr(), reinterpret_cast<int>(tab_id)); | 332 weak_factory_.GetWeakPtr(), reinterpret_cast<int>(tab_id)); |
341 thumbnail_cache_->DecompressThumbnailFromFile(reinterpret_cast<int>(tab_id), | 333 thumbnail_cache_->DecompressThumbnailFromFile(reinterpret_cast<int>(tab_id), |
342 decompress_done_callback); | 334 decompress_done_callback); |
343 } | 335 } |
344 | 336 |
| 337 void TabContentManager::OnUIResourcesWereEvicted() { |
| 338 thumbnail_cache_->OnUIResourcesWereEvicted(); |
| 339 } |
| 340 |
345 void TabContentManager::OnFinishedThumbnailRead(int tab_id) { | 341 void TabContentManager::OnFinishedThumbnailRead(int tab_id) { |
346 JNIEnv* env = base::android::AttachCurrentThread(); | 342 JNIEnv* env = base::android::AttachCurrentThread(); |
347 Java_TabContentManager_notifyListenersOfThumbnailChange( | 343 Java_TabContentManager_notifyListenersOfThumbnailChange( |
348 env, weak_java_tab_content_manager_.get(env).obj(), tab_id); | 344 env, weak_java_tab_content_manager_.get(env).obj(), tab_id); |
349 } | 345 } |
350 | 346 |
351 void TabContentManager::PutThumbnailIntoCache(int tab_id, | 347 void TabContentManager::PutThumbnailIntoCache(int tab_id, |
352 float thumbnail_scale, | 348 float thumbnail_scale, |
353 const SkBitmap& bitmap) { | 349 const SkBitmap& bitmap) { |
354 TabReadbackRequestMap::iterator readback_iter = | 350 TabReadbackRequestMap::iterator readback_iter = |
(...skipping 23 matching lines...) Expand all Loading... |
378 jboolean use_approximation_thumbnail) { | 374 jboolean use_approximation_thumbnail) { |
379 TabContentManager* manager = new TabContentManager( | 375 TabContentManager* manager = new TabContentManager( |
380 env, obj, default_cache_size, approximation_cache_size, | 376 env, obj, default_cache_size, approximation_cache_size, |
381 compression_queue_max_size, write_queue_max_size, | 377 compression_queue_max_size, write_queue_max_size, |
382 use_approximation_thumbnail); | 378 use_approximation_thumbnail); |
383 return reinterpret_cast<intptr_t>(manager); | 379 return reinterpret_cast<intptr_t>(manager); |
384 } | 380 } |
385 | 381 |
386 } // namespace android | 382 } // namespace android |
387 } // namespace chrome | 383 } // namespace chrome |
OLD | NEW |