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

Unified Diff: cc/tiles/image_controller.cc

Issue 2699533010: cc: Fix cleanup path for image decode requests in ImageController. (Closed)
Patch Set: .. Created 3 years, 10 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 | « no previous file | cc/tiles/image_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiles/image_controller.cc
diff --git a/cc/tiles/image_controller.cc b/cc/tiles/image_controller.cc
index f0d1bb9666c9cde5de93e7879041193d1e74851f..931070bfcafe0d394defe4320a2d603dc4320d9f 100644
--- a/cc/tiles/image_controller.cc
+++ b/cc/tiles/image_controller.cc
@@ -77,9 +77,10 @@ void ImageController::StopWorkerTasks() {
ImageDecodeRequestId id = request_to_complete.first;
ImageDecodeRequest& request = request_to_complete.second;
- // The task (if one exists) would have run already, so we just need to
- // complete it.
- if (request.task)
+ // The task (if one exists) would have run already, we just need to make
+ // sure it was completed. Multiple requests for the same image use the same
+ // task so it could have already been completed.
+ if (request.task && !request.task->HasCompleted())
request.task->DidComplete();
// Issue the callback, and unref the image immediately. This is so that any
@@ -106,7 +107,9 @@ void ImageController::StopWorkerTasks() {
// several different image deque requests for the same image.
if (request.task->state().IsNew())
request.task->state().DidCancel();
- request.task->DidComplete();
+
+ if (!request.task->HasCompleted())
+ request.task->DidComplete();
}
// Run the callback and unref the image.
request.callback.Run(id);
@@ -116,11 +119,14 @@ void ImageController::StopWorkerTasks() {
}
void ImageController::SetImageDecodeCache(ImageDecodeCache* cache) {
+ DCHECK(!cache_ || !cache);
+
if (!cache) {
SetPredecodeImages(std::vector<DrawImage>(),
ImageDecodeCache::TracingInfo());
StopWorkerTasks();
}
+
cache_ = cache;
}
« no previous file with comments | « no previous file | cc/tiles/image_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698