Index: cc/tiles/gpu_image_decode_controller_unittest.cc |
diff --git a/cc/tiles/gpu_image_decode_controller_unittest.cc b/cc/tiles/gpu_image_decode_controller_unittest.cc |
index fef46e98dccf01c3c3c03c16df8f79be96ed8e9f..525110ead587b69126a6832f12885b4c7cf3a27d 100644 |
--- a/cc/tiles/gpu_image_decode_controller_unittest.cc |
+++ b/cc/tiles/gpu_image_decode_controller_unittest.cc |
@@ -31,28 +31,24 @@ SkMatrix CreateMatrix(const SkSize& scale, bool is_decomposable) { |
return matrix; |
} |
-void ScheduleTask(ImageDecodeTask* task) { |
- task->WillSchedule(); |
- task->ScheduleOnOriginThread(nullptr); |
- task->DidSchedule(); |
-} |
- |
void RunTask(ImageDecodeTask* task) { |
task->WillRun(); |
task->RunOnWorkerThread(); |
task->DidRun(); |
} |
-void CompleteTask(ImageDecodeTask* task) { |
- task->WillComplete(); |
- task->CompleteOnOriginThread(nullptr); |
+void CompleteTask(GpuImageDecodeController* controller, ImageDecodeTask* task) { |
+ if (task->GetTaskTypeId() == TASK_TYPE_IMAGE_DECODE) |
+ controller->ImageDecodeTaskCompleted(task); |
+ else if (task->GetTaskTypeId() == TASK_TYPE_IMAGE_UPLOAD) |
+ controller->ImageUploadTaskCompleted(task); |
+ |
task->DidComplete(); |
} |
-void ProcessTask(ImageDecodeTask* task) { |
- ScheduleTask(task); |
+void ProcessTask(GpuImageDecodeController* controller, ImageDecodeTask* task) { |
RunTask(task); |
- CompleteTask(task); |
+ CompleteTask(controller, task); |
} |
TEST(GpuImageDecodeControllerTest, GetTaskForImageSameImage) { |
@@ -83,8 +79,8 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageSameImage) { |
EXPECT_TRUE(need_unref); |
EXPECT_TRUE(task.get() == another_task.get()); |
- ProcessTask(task->dependency().get()); |
- ProcessTask(task.get()); |
+ ProcessTask(&controller, task->dependency().get()); |
+ ProcessTask(&controller, task.get()); |
controller.UnrefImage(draw_image); |
controller.UnrefImage(draw_image); |
@@ -122,10 +118,10 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageDifferentImage) { |
EXPECT_TRUE(second_task); |
EXPECT_TRUE(first_task.get() != second_task.get()); |
- ProcessTask(first_task->dependency().get()); |
- ProcessTask(first_task.get()); |
- ProcessTask(second_task->dependency().get()); |
- ProcessTask(second_task.get()); |
+ ProcessTask(&controller, first_task->dependency().get()); |
+ ProcessTask(&controller, first_task.get()); |
+ ProcessTask(&controller, second_task->dependency().get()); |
+ ProcessTask(&controller, second_task.get()); |
controller.UnrefImage(first_draw_image); |
controller.UnrefImage(second_draw_image); |
@@ -151,8 +147,7 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageAlreadyDecoded) { |
EXPECT_TRUE(task); |
EXPECT_TRUE(task->dependency()); |
- ProcessTask(task->dependency().get()); |
- ScheduleTask(task.get()); |
+ ProcessTask(&controller, task->dependency().get()); |
RunTask(task.get()); |
scoped_refptr<ImageDecodeTask> another_task; |
@@ -161,7 +156,7 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageAlreadyDecoded) { |
EXPECT_TRUE(need_unref); |
EXPECT_FALSE(another_task); |
- CompleteTask(task.get()); |
+ CompleteTask(&controller, task.get()); |
controller.UnrefImage(draw_image); |
controller.UnrefImage(draw_image); |
@@ -186,8 +181,7 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageCanceledGetsNewTask) { |
EXPECT_TRUE(need_unref); |
EXPECT_TRUE(task); |
- ProcessTask(task->dependency().get()); |
- ScheduleTask(task.get()); |
+ ProcessTask(&controller, task->dependency().get()); |
scoped_refptr<ImageDecodeTask> another_task; |
need_unref = controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, |
@@ -196,7 +190,7 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageCanceledGetsNewTask) { |
EXPECT_TRUE(another_task.get() == task.get()); |
// Didn't run the task, complete it (it was canceled). |
- CompleteTask(task.get()); |
+ CompleteTask(&controller, task.get()); |
// Fully cancel everything (so the raster would unref things). |
controller.UnrefImage(draw_image); |
@@ -210,8 +204,8 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageCanceledGetsNewTask) { |
EXPECT_TRUE(third_task); |
EXPECT_FALSE(third_task.get() == task.get()); |
- ProcessTask(third_task->dependency().get()); |
- ProcessTask(third_task.get()); |
+ ProcessTask(&controller, third_task->dependency().get()); |
+ ProcessTask(&controller, third_task.get()); |
controller.UnrefImage(draw_image); |
} |
@@ -236,8 +230,7 @@ TEST(GpuImageDecodeControllerTest, |
EXPECT_TRUE(need_unref); |
EXPECT_TRUE(task); |
- ProcessTask(task->dependency().get()); |
- ScheduleTask(task.get()); |
+ ProcessTask(&controller, task->dependency().get()); |
scoped_refptr<ImageDecodeTask> another_task; |
need_unref = controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, |
@@ -246,7 +239,7 @@ TEST(GpuImageDecodeControllerTest, |
EXPECT_TRUE(another_task.get() == task.get()); |
// Didn't run the task, complete it (it was canceled). |
- CompleteTask(task.get()); |
+ CompleteTask(&controller, task.get()); |
// Note that here, everything is reffed, but a new task is created. This is |
// possible with repeated schedule/cancel operations. |
@@ -257,8 +250,8 @@ TEST(GpuImageDecodeControllerTest, |
EXPECT_TRUE(third_task); |
EXPECT_FALSE(third_task.get() == task.get()); |
- ProcessTask(third_task->dependency().get()); |
- ProcessTask(third_task.get()); |
+ ProcessTask(&controller, third_task->dependency().get()); |
+ ProcessTask(&controller, third_task.get()); |
// 3 Unrefs! |
controller.UnrefImage(draw_image); |
@@ -285,8 +278,8 @@ TEST(GpuImageDecodeControllerTest, GetDecodedImageForDraw) { |
EXPECT_TRUE(need_unref); |
EXPECT_TRUE(task); |
- ProcessTask(task->dependency().get()); |
- ProcessTask(task.get()); |
+ ProcessTask(&controller, task->dependency().get()); |
+ ProcessTask(&controller, task.get()); |
// Must hold context lock before calling GetDecodedImageForDraw / |
// DrawWithImageFinished. |
@@ -320,8 +313,8 @@ TEST(GpuImageDecodeControllerTest, GetLargeDecodedImageForDraw) { |
EXPECT_TRUE(need_unref); |
EXPECT_TRUE(task); |
- ProcessTask(task->dependency().get()); |
- ProcessTask(task.get()); |
+ ProcessTask(&controller, task->dependency().get()); |
+ ProcessTask(&controller, task.get()); |
// Must hold context lock before calling GetDecodedImageForDraw / |
// DrawWithImageFinished. |
@@ -534,10 +527,8 @@ TEST(GpuImageDecodeControllerTest, CanceledTasksDoNotCountAgainstBudget) { |
EXPECT_TRUE(task); |
EXPECT_TRUE(need_unref); |
- ScheduleTask(task->dependency().get()); |
- CompleteTask(task->dependency().get()); |
- ScheduleTask(task.get()); |
- CompleteTask(task.get()); |
+ CompleteTask(&controller, task->dependency().get()); |
+ CompleteTask(&controller, task.get()); |
controller.UnrefImage(draw_image); |
EXPECT_EQ(0u, controller.GetBytesUsedForTesting()); |
@@ -564,8 +555,8 @@ TEST(GpuImageDecodeControllerTest, ShouldAggressivelyFreeResources) { |
EXPECT_TRUE(task); |
} |
- ProcessTask(task->dependency().get()); |
- ProcessTask(task.get()); |
+ ProcessTask(&controller, task->dependency().get()); |
+ ProcessTask(&controller, task.get()); |
controller.UnrefImage(draw_image); |
@@ -594,8 +585,8 @@ TEST(GpuImageDecodeControllerTest, ShouldAggressivelyFreeResources) { |
EXPECT_TRUE(task); |
} |
- ProcessTask(task->dependency().get()); |
- ProcessTask(task.get()); |
+ ProcessTask(&controller, task->dependency().get()); |
+ ProcessTask(&controller, task.get()); |
// The image should be in our cache after un-ref. |
controller.UnrefImage(draw_image); |