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

Unified Diff: cc/tiles/software_image_decode_controller.cc

Issue 1854723002: cc: Simplify task and its derived classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Corrected scope of dependencies. Created 4 years, 8 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
Index: cc/tiles/software_image_decode_controller.cc
diff --git a/cc/tiles/software_image_decode_controller.cc b/cc/tiles/software_image_decode_controller.cc
index 93d017f186fa0dd34000ca815ef3f7ff637cdc17..96f1697d1270276750888014a0f673dfaf59e781 100644
--- a/cc/tiles/software_image_decode_controller.cc
+++ b/cc/tiles/software_image_decode_controller.cc
@@ -36,7 +36,7 @@ class AutoRemoveKeyFromTaskMap {
public:
AutoRemoveKeyFromTaskMap(
std::unordered_map<SoftwareImageDecodeController::ImageKey,
- scoped_refptr<ImageDecodeTask>,
+ scoped_refptr<Task>,
SoftwareImageDecodeController::ImageKeyHash>* task_map,
const SoftwareImageDecodeController::ImageKey& key)
: task_map_(task_map), key_(key) {}
@@ -44,12 +44,12 @@ class AutoRemoveKeyFromTaskMap {
private:
std::unordered_map<SoftwareImageDecodeController::ImageKey,
- scoped_refptr<ImageDecodeTask>,
+ scoped_refptr<Task>,
SoftwareImageDecodeController::ImageKeyHash>* task_map_;
SoftwareImageDecodeController::ImageKey key_;
};
-class ImageDecodeTaskImpl : public ImageDecodeTask {
+class ImageDecodeTaskImpl : public Task {
public:
ImageDecodeTaskImpl(SoftwareImageDecodeController* controller,
const SoftwareImageDecodeController::ImageKey& image_key,
@@ -62,6 +62,10 @@ class ImageDecodeTaskImpl : public ImageDecodeTask {
source_prepare_tiles_id_(source_prepare_tiles_id) {}
// Overridden from Task:
+ void ScheduleOnOriginThread() override {}
+ void CompleteOnOriginThread() override {
+ controller_->RemovePendingTask(image_key_);
+ }
void RunOnWorkerThread() override {
TRACE_EVENT2("cc", "ImageDecodeTaskImpl::RunOnWorkerThread", "mode",
"software", "source_prepare_tiles_id",
@@ -71,12 +75,6 @@ class ImageDecodeTaskImpl : public ImageDecodeTask {
controller_->DecodeImage(image_key_, image_);
}
- // Overridden from TileTask:
- void ScheduleOnOriginThread(TileTaskClient* client) override {}
- void CompleteOnOriginThread(TileTaskClient* client) override {
- controller_->RemovePendingTask(image_key_);
- }
-
protected:
~ImageDecodeTaskImpl() override {}
@@ -157,7 +155,7 @@ SoftwareImageDecodeController::~SoftwareImageDecodeController() {
bool SoftwareImageDecodeController::GetTaskForImageAndRef(
const DrawImage& image,
uint64_t prepare_tiles_id,
- scoped_refptr<ImageDecodeTask>* task) {
+ scoped_refptr<Task>* task) {
// If the image already exists or if we're going to create a task for it, then
// we'll likely need to ref this image (the exception is if we're prerolling
// the image only). That means the image is or will be in the cache. When the
@@ -184,7 +182,7 @@ bool SoftwareImageDecodeController::GetTaskForImageAndRef(
if (!CanHandleImage(key)) {
base::AutoLock lock(lock_);
if (prerolled_images_.count(key.image_id()) == 0) {
- scoped_refptr<ImageDecodeTask>& existing_task = pending_image_tasks_[key];
+ scoped_refptr<Task>& existing_task = pending_image_tasks_[key];
if (!existing_task) {
existing_task = make_scoped_refptr(
new ImageDecodeTaskImpl(this, key, image, prepare_tiles_id));
@@ -217,7 +215,7 @@ bool SoftwareImageDecodeController::GetTaskForImageAndRef(
}
// If the task exists, return it.
- scoped_refptr<ImageDecodeTask>& existing_task = pending_image_tasks_[key];
+ scoped_refptr<Task>& existing_task = pending_image_tasks_[key];
if (existing_task) {
RefImage(key);
*task = existing_task;

Powered by Google App Engine
This is Rietveld 408576698