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

Unified Diff: cc/resources/raster_worker_pool.cc

Issue 498553005: cc: Fix UAF in g_raster_required_for_activation_delay (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/raster_worker_pool.cc
diff --git a/cc/resources/raster_worker_pool.cc b/cc/resources/raster_worker_pool.cc
index 255d5af5f71e16c5614a4dc6e85fda3e92e29610..34a34fc3e5b8daa458d34483e14a48b71f1cbe21 100644
--- a/cc/resources/raster_worker_pool.cc
+++ b/cc/resources/raster_worker_pool.cc
@@ -15,21 +15,13 @@
namespace cc {
namespace {
-// Synthetic delay for raster tasks that are required for activation. Global to
-// avoid static initializer on critical path.
-struct RasterRequiredForActivationSyntheticDelayInitializer {
- RasterRequiredForActivationSyntheticDelayInitializer()
- : delay(base::debug::TraceEventSyntheticDelay::Lookup(
- "cc.RasterRequiredForActivation")) {}
- base::debug::TraceEventSyntheticDelay* delay;
-};
-static base::LazyInstance<RasterRequiredForActivationSyntheticDelayInitializer>
- g_raster_required_for_activation_delay = LAZY_INSTANCE_INITIALIZER;
-
class RasterTaskGraphRunner : public TaskGraphRunner,
public base::DelegateSimpleThread::Delegate {
public:
- RasterTaskGraphRunner() {
+ RasterTaskGraphRunner()
+ : trace_event_synthetic_delay_(
+ base::debug::TraceEventSyntheticDelay::Lookup(
+ "cc.RasterRequiredForActivation")) {
size_t num_threads = RasterWorkerPool::GetNumRasterThreads();
while (workers_.size() < num_threads) {
scoped_ptr<base::DelegateSimpleThread> worker =
@@ -48,6 +40,10 @@ class RasterTaskGraphRunner : public TaskGraphRunner,
virtual ~RasterTaskGraphRunner() { NOTREACHED(); }
+ base::debug::TraceEventSyntheticDelay* trace_event_synthetic_delay() const {
+ return trace_event_synthetic_delay_;
+ }
+
private:
// Overridden from base::DelegateSimpleThread::Delegate:
virtual void Run() OVERRIDE {
@@ -55,6 +51,7 @@ class RasterTaskGraphRunner : public TaskGraphRunner,
}
ScopedPtrDeque<base::DelegateSimpleThread> workers_;
+ base::debug::TraceEventSyntheticDelay* trace_event_synthetic_delay_;
reveman 2014/08/27 00:34:37 I think |synthetic_delay_| is verbose enough.
boliu 2014/08/27 01:14:49 Done.
};
base::LazyInstance<RasterTaskGraphRunner>::Leaky g_task_graph_runner =
@@ -103,13 +100,14 @@ class RasterRequiredForActivationFinishedTaskImpl
RasterRequiredForActivationFinishedTaskImpl(
base::SequencedTaskRunner* task_runner,
const base::Closure& on_raster_finished_callback,
- size_t tasks_required_for_activation_count)
+ size_t tasks_required_for_activation_count,
+ base::debug::TraceEventSyntheticDelay* delay)
: RasterFinishedTaskImpl(task_runner, on_raster_finished_callback),
+ delay_(delay),
tasks_required_for_activation_count_(
tasks_required_for_activation_count) {
if (tasks_required_for_activation_count_) {
- g_raster_required_for_activation_delay.Get().delay->BeginParallel(
- &activation_delay_end_time_);
+ delay_->BeginParallel(&activation_delay_end_time_);
}
}
@@ -119,8 +117,7 @@ class RasterRequiredForActivationFinishedTaskImpl
"cc", "RasterRequiredForActivationFinishedTaskImpl::RunOnWorkerThread");
if (tasks_required_for_activation_count_) {
- g_raster_required_for_activation_delay.Get().delay->EndParallel(
- activation_delay_end_time_);
+ delay_->EndParallel(activation_delay_end_time_);
}
RasterFinished();
}
@@ -128,6 +125,7 @@ class RasterRequiredForActivationFinishedTaskImpl
private:
virtual ~RasterRequiredForActivationFinishedTaskImpl() {}
+ base::debug::TraceEventSyntheticDelay* delay_;
reveman 2014/08/27 00:34:37 How about just using g_task_graph_runner.Get().syn
boliu 2014/08/27 01:14:49 Done.
base::TimeTicks activation_delay_end_time_;
const size_t tasks_required_for_activation_count_;
@@ -191,7 +189,8 @@ RasterWorkerPool::CreateRasterRequiredForActivationFinishedTask(
return make_scoped_refptr(new RasterRequiredForActivationFinishedTaskImpl(
task_runner,
on_raster_finished_callback,
- tasks_required_for_activation_count));
+ tasks_required_for_activation_count,
+ g_task_graph_runner.Get().trace_event_synthetic_delay()));
}
// static
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698