Sync: Avoid deadlock in SyncBackendRegistrar / ModelSafeWorker on sync backend shutdown.
[chromium-blink-merge.git] / cc / resources / bitmap_raster_worker_pool.h
blob876bf363a002907be7b43bd021c12cd02d0146d1
1 // Copyright 2014 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 #ifndef CC_RESOURCES_BITMAP_RASTER_WORKER_POOL_H_
6 #define CC_RESOURCES_BITMAP_RASTER_WORKER_POOL_H_
8 #include "base/memory/weak_ptr.h"
9 #include "base/values.h"
10 #include "cc/resources/raster_worker_pool.h"
11 #include "cc/resources/rasterizer.h"
13 namespace base {
14 namespace debug {
15 class ConvertableToTraceFormat;
19 namespace cc {
20 class ResourceProvider;
22 class CC_EXPORT BitmapRasterWorkerPool : public RasterWorkerPool,
23 public Rasterizer,
24 public RasterizerTaskClient {
25 public:
26 virtual ~BitmapRasterWorkerPool();
28 static scoped_ptr<RasterWorkerPool> Create(
29 base::SequencedTaskRunner* task_runner,
30 TaskGraphRunner* task_graph_runner,
31 ResourceProvider* resource_provider);
33 // Overridden from RasterWorkerPool:
34 virtual Rasterizer* AsRasterizer() override;
36 // Overridden from Rasterizer:
37 virtual void SetClient(RasterizerClient* client) override;
38 virtual void Shutdown() override;
39 virtual void ScheduleTasks(RasterTaskQueue* queue) override;
40 virtual void CheckForCompletedTasks() override;
42 // Overridden from RasterizerTaskClient:
43 virtual scoped_ptr<RasterBuffer> AcquireBufferForRaster(
44 const Resource* resource) override;
45 virtual void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override;
47 protected:
48 BitmapRasterWorkerPool(base::SequencedTaskRunner* task_runner,
49 TaskGraphRunner* task_graph_runner,
50 ResourceProvider* resource_provider);
52 private:
53 void OnRasterFinished(TaskSet task_set);
54 scoped_refptr<base::debug::ConvertableToTraceFormat> StateAsValue() const;
56 scoped_refptr<base::SequencedTaskRunner> task_runner_;
57 TaskGraphRunner* task_graph_runner_;
58 const NamespaceToken namespace_token_;
59 RasterizerClient* client_;
60 ResourceProvider* resource_provider_;
62 TaskSetCollection raster_pending_;
64 scoped_refptr<RasterizerTask> raster_finished_tasks_[kNumberOfTaskSets];
66 // Task graph used when scheduling tasks and vector used to gather
67 // completed tasks.
68 TaskGraph graph_;
69 Task::Vector completed_tasks_;
71 base::WeakPtrFactory<BitmapRasterWorkerPool>
72 raster_finished_weak_ptr_factory_;
74 DISALLOW_COPY_AND_ASSIGN(BitmapRasterWorkerPool);
77 } // namespace cc
79 #endif // CC_RESOURCES_BITMAP_RASTER_WORKER_POOL_H_