Skip to content

Commit

Permalink
cc: fix another data race in RenderingStatsInstrumentation.
Browse files Browse the repository at this point in the history
Access to the stats was not protected by a lock. Fix by returning a copy to
the stats and locking while making the copy.

R=enne@chromium.org
BUG=370244

Review URL: https://codereview.chromium.org/289163004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271646 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ernstm@chromium.org committed May 20, 2014
1 parent f202649 commit 77f333a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
12 changes: 12 additions & 0 deletions cc/debug/rendering_stats_instrumentation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ RenderingStatsInstrumentation::RenderingStatsInstrumentation()

RenderingStatsInstrumentation::~RenderingStatsInstrumentation() {}

MainThreadRenderingStats
RenderingStatsInstrumentation::main_thread_rendering_stats() {
base::AutoLock scoped_lock(lock_);
return main_stats_;
}

ImplThreadRenderingStats
RenderingStatsInstrumentation::impl_thread_rendering_stats() {
base::AutoLock scoped_lock(lock_);
return impl_stats_;
}

RenderingStats RenderingStatsInstrumentation::GetRenderingStats() {
base::AutoLock scoped_lock(lock_);
RenderingStats rendering_stats;
Expand Down
15 changes: 7 additions & 8 deletions cc/debug/rendering_stats_instrumentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@ class CC_EXPORT RenderingStatsInstrumentation {
static scoped_ptr<RenderingStatsInstrumentation> Create();
virtual ~RenderingStatsInstrumentation();

// Return current main thread rendering stats.
const MainThreadRenderingStats& main_thread_rendering_stats() {
return main_stats_;
}
// Return current impl thread rendering stats.
const ImplThreadRenderingStats& impl_thread_rendering_stats() {
return impl_stats_;
}
// Return copy of current main thread rendering stats.
MainThreadRenderingStats main_thread_rendering_stats();

// Return copy of current impl thread rendering stats.
ImplThreadRenderingStats impl_thread_rendering_stats();

// Return the accumulated, combined rendering stats.
RenderingStats GetRenderingStats();

// Add current main thread rendering stats to accumulator and
// clear current stats.
void AccumulateAndClearMainThreadStats();

// Add current impl thread rendering stats to accumulator and
// clear current stats.
void AccumulateAndClearImplThreadStats();
Expand Down

0 comments on commit 77f333a

Please sign in to comment.