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

Side by Side Diff: cc/base/worker_pool.h

Issue 12519006: cc:: Add RenderingStatsInstrumentation to manage collection of RenderingStats (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Updated all tests Created 7 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | cc/base/worker_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_BASE_WORKER_POOL_H_ 5 #ifndef CC_BASE_WORKER_POOL_H_
6 #define CC_BASE_WORKER_POOL_H_ 6 #define CC_BASE_WORKER_POOL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/cancelable_callback.h" 10 #include "base/cancelable_callback.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "cc/base/cc_export.h" 14 #include "cc/base/cc_export.h"
15 #include "cc/base/scoped_ptr_deque.h" 15 #include "cc/base/scoped_ptr_deque.h"
16 16
17 namespace cc { 17 namespace cc {
18 struct RenderingStats;
19 18
20 namespace internal { 19 namespace internal {
21 20
22 class WorkerPoolTask { 21 class WorkerPoolTask {
23 public: 22 public:
24 virtual ~WorkerPoolTask(); 23 virtual ~WorkerPoolTask();
25 24
26 virtual bool IsCheap() = 0; 25 virtual bool IsCheap() = 0;
27 26
28 virtual void Run(RenderingStats* rendering_stats) = 0; 27 virtual void Run() = 0;
29 28
30 virtual void RunOnThread( 29 virtual void RunOnThread(unsigned thread_index) = 0;
31 RenderingStats* rendering_stats, unsigned thread_index) = 0;
32 30
33 void DidComplete(); 31 void DidComplete();
34 32
35 protected: 33 protected:
36 WorkerPoolTask(const base::Closure& reply); 34 WorkerPoolTask(const base::Closure& reply);
37 35
38 const base::Closure reply_; 36 const base::Closure reply_;
39 }; 37 };
40 38
41 } // namespace internal 39 } // namespace internal
42 40
43 class CC_EXPORT WorkerPoolClient { 41 class CC_EXPORT WorkerPoolClient {
44 public: 42 public:
45 virtual void DidFinishDispatchingWorkerPoolCompletionCallbacks() = 0; 43 virtual void DidFinishDispatchingWorkerPoolCompletionCallbacks() = 0;
46 44
47 protected: 45 protected:
48 virtual ~WorkerPoolClient() {} 46 virtual ~WorkerPoolClient() {}
49 }; 47 };
50 48
51 // A worker thread pool that runs rendering tasks and guarantees completion 49 // A worker thread pool that runs rendering tasks and guarantees completion
52 // of all pending tasks at shutdown. 50 // of all pending tasks at shutdown.
53 class WorkerPool { 51 class WorkerPool {
54 public: 52 public:
55 typedef base::Callback<void(RenderingStats*)> Callback; 53 typedef base::Callback<void()> Callback;
56 54
57 virtual ~WorkerPool(); 55 virtual ~WorkerPool();
58 56
59 static scoped_ptr<WorkerPool> Create( 57 static scoped_ptr<WorkerPool> Create(
60 WorkerPoolClient* client, 58 WorkerPoolClient* client,
61 size_t num_threads, 59 size_t num_threads,
62 base::TimeDelta check_for_completed_tasks_delay, 60 base::TimeDelta check_for_completed_tasks_delay,
63 const std::string& thread_name_prefix) { 61 const std::string& thread_name_prefix) {
64 return make_scoped_ptr(new WorkerPool(client, 62 return make_scoped_ptr(new WorkerPool(client,
65 num_threads, 63 num_threads,
66 check_for_completed_tasks_delay, 64 check_for_completed_tasks_delay,
67 thread_name_prefix)); 65 thread_name_prefix));
68 } 66 }
69 67
70 // Tells the worker pool to shutdown and returns once all pending tasks have 68 // Tells the worker pool to shutdown and returns once all pending tasks have
71 // completed. 69 // completed.
72 void Shutdown(); 70 void Shutdown();
73 71
74 // Posts |task| to worker pool. On completion, |reply| 72 // Posts |task| to worker pool. On completion, |reply|
75 // is posted to the thread that called PostTaskAndReply(). 73 // is posted to the thread that called PostTaskAndReply().
76 void PostTaskAndReply(const Callback& task, const base::Closure& reply); 74 void PostTaskAndReply(const Callback& task, const base::Closure& reply);
77 75
78 // Set time limit for running cheap tasks. 76 // Set time limit for running cheap tasks.
79 void SetRunCheapTasksTimeLimit(base::TimeTicks run_cheap_tasks_time_limit); 77 void SetRunCheapTasksTimeLimit(base::TimeTicks run_cheap_tasks_time_limit);
80 78
81 // Toggle rendering stats collection.
82 void SetRecordRenderingStats(bool record_rendering_stats);
83
84 // Collect rendering stats of all completed tasks.
85 void GetRenderingStats(RenderingStats* stats);
86
87 protected: 79 protected:
88 WorkerPool(WorkerPoolClient* client, 80 WorkerPool(WorkerPoolClient* client,
89 size_t num_threads, 81 size_t num_threads,
90 base::TimeDelta check_for_completed_tasks_delay, 82 base::TimeDelta check_for_completed_tasks_delay,
91 const std::string& thread_name_prefix); 83 const std::string& thread_name_prefix);
92 84
93 void PostTask(scoped_ptr<internal::WorkerPoolTask> task); 85 void PostTask(scoped_ptr<internal::WorkerPoolTask> task);
94 86
95 private: 87 private:
96 class Inner; 88 class Inner;
(...skipping 25 matching lines...) Expand all
122 114
123 // Hide the gory details of the worker pool in |inner_|. 115 // Hide the gory details of the worker pool in |inner_|.
124 const scoped_ptr<Inner> inner_; 116 const scoped_ptr<Inner> inner_;
125 117
126 DISALLOW_COPY_AND_ASSIGN(WorkerPool); 118 DISALLOW_COPY_AND_ASSIGN(WorkerPool);
127 }; 119 };
128 120
129 } // namespace cc 121 } // namespace cc
130 122
131 #endif // CC_BASE_WORKER_POOL_H_ 123 #endif // CC_BASE_WORKER_POOL_H_
OLDNEW
« no previous file with comments | « no previous file | cc/base/worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698