summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorsunnyps <sunnyps@chromium.org>2015-06-23 17:09:58 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-24 00:10:42 +0000
commit86c1dbcdd76224d456d1a67302c31f89b082c464 (patch)
treef1d9024c4cbd903b84512cb60a7494da954d5a52 /cc
parentfee8117d13d0724363a2c381c8c8ce29a62ff444 (diff)
downloadchromium_src-86c1dbcdd76224d456d1a67302c31f89b082c464.zip
chromium_src-86c1dbcdd76224d456d1a67302c31f89b082c464.tar.gz
chromium_src-86c1dbcdd76224d456d1a67302c31f89b082c464.tar.bz2
cc: Remove unnecessary task runner refptrs from schedulers.
Task runners are ref counted so that they can be used safely from multiple threads. This is not required for (Display)Scheduler in which case the owner of the scheduler (Proxy or OnScreenDisplayClient) holds a reference to the task runner for as long as the scheduler lives. R=brianderson,mithro CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1205483004 Cr-Commit-Position: refs/heads/master@{#335817}
Diffstat (limited to 'cc')
-rw-r--r--cc/scheduler/scheduler.cc8
-rw-r--r--cc/scheduler/scheduler.h6
-rw-r--r--cc/scheduler/scheduler_unittest.cc6
-rw-r--r--cc/surfaces/display_scheduler.cc9
-rw-r--r--cc/surfaces/display_scheduler.h4
-rw-r--r--cc/surfaces/display_scheduler_unittest.cc25
-rw-r--r--cc/surfaces/display_unittest.cc19
-rw-r--r--cc/surfaces/onscreen_display_client.cc4
-rw-r--r--cc/test/scheduler_test_common.cc8
-rw-r--r--cc/test/scheduler_test_common.h4
10 files changed, 49 insertions, 44 deletions
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc
index 5e9cd4d..6d6ab2a 100644
--- a/cc/scheduler/scheduler.cc
+++ b/cc/scheduler/scheduler.cc
@@ -22,15 +22,15 @@ scoped_ptr<Scheduler> Scheduler::Create(
SchedulerClient* client,
const SchedulerSettings& settings,
int layer_tree_host_id,
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
+ base::SingleThreadTaskRunner* task_runner,
BeginFrameSource* external_frame_source) {
scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source;
if (!settings.use_external_begin_frame_source) {
synthetic_frame_source = SyntheticBeginFrameSource::Create(
- task_runner.get(), BeginFrameArgs::DefaultInterval());
+ task_runner, BeginFrameArgs::DefaultInterval());
}
scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source =
- BackToBackBeginFrameSource::Create(task_runner.get());
+ BackToBackBeginFrameSource::Create(task_runner);
return make_scoped_ptr(new Scheduler(
client, settings, layer_tree_host_id, task_runner, external_frame_source,
synthetic_frame_source.Pass(), unthrottled_frame_source.Pass()));
@@ -40,7 +40,7 @@ Scheduler::Scheduler(
SchedulerClient* client,
const SchedulerSettings& settings,
int layer_tree_host_id,
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
+ base::SingleThreadTaskRunner* task_runner,
BeginFrameSource* external_frame_source,
scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source,
scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source)
diff --git a/cc/scheduler/scheduler.h b/cc/scheduler/scheduler.h
index bac1a7b..6ffdf3f 100644
--- a/cc/scheduler/scheduler.h
+++ b/cc/scheduler/scheduler.h
@@ -59,7 +59,7 @@ class CC_EXPORT Scheduler : public BeginFrameObserverBase {
SchedulerClient* client,
const SchedulerSettings& scheduler_settings,
int layer_tree_host_id,
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
+ base::SingleThreadTaskRunner* task_runner,
BeginFrameSource* external_frame_source);
~Scheduler() override;
@@ -150,7 +150,7 @@ class CC_EXPORT Scheduler : public BeginFrameObserverBase {
Scheduler(SchedulerClient* client,
const SchedulerSettings& scheduler_settings,
int layer_tree_host_id,
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
+ base::SingleThreadTaskRunner* task_runner,
BeginFrameSource* external_frame_source,
scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source,
scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source);
@@ -162,7 +162,7 @@ class CC_EXPORT Scheduler : public BeginFrameObserverBase {
const SchedulerSettings settings_;
SchedulerClient* client_;
int layer_tree_host_id_;
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ base::SingleThreadTaskRunner* task_runner_;
BeginFrameSource* external_frame_source_;
scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source_;
scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source_;
diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc
index 3455675..af08303 100644
--- a/cc/scheduler/scheduler_unittest.cc
+++ b/cc/scheduler/scheduler_unittest.cc
@@ -262,9 +262,9 @@ class SchedulerTest : public testing::Test {
fake_external_begin_frame_source_.reset(
new FakeExternalBeginFrameSource(client_.get()));
}
- scheduler_ = TestScheduler::Create(now_src_.get(), client_.get(),
- scheduler_settings_, 0, task_runner_,
- fake_external_begin_frame_source_.get());
+ scheduler_ = TestScheduler::Create(
+ now_src_.get(), client_.get(), scheduler_settings_, 0,
+ task_runner_.get(), fake_external_begin_frame_source_.get());
DCHECK(scheduler_);
client_->set_scheduler(scheduler_.get());
return scheduler_.get();
diff --git a/cc/surfaces/display_scheduler.cc b/cc/surfaces/display_scheduler.cc
index ebdef9a..3810e14 100644
--- a/cc/surfaces/display_scheduler.cc
+++ b/cc/surfaces/display_scheduler.cc
@@ -12,11 +12,10 @@
namespace cc {
-DisplayScheduler::DisplayScheduler(
- DisplaySchedulerClient* client,
- BeginFrameSource* begin_frame_source,
- scoped_refptr<base::SingleThreadTaskRunner> task_runner,
- int max_pending_swaps)
+DisplayScheduler::DisplayScheduler(DisplaySchedulerClient* client,
+ BeginFrameSource* begin_frame_source,
+ base::SingleThreadTaskRunner* task_runner,
+ int max_pending_swaps)
: client_(client),
begin_frame_source_(begin_frame_source),
task_runner_(task_runner),
diff --git a/cc/surfaces/display_scheduler.h b/cc/surfaces/display_scheduler.h
index 6409c9b..bc509c7 100644
--- a/cc/surfaces/display_scheduler.h
+++ b/cc/surfaces/display_scheduler.h
@@ -30,7 +30,7 @@ class CC_SURFACES_EXPORT DisplayScheduler : public BeginFrameObserverBase {
public:
DisplayScheduler(DisplaySchedulerClient* client,
BeginFrameSource* begin_frame_source,
- scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ base::SingleThreadTaskRunner* task_runner,
int max_pending_swaps);
~DisplayScheduler() override;
@@ -56,7 +56,7 @@ class CC_SURFACES_EXPORT DisplayScheduler : public BeginFrameObserverBase {
DisplaySchedulerClient* client_;
BeginFrameSource* begin_frame_source_;
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ base::SingleThreadTaskRunner* task_runner_;
BeginFrameArgs current_begin_frame_args_;
base::Closure begin_frame_deadline_closure_;
diff --git a/cc/surfaces/display_scheduler_unittest.cc b/cc/surfaces/display_scheduler_unittest.cc
index 2309b0a..43a0c9a 100644
--- a/cc/surfaces/display_scheduler_unittest.cc
+++ b/cc/surfaces/display_scheduler_unittest.cc
@@ -16,6 +16,8 @@
namespace cc {
namespace {
+const int kMaxPendingSwaps = 1;
+
class FakeDisplaySchedulerClient : public DisplaySchedulerClient {
public:
FakeDisplaySchedulerClient() : draw_and_swap_count_(0) {}
@@ -39,7 +41,7 @@ class TestDisplayScheduler : public DisplayScheduler {
public:
TestDisplayScheduler(DisplaySchedulerClient* client,
BeginFrameSource* begin_frame_source,
- scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ base::SingleThreadTaskRunner* task_runner,
int max_pending_swaps)
: DisplayScheduler(client,
begin_frame_source,
@@ -68,14 +70,15 @@ class TestDisplayScheduler : public DisplayScheduler {
class DisplaySchedulerTest : public testing::Test {
public:
- DisplaySchedulerTest() : now_src_(new base::SimpleTestTickClock()) {
- const int max_pending_swaps = 1;
+ DisplaySchedulerTest()
+ : now_src_(new base::SimpleTestTickClock()),
+ task_runner_(new base::NullTaskRunner),
+ client_(new FakeDisplaySchedulerClient),
+ scheduler_(new TestDisplayScheduler(client_.get(),
+ &fake_begin_frame_source_,
+ task_runner_.get(),
+ kMaxPendingSwaps)) {
now_src_->Advance(base::TimeDelta::FromMicroseconds(10000));
- null_task_runner_ = make_scoped_refptr(new base::NullTaskRunner);
- client_ = make_scoped_ptr(new FakeDisplaySchedulerClient);
- scheduler_ = make_scoped_ptr(
- new TestDisplayScheduler(client_.get(), &fake_begin_frame_source_,
- null_task_runner_, max_pending_swaps));
}
~DisplaySchedulerTest() override {}
@@ -96,10 +99,10 @@ class DisplaySchedulerTest : public testing::Test {
FakeDisplaySchedulerClient& client() { return *client_; }
DisplayScheduler& scheduler() { return *scheduler_; }
- scoped_ptr<base::SimpleTestTickClock> now_src_;
- scoped_refptr<base::NullTaskRunner> null_task_runner_;
-
FakeBeginFrameSource fake_begin_frame_source_;
+
+ scoped_ptr<base::SimpleTestTickClock> now_src_;
+ scoped_refptr<base::NullTaskRunner> task_runner_;
scoped_ptr<FakeDisplaySchedulerClient> client_;
scoped_ptr<TestDisplayScheduler> scheduler_;
};
diff --git a/cc/surfaces/display_unittest.cc b/cc/surfaces/display_unittest.cc
index c021390..93ff0f8 100644
--- a/cc/surfaces/display_unittest.cc
+++ b/cc/surfaces/display_unittest.cc
@@ -33,7 +33,9 @@ class EmptySurfaceFactoryClient : public SurfaceFactoryClient {
class DisplayTest : public testing::Test {
public:
- DisplayTest() : factory_(&manager_, &empty_client_) {}
+ DisplayTest()
+ : factory_(&manager_, &empty_client_),
+ task_runner_(new base::NullTaskRunner) {}
protected:
void SetUpContext(scoped_ptr<TestWebGraphicsContext3D> context) {
@@ -65,6 +67,7 @@ class DisplayTest : public testing::Test {
scoped_ptr<FakeOutputSurface> output_surface_;
FakeOutputSurface* output_surface_ptr_;
FakeBeginFrameSource fake_begin_frame_source_;
+ scoped_refptr<base::NullTaskRunner> task_runner_;
scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
};
@@ -82,11 +85,9 @@ class TestDisplayClient : public DisplayClient {
class TestDisplayScheduler : public DisplayScheduler {
public:
TestDisplayScheduler(DisplaySchedulerClient* client,
- BeginFrameSource* begin_frame_source)
- : DisplayScheduler(client,
- begin_frame_source,
- make_scoped_refptr(new base::NullTaskRunner),
- 1),
+ BeginFrameSource* begin_frame_source,
+ base::NullTaskRunner* task_runner)
+ : DisplayScheduler(client, begin_frame_source, task_runner, 1),
damaged(false),
entire_display_damaged(false),
swapped(false) {}
@@ -128,7 +129,8 @@ TEST_F(DisplayTest, DisplayDamaged) {
Display display(&client, &manager_, shared_bitmap_manager_.get(), nullptr,
settings);
- TestDisplayScheduler scheduler(&display, &fake_begin_frame_source_);
+ TestDisplayScheduler scheduler(&display, &fake_begin_frame_source_,
+ task_runner_.get());
display.Initialize(output_surface_.Pass(), &scheduler);
SurfaceId surface_id(7u);
@@ -335,7 +337,8 @@ TEST_F(DisplayTest, Finish) {
Display display(&client, &manager_, shared_bitmap_manager_.get(), nullptr,
settings);
- TestDisplayScheduler scheduler(&display, &fake_begin_frame_source_);
+ TestDisplayScheduler scheduler(&display, &fake_begin_frame_source_,
+ task_runner_.get());
display.Initialize(output_surface_.Pass(), &scheduler);
SurfaceId surface_id(7u);
diff --git a/cc/surfaces/onscreen_display_client.cc b/cc/surfaces/onscreen_display_client.cc
index 46e8cb6..2bd58fe 100644
--- a/cc/surfaces/onscreen_display_client.cc
+++ b/cc/surfaces/onscreen_display_client.cc
@@ -52,8 +52,8 @@ bool OnscreenDisplayClient::Initialize() {
frame_source = synthetic_frame_source_.get();
}
- scheduler_.reset(new DisplayScheduler(display_.get(), frame_source,
- task_runner_, max_frames_pending));
+ scheduler_.reset(new DisplayScheduler(
+ display_.get(), frame_source, task_runner_.get(), max_frames_pending));
return display_->Initialize(output_surface_.Pass(), scheduler_.get());
}
diff --git a/cc/test/scheduler_test_common.cc b/cc/test/scheduler_test_common.cc
index ee00faa..31272dd 100644
--- a/cc/test/scheduler_test_common.cc
+++ b/cc/test/scheduler_test_common.cc
@@ -70,15 +70,15 @@ scoped_ptr<TestScheduler> TestScheduler::Create(
SchedulerClient* client,
const SchedulerSettings& settings,
int layer_tree_host_id,
- const scoped_refptr<OrderedSimpleTaskRunner>& task_runner,
+ OrderedSimpleTaskRunner* task_runner,
BeginFrameSource* external_frame_source) {
scoped_ptr<TestSyntheticBeginFrameSource> synthetic_frame_source;
if (!settings.use_external_begin_frame_source) {
synthetic_frame_source = TestSyntheticBeginFrameSource::Create(
- now_src, task_runner.get(), BeginFrameArgs::DefaultInterval());
+ now_src, task_runner, BeginFrameArgs::DefaultInterval());
}
scoped_ptr<TestBackToBackBeginFrameSource> unthrottled_frame_source =
- TestBackToBackBeginFrameSource::Create(now_src, task_runner.get());
+ TestBackToBackBeginFrameSource::Create(now_src, task_runner);
return make_scoped_ptr(new TestScheduler(
now_src, client, settings, layer_tree_host_id, task_runner,
external_frame_source, synthetic_frame_source.Pass(),
@@ -90,7 +90,7 @@ TestScheduler::TestScheduler(
SchedulerClient* client,
const SchedulerSettings& scheduler_settings,
int layer_tree_host_id,
- const scoped_refptr<OrderedSimpleTaskRunner>& task_runner,
+ OrderedSimpleTaskRunner* task_runner,
BeginFrameSource* external_frame_source,
scoped_ptr<TestSyntheticBeginFrameSource> synthetic_frame_source,
scoped_ptr<TestBackToBackBeginFrameSource> unthrottled_frame_source)
diff --git a/cc/test/scheduler_test_common.h b/cc/test/scheduler_test_common.h
index a99cbaf..a1ab922 100644
--- a/cc/test/scheduler_test_common.h
+++ b/cc/test/scheduler_test_common.h
@@ -166,7 +166,7 @@ class TestScheduler : public Scheduler {
SchedulerClient* client,
const SchedulerSettings& scheduler_settings,
int layer_tree_host_id,
- const scoped_refptr<OrderedSimpleTaskRunner>& task_runner,
+ OrderedSimpleTaskRunner* task_runner,
BeginFrameSource* external_frame_source);
// Extra test helper functionality
@@ -195,7 +195,7 @@ class TestScheduler : public Scheduler {
SchedulerClient* client,
const SchedulerSettings& scheduler_settings,
int layer_tree_host_id,
- const scoped_refptr<OrderedSimpleTaskRunner>& task_runner,
+ OrderedSimpleTaskRunner* task_runner,
BeginFrameSource* external_frame_source,
scoped_ptr<TestSyntheticBeginFrameSource> synthetic_frame_source,
scoped_ptr<TestBackToBackBeginFrameSource> unthrottled_frame_source);