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

Unified Diff: cc/tiles/gpu_image_decode_controller_unittest.cc

Issue 1866043006: cc: Remove ScheduleOnOriginThread() and CompleteOnOriginThread(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/tiles/gpu_image_decode_controller.cc ('k') | cc/tiles/software_image_decode_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2e18670b37a3059c37f4c893a2c56d5a0e9c58a2..b34ac0f8cd8377f317638a282d2070084d00de63 100644
--- a/cc/tiles/gpu_image_decode_controller_unittest.cc
+++ b/cc/tiles/gpu_image_decode_controller_unittest.cc
@@ -41,25 +41,24 @@ SkMatrix CreateMatrix(const SkSize& scale, bool is_decomposable) {
}
void ScheduleTask(TileTask* task) {
- task->WillSchedule();
- task->ScheduleOnOriginThread(nullptr);
- task->DidSchedule();
+ task->state().DidSchedule();
}
+// Before running the task it must be scheduled. Call ScheduleTask() before
+// calling this function.
void RunTask(TileTask* task) {
- // TODO(prashant.n): Once ScheduleOnOriginThread() and
- // CompleteOnOriginThread() functions are removed, modify this function
- // accordingly. (crbug.com/599863)
- task->state().DidSchedule();
task->state().DidStart();
task->RunOnWorkerThread();
task->state().DidFinish();
}
void CompleteTask(TileTask* task) {
- task->WillComplete();
- task->CompleteOnOriginThread(nullptr);
- task->DidComplete();
+ DCHECK(task->state().IsFinished() || task->state().IsCanceled());
+ task->OnTaskCompleted();
+}
+
+void CancelTask(TileTask* task) {
+ task->state().DidCancel();
}
void ProcessTask(TileTask* task) {
@@ -163,7 +162,7 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageAlreadyDecodedAndLocked) {
RunTask(task->dependencies()[0].get());
// Cancel the upload.
- ScheduleTask(task.get());
+ CancelTask(task.get());
CompleteTask(task.get());
// Get the image again - we should have an upload task, but no dependent
@@ -207,7 +206,7 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageAlreadyDecodedNotLocked) {
ProcessTask(task->dependencies()[0].get());
// Cancel the upload.
- ScheduleTask(task.get());
+ CancelTask(task.get());
CompleteTask(task.get());
// Unref the image.
@@ -282,7 +281,6 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageCanceledGetsNewTask) {
EXPECT_TRUE(task);
ProcessTask(task->dependencies()[0].get());
- ScheduleTask(task.get());
scoped_refptr<TileTask> another_task;
need_unref = controller.GetTaskForImageAndRef(
@@ -290,7 +288,8 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageCanceledGetsNewTask) {
EXPECT_TRUE(need_unref);
EXPECT_TRUE(another_task.get() == task.get());
- // Didn't run the task, complete it (it was canceled).
+ // Didn't run the task, so cancel it.
+ CancelTask(task.get());
CompleteTask(task.get());
// Fully cancel everything (so the raster would unref things).
@@ -330,7 +329,6 @@ TEST(GpuImageDecodeControllerTest,
EXPECT_TRUE(task);
ProcessTask(task->dependencies()[0].get());
- ScheduleTask(task.get());
scoped_refptr<TileTask> another_task;
need_unref = controller.GetTaskForImageAndRef(
@@ -338,7 +336,8 @@ TEST(GpuImageDecodeControllerTest,
EXPECT_TRUE(need_unref);
EXPECT_TRUE(another_task.get() == task.get());
- // Didn't run the task, complete it (it was canceled).
+ // Didn't run the task, so cancel it.
+ CancelTask(task.get());
CompleteTask(task.get());
// Note that here, everything is reffed, but a new task is created. This is
@@ -377,8 +376,8 @@ TEST(GpuImageDecodeControllerTest, NoTaskForImageAlreadyFailedDecoding) {
EXPECT_TRUE(task);
ProcessTask(task->dependencies()[0].get());
- ScheduleTask(task.get());
- // Didn't run the task, complete it (it was canceled).
+ // Didn't run the task, so cancel it.
+ CancelTask(task.get());
CompleteTask(task.get());
controller.SetImageDecodingFailedForTesting(draw_image);
@@ -688,9 +687,9 @@ TEST(GpuImageDecodeControllerTest, CanceledTasksDoNotCountAgainstBudget) {
EXPECT_TRUE(task);
EXPECT_TRUE(need_unref);
- ScheduleTask(task->dependencies()[0].get());
+ CancelTask(task->dependencies()[0].get());
CompleteTask(task->dependencies()[0].get());
- ScheduleTask(task.get());
+ CancelTask(task.get());
CompleteTask(task.get());
controller.UnrefImage(draw_image);
« no previous file with comments | « cc/tiles/gpu_image_decode_controller.cc ('k') | cc/tiles/software_image_decode_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698