summaryrefslogtreecommitdiffstats
path: root/cc/test/fake_tile_manager.cc
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-09 01:23:53 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-09 01:23:53 +0000
commitec7541d7017558d645b8c4eceebc6ceb5b89aea4 (patch)
treec9712bc727a3d5d03e4c73401c26eeb358c626c9 /cc/test/fake_tile_manager.cc
parent06d4187e5500be8ff724eb001fe175a1234f733c (diff)
downloadchromium_src-ec7541d7017558d645b8c4eceebc6ceb5b89aea4.zip
chromium_src-ec7541d7017558d645b8c4eceebc6ceb5b89aea4.tar.gz
chromium_src-ec7541d7017558d645b8c4eceebc6ceb5b89aea4.tar.bz2
cc: Make RasterWorkerPool an abstract class.
This makes ownership more clear and avoids the need to have the base class call virtual functions that need to be implemented by derived classes. Also removes the need for the base class to implement the WorkerPoolTaskClient interface. No changes in behavior. Might have a small positive impact on performance as it removes an unnecessary level of callback redirection from the "raster finished" tasks. BUG=269841 Review URL: https://codereview.chromium.org/221953003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262584 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test/fake_tile_manager.cc')
-rw-r--r--cc/test/fake_tile_manager.cc66
1 files changed, 30 insertions, 36 deletions
diff --git a/cc/test/fake_tile_manager.cc b/cc/test/fake_tile_manager.cc
index cf797f1..da365e7 100644
--- a/cc/test/fake_tile_manager.cc
+++ b/cc/test/fake_tile_manager.cc
@@ -7,17 +7,19 @@
#include <deque>
#include <limits>
+#include "base/lazy_instance.h"
#include "cc/resources/raster_worker_pool.h"
namespace cc {
namespace {
-class FakeRasterWorkerPool : public RasterWorkerPool {
+class FakeRasterWorkerPool : public RasterWorkerPool,
+ public internal::WorkerPoolTaskClient {
public:
- FakeRasterWorkerPool() : RasterWorkerPool(NULL, NULL, NULL) {}
-
// Overridden from RasterWorkerPool:
+ virtual void SetClient(RasterWorkerPoolClient* client) OVERRIDE {}
+ virtual void Shutdown() OVERRIDE {}
virtual void ScheduleTasks(RasterTaskQueue* queue) OVERRIDE {
for (RasterTaskQueue::Item::Vector::const_iterator it =
queue->items.begin();
@@ -33,17 +35,19 @@ class FakeRasterWorkerPool : public RasterWorkerPool {
}
}
virtual void CheckForCompletedTasks() OVERRIDE {
- while (!completed_tasks_.empty()) {
- internal::WorkerPoolTask* task = completed_tasks_.front().get();
+ for (internal::WorkerPoolTask::Vector::iterator it =
+ completed_tasks_.begin();
+ it != completed_tasks_.end();
+ ++it) {
+ internal::WorkerPoolTask* task = it->get();
task->WillComplete();
task->CompleteOnOriginThread(this);
task->DidComplete();
task->RunReplyOnOriginThread();
-
- completed_tasks_.pop_front();
}
+ completed_tasks_.clear();
}
virtual GLenum GetResourceTarget() const OVERRIDE {
return GL_TEXTURE_2D;
@@ -61,63 +65,53 @@ class FakeRasterWorkerPool : public RasterWorkerPool {
const Resource* resource) OVERRIDE {}
private:
- // Overridden from RasterWorkerPool:
- virtual void OnRasterTasksFinished() OVERRIDE {}
- virtual void OnRasterTasksRequiredForActivationFinished() OVERRIDE {}
-
- TaskDeque completed_tasks_;
+ internal::WorkerPoolTask::Vector completed_tasks_;
};
+base::LazyInstance<FakeRasterWorkerPool> g_fake_raster_worker_pool =
+ LAZY_INSTANCE_INITIALIZER;
} // namespace
FakeTileManager::FakeTileManager(TileManagerClient* client)
: TileManager(client,
- base::MessageLoopProxy::current().get(),
- NULL,
NULL,
- make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool),
- make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool),
+ g_fake_raster_worker_pool.Pointer(),
+ g_fake_raster_worker_pool.Pointer(),
std::numeric_limits<unsigned>::max(),
- NULL,
- true) {}
+ true,
+ NULL) {}
FakeTileManager::FakeTileManager(TileManagerClient* client,
ResourceProvider* resource_provider)
: TileManager(client,
- base::MessageLoopProxy::current().get(),
resource_provider,
- NULL,
- make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool),
- make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool),
+ g_fake_raster_worker_pool.Pointer(),
+ g_fake_raster_worker_pool.Pointer(),
std::numeric_limits<unsigned>::max(),
- NULL,
- true) {}
+ true,
+ NULL) {}
FakeTileManager::FakeTileManager(TileManagerClient* client,
ResourceProvider* resource_provider,
bool allow_on_demand_raster)
: TileManager(client,
- base::MessageLoopProxy::current().get(),
resource_provider,
- NULL,
- make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool),
- make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool),
+ g_fake_raster_worker_pool.Pointer(),
+ g_fake_raster_worker_pool.Pointer(),
std::numeric_limits<unsigned>::max(),
- NULL,
- allow_on_demand_raster) {}
+ allow_on_demand_raster,
+ NULL) {}
FakeTileManager::FakeTileManager(TileManagerClient* client,
ResourceProvider* resource_provider,
size_t raster_task_limit_bytes)
: TileManager(client,
- base::MessageLoopProxy::current().get(),
resource_provider,
- NULL,
- make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool),
- make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool),
+ g_fake_raster_worker_pool.Pointer(),
+ g_fake_raster_worker_pool.Pointer(),
raster_task_limit_bytes,
- NULL,
- true) {}
+ true,
+ NULL) {}
FakeTileManager::~FakeTileManager() {}