Policy: check MustRemainInstalled in addition to UserMayModifySettings before offerin...
[chromium-blink-merge.git] / cc / test / fake_tile_manager.cc
blob04e7cd6b96fe6315766053373914eff5b68d969e
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/test/fake_tile_manager.h"
7 #include <deque>
8 #include <limits>
10 #include "base/lazy_instance.h"
11 #include "cc/resources/raster_buffer.h"
12 #include "cc/resources/tile_task_runner.h"
14 namespace cc {
16 namespace {
18 class FakeTileTaskRunnerImpl : public TileTaskRunner, public TileTaskClient {
19 public:
20 // Overridden from TileTaskRunner:
21 void SetClient(TileTaskRunnerClient* client) override {}
22 void Shutdown() override {}
23 void ScheduleTasks(TileTaskQueue* queue) override {
24 for (TileTaskQueue::Item::Vector::const_iterator it = queue->items.begin();
25 it != queue->items.end(); ++it) {
26 RasterTask* task = it->task;
28 task->WillSchedule();
29 task->ScheduleOnOriginThread(this);
30 task->DidSchedule();
32 completed_tasks_.push_back(task);
35 void CheckForCompletedTasks() override {
36 for (RasterTask::Vector::iterator it = completed_tasks_.begin();
37 it != completed_tasks_.end();
38 ++it) {
39 RasterTask* task = it->get();
41 task->WillComplete();
42 task->CompleteOnOriginThread(this);
43 task->DidComplete();
45 task->RunReplyOnOriginThread();
47 completed_tasks_.clear();
49 ResourceFormat GetResourceFormat() override { return RGBA_8888; }
51 // Overridden from TileTaskClient:
52 scoped_ptr<RasterBuffer> AcquireBufferForRaster(
53 const Resource* resource) override {
54 return nullptr;
56 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override {}
58 private:
59 RasterTask::Vector completed_tasks_;
61 base::LazyInstance<FakeTileTaskRunnerImpl> g_fake_tile_task_runner =
62 LAZY_INSTANCE_INITIALIZER;
64 } // namespace
66 FakeTileManager::FakeTileManager(TileManagerClient* client)
67 : TileManager(client,
68 base::MessageLoopProxy::current(),
69 nullptr,
70 g_fake_tile_task_runner.Pointer(),
71 nullptr,
72 std::numeric_limits<size_t>::max()) {
75 FakeTileManager::FakeTileManager(TileManagerClient* client,
76 ResourcePool* resource_pool)
77 : TileManager(client,
78 base::MessageLoopProxy::current(),
79 resource_pool,
80 g_fake_tile_task_runner.Pointer(),
81 nullptr,
82 std::numeric_limits<size_t>::max()) {
85 FakeTileManager::~FakeTileManager() {}
87 bool FakeTileManager::HasBeenAssignedMemory(Tile* tile) {
88 return std::find(tiles_for_raster.begin(),
89 tiles_for_raster.end(),
90 tile) != tiles_for_raster.end();
93 void FakeTileManager::Release(Tile* tile) {
94 TileManager::Release(tile);
96 FreeResourcesForReleasedTiles();
97 CleanUpReleasedTiles();
100 } // namespace cc