diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-20 18:26:15 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-20 18:26:15 +0000 |
commit | 810d40b7969be4da75695a82699e3c8620ac4b66 (patch) | |
tree | 2f7f78b7210edb0cfa0bacadfec1943fd3740076 /cc/test | |
parent | fe218424336071b7e1aaadb20f1e236d34c635de (diff) | |
download | chromium_src-810d40b7969be4da75695a82699e3c8620ac4b66.zip chromium_src-810d40b7969be4da75695a82699e3c8620ac4b66.tar.gz chromium_src-810d40b7969be4da75695a82699e3c8620ac4b66.tar.bz2 |
cc: Remove cc::Thread and cc::ThreadImpl.
These classes are replaced by using base::SingleThreadTaskRunner
directly.
R=piman,jamesr
BUG=251134
Depends on: https://codereview.chromium.org/17362002/
Review URL: https://chromiumcodereview.appspot.com/17114008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207491 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test')
-rw-r--r-- | cc/test/fake_impl_proxy.h | 2 | ||||
-rw-r--r-- | cc/test/fake_proxy.h | 8 | ||||
-rw-r--r-- | cc/test/layer_tree_test.cc | 62 | ||||
-rw-r--r-- | cc/test/layer_tree_test.h | 8 | ||||
-rw-r--r-- | cc/test/scheduler_test_common.h | 1 |
5 files changed, 47 insertions, 34 deletions
diff --git a/cc/test/fake_impl_proxy.h b/cc/test/fake_impl_proxy.h index 777da4a..b52fea4 100644 --- a/cc/test/fake_impl_proxy.h +++ b/cc/test/fake_impl_proxy.h @@ -12,7 +12,7 @@ namespace cc { class FakeImplProxy : public FakeProxy { public: - FakeImplProxy() : FakeProxy(scoped_ptr<Thread>()), set_impl_thread_(this) {} + FakeImplProxy() : set_impl_thread_(this) {} private: DebugScopedSetImplThread set_impl_thread_; diff --git a/cc/test/fake_proxy.h b/cc/test/fake_proxy.h index b806df4..3f7df44 100644 --- a/cc/test/fake_proxy.h +++ b/cc/test/fake_proxy.h @@ -5,7 +5,7 @@ #ifndef CC_TEST_FAKE_PROXY_H_ #define CC_TEST_FAKE_PROXY_H_ -#include "cc/base/thread.h" +#include "base/single_thread_task_runner.h" #include "cc/trees/layer_tree_host.h" #include "cc/trees/proxy.h" @@ -13,8 +13,10 @@ namespace cc { class FakeProxy : public Proxy { public: - explicit FakeProxy(scoped_ptr<Thread> impl_thread) - : Proxy(impl_thread.Pass()), + FakeProxy() : Proxy(NULL), layer_tree_host_(NULL) {} + explicit FakeProxy( + scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) + : Proxy(impl_task_runner), layer_tree_host_(NULL) {} void SetLayerTreeHost(LayerTreeHost* host); diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index b6f47ab..df47b3d 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc @@ -10,7 +10,6 @@ #include "cc/animation/layer_animation_controller.h" #include "cc/animation/timing_function.h" #include "cc/base/switches.h" -#include "cc/base/thread_impl.h" #include "cc/input/input_handler.h" #include "cc/layers/content_layer.h" #include "cc/layers/layer.h" @@ -179,10 +178,10 @@ class LayerTreeHostForTesting : public cc::LayerTreeHost { TestHooks* test_hooks, cc::LayerTreeHostClient* host_client, const cc::LayerTreeSettings& settings, - scoped_ptr<cc::Thread> impl_thread) { + scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { scoped_ptr<LayerTreeHostForTesting> layer_tree_host( new LayerTreeHostForTesting(test_hooks, host_client, settings)); - bool success = layer_tree_host->Initialize(impl_thread.Pass()); + bool success = layer_tree_host->Initialize(impl_task_runner); EXPECT_TRUE(success); return layer_tree_host.Pass(); } @@ -325,19 +324,22 @@ void LayerTreeTest::EndTest() { } else if (proxy()) { // Racy timeouts and explicit EndTest calls might have cleaned up // the tree host. Should check proxy first. - proxy()->MainThread()->PostTask( + proxy()->MainThreadTaskRunner()->PostTask( + FROM_HERE, base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); } } void LayerTreeTest::EndTestAfterDelay(int delay_milliseconds) { - proxy()->MainThread()->PostTask( + proxy()->MainThreadTaskRunner()->PostTask( + FROM_HERE, base::Bind(&LayerTreeTest::EndTest, main_thread_weak_ptr_)); } void LayerTreeTest::PostAddAnimationToMainThread( Layer* layer_to_receive_animation) { - proxy()->MainThread()->PostTask( + proxy()->MainThreadTaskRunner()->PostTask( + FROM_HERE, base::Bind(&LayerTreeTest::DispatchAddAnimation, main_thread_weak_ptr_, base::Unretained(layer_to_receive_animation))); @@ -345,38 +347,44 @@ void LayerTreeTest::PostAddAnimationToMainThread( void LayerTreeTest::PostAddInstantAnimationToMainThread( Layer* layer_to_receive_animation) { - proxy()->MainThread()->PostTask( + proxy()->MainThreadTaskRunner()->PostTask( + FROM_HERE, base::Bind(&LayerTreeTest::DispatchAddInstantAnimation, main_thread_weak_ptr_, base::Unretained(layer_to_receive_animation))); } void LayerTreeTest::PostSetNeedsCommitToMainThread() { - proxy()->MainThread()->PostTask( + proxy()->MainThreadTaskRunner()->PostTask( + FROM_HERE, base::Bind(&LayerTreeTest::DispatchSetNeedsCommit, main_thread_weak_ptr_)); } void LayerTreeTest::PostAcquireLayerTextures() { - proxy()->MainThread()->PostTask( + proxy()->MainThreadTaskRunner()->PostTask( + FROM_HERE, base::Bind(&LayerTreeTest::DispatchAcquireLayerTextures, main_thread_weak_ptr_)); } void LayerTreeTest::PostSetNeedsRedrawToMainThread() { - proxy()->MainThread()->PostTask( + proxy()->MainThreadTaskRunner()->PostTask( + FROM_HERE, base::Bind(&LayerTreeTest::DispatchSetNeedsRedraw, main_thread_weak_ptr_)); } void LayerTreeTest::PostSetNeedsRedrawRectToMainThread(gfx::Rect damage_rect) { - proxy()->MainThread()->PostTask( + proxy()->MainThreadTaskRunner()->PostTask( + FROM_HERE, base::Bind(&LayerTreeTest::DispatchSetNeedsRedrawRect, main_thread_weak_ptr_, damage_rect)); } void LayerTreeTest::PostSetVisibleToMainThread(bool visible) { - proxy()->MainThread()->PostTask( + proxy()->MainThreadTaskRunner()->PostTask( + FROM_HERE, base::Bind(&LayerTreeTest::DispatchSetVisible, main_thread_weak_ptr_, visible)); @@ -385,15 +393,12 @@ void LayerTreeTest::PostSetVisibleToMainThread(bool visible) { void LayerTreeTest::DoBeginTest() { client_ = LayerTreeHostClientForTesting::Create(this); - scoped_ptr<cc::Thread> impl_ccthread; - if (impl_thread_) { - impl_ccthread = cc::ThreadImpl::CreateForDifferentThread( - impl_thread_->message_loop_proxy()); - } - layer_tree_host_ = LayerTreeHostForTesting::Create(this, - client_.get(), - settings_, - impl_ccthread.Pass()); + DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy()); + layer_tree_host_ = LayerTreeHostForTesting::Create( + this, + client_.get(), + settings_, + impl_thread_ ? impl_thread_->message_loop_proxy() : NULL); ASSERT_TRUE(layer_tree_host_); started_ = true; @@ -439,7 +444,8 @@ void LayerTreeTest::ScheduleComposite() { if (!started_ || scheduled_) return; scheduled_ = true; - proxy()->MainThread()->PostTask( + proxy()->MainThreadTaskRunner()->PostTask( + FROM_HERE, base::Bind(&LayerTreeTest::DispatchComposite, main_thread_weak_ptr_)); } @@ -447,7 +453,8 @@ void LayerTreeTest::RealEndTest() { ended_ = true; if (layer_tree_host_ && proxy()->CommitPendingForTesting()) { - proxy()->MainThread()->PostTask( + proxy()->MainThreadTaskRunner()->PostTask( + FROM_HERE, base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); return; } @@ -548,7 +555,8 @@ void LayerTreeTest::RunTest(bool threaded, ASSERT_TRUE(impl_thread_->Start()); } - main_ccthread_ = cc::ThreadImpl::CreateForCurrentThread(); + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_ = + base::MessageLoopProxy::current(); delegating_renderer_ = delegating_renderer; @@ -562,12 +570,14 @@ void LayerTreeTest::RunTest(bool threaded, } InitializeSettings(&settings_); - main_ccthread_->PostTask( + main_task_runner_->PostTask( + FROM_HERE, base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this))); if (timeout_seconds_) { timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this))); - main_ccthread_->PostDelayedTask( + main_task_runner_->PostDelayedTask( + FROM_HERE, timeout_.callback(), base::TimeDelta::FromSeconds(timeout_seconds_)); } diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h index 2d67a44..ba33b6e 100644 --- a/cc/test/layer_tree_test.h +++ b/cc/test/layer_tree_test.h @@ -7,7 +7,6 @@ #include "base/memory/ref_counted.h" #include "base/threading/thread.h" -#include "cc/base/thread.h" #include "cc/trees/layer_tree_host.h" #include "cc/trees/layer_tree_host_impl.h" #include "testing/gtest/include/gtest/gtest.h" @@ -141,7 +140,10 @@ class LayerTreeTest : public testing::Test, public TestHooks { bool delegating_renderer, bool impl_side_painting); - Thread* ImplThread() { return proxy() ? proxy()->ImplThread() : NULL; } + bool HasImplThread() { return proxy() ? proxy()->HasImplThread() : false; } + base::SingleThreadTaskRunner* ImplThreadTaskRunner() { + return proxy() ? proxy()->ImplThreadTaskRunner() : NULL; + } Proxy* proxy() const { return layer_tree_host_ ? layer_tree_host_->proxy() : NULL; } @@ -174,7 +176,7 @@ class LayerTreeTest : public testing::Test, public TestHooks { int timeout_seconds_; - scoped_ptr<Thread> main_ccthread_; + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; scoped_ptr<base::Thread> impl_thread_; base::CancelableClosure timeout_; base::WeakPtr<LayerTreeTest> main_thread_weak_ptr_; diff --git a/cc/test/scheduler_test_common.h b/cc/test/scheduler_test_common.h index e268020..ad8927d 100644 --- a/cc/test/scheduler_test_common.h +++ b/cc/test/scheduler_test_common.h @@ -8,7 +8,6 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/time.h" -#include "cc/base/thread.h" #include "cc/scheduler/delay_based_time_source.h" #include "cc/scheduler/frame_rate_controller.h" #include "testing/gtest/include/gtest/gtest.h" |