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

Unified Diff: chrome/browser/android/thumbnail/thumbnail.cc

Issue 1371523003: Android: Don't destroy LayerTreeHost when Surface goes away (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/thumbnail/thumbnail.h ('k') | chrome/browser/android/thumbnail/thumbnail_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/thumbnail/thumbnail.cc
diff --git a/chrome/browser/android/thumbnail/thumbnail.cc b/chrome/browser/android/thumbnail/thumbnail.cc
index 62c4aa675742b36a8c7133d5dd0b7f87ab10615d..744b1d408ee660d033a3a2f8f078d83b285ddf20 100644
--- a/chrome/browser/android/thumbnail/thumbnail.cc
+++ b/chrome/browser/android/thumbnail/thumbnail.cc
@@ -2,7 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind.h"
+#include "base/location.h"
#include "base/logging.h"
+#include "base/thread_task_runner_handle.h"
#include "chrome/browser/android/thumbnail/thumbnail.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
@@ -45,7 +48,8 @@ Thumbnail::Thumbnail(TabId tab_id,
ui_resource_id_(0),
retrieved_(false),
ui_resource_provider_(ui_resource_provider),
- thumbnail_delegate_(thumbnail_delegate) {
+ thumbnail_delegate_(thumbnail_delegate),
+ weak_factory_(this) {
}
Thumbnail::~Thumbnail() {
@@ -83,8 +87,15 @@ void Thumbnail::CreateUIResource() {
cc::UIResourceBitmap Thumbnail::GetBitmap(cc::UIResourceId uid,
bool resource_lost) {
- if (retrieved_)
+ if (retrieved_) {
+ // InvalidateCachedThumbnail() causes |this| to be deleted, so
+ // don't delete the resource while LayerTeeHost calls into |this|
+ // to avoid reentry there.
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(&Thumbnail::DoInvalidate, weak_factory_.GetWeakPtr()));
return bitmap_;
+ }
retrieved_ = true;
@@ -94,8 +105,7 @@ cc::UIResourceBitmap Thumbnail::GetBitmap(cc::UIResourceId uid,
return old_bitmap;
}
-void Thumbnail::UIResourceIsInvalid() {
- ui_resource_id_ = 0;
+void Thumbnail::DoInvalidate() {
if (thumbnail_delegate_)
thumbnail_delegate_->InvalidateCachedThumbnail(this);
}
« no previous file with comments | « chrome/browser/android/thumbnail/thumbnail.h ('k') | chrome/browser/android/thumbnail/thumbnail_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698