summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-20 18:26:15 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-20 18:26:15 +0000
commit5f2e9479e588a54fcbd55c8e153f5509eb5efb4c (patch)
tree2f7f78b7210edb0cfa0bacadfec1943fd3740076 /cc
parentcdc2847126f9a2d23059612d71b47285df1c8602 (diff)
downloadchromium_src-5f2e9479e588a54fcbd55c8e153f5509eb5efb4c.zip
chromium_src-5f2e9479e588a54fcbd55c8e153f5509eb5efb4c.tar.gz
chromium_src-5f2e9479e588a54fcbd55c8e153f5509eb5efb4c.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')
-rw-r--r--cc/base/thread.h36
-rw-r--r--cc/base/thread_impl.cc42
-rw-r--r--cc/base/thread_impl.h44
-rw-r--r--cc/cc.gyp3
-rw-r--r--cc/layers/delegated_renderer_layer_impl_unittest.cc2
-rw-r--r--cc/layers/layer.cc21
-rw-r--r--cc/layers/layer_unittest.cc9
-rw-r--r--cc/layers/nine_patch_layer_unittest.cc3
-rw-r--r--cc/layers/scrollbar_layer_unittest.cc2
-rw-r--r--cc/layers/texture_layer.cc1
-rw-r--r--cc/layers/texture_layer_unittest.cc3
-rw-r--r--cc/layers/tiled_layer_unittest.cc7
-rw-r--r--cc/resources/prioritized_resource_unittest.cc3
-rw-r--r--cc/resources/resource_update_controller_unittest.cc4
-rw-r--r--cc/scheduler/rate_limiter.cc14
-rw-r--r--cc/scheduler/rate_limiter.h10
-rw-r--r--cc/scheduler/scheduler.cc1
-rw-r--r--cc/test/fake_impl_proxy.h2
-rw-r--r--cc/test/fake_proxy.h8
-rw-r--r--cc/test/layer_tree_test.cc62
-rw-r--r--cc/test/layer_tree_test.h8
-rw-r--r--cc/test/scheduler_test_common.h1
-rw-r--r--cc/trees/layer_tree_host.cc19
-rw-r--r--cc/trees/layer_tree_host.h9
-rw-r--r--cc/trees/layer_tree_host_common_unittest.cc1
-rw-r--r--cc/trees/layer_tree_host_impl.cc11
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc2
-rw-r--r--cc/trees/layer_tree_host_unittest.cc33
-rw-r--r--cc/trees/layer_tree_host_unittest_context.cc22
-rw-r--r--cc/trees/layer_tree_host_unittest_scroll.cc10
-rw-r--r--cc/trees/proxy.cc37
-rw-r--r--cc/trees/proxy.h19
-rw-r--r--cc/trees/single_thread_proxy.cc5
-rw-r--r--cc/trees/thread_proxy.cc156
-rw-r--r--cc/trees/thread_proxy.h11
-rw-r--r--cc/trees/tree_synchronizer_unittest.cc2
36 files changed, 276 insertions, 347 deletions
diff --git a/cc/base/thread.h b/cc/base/thread.h
deleted file mode 100644
index 296f70e..0000000
--- a/cc/base/thread.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CC_BASE_THREAD_H_
-#define CC_BASE_THREAD_H_
-
-#include "base/basictypes.h"
-#include "base/callback.h"
-#include "base/time.h"
-#include "cc/base/cc_export.h"
-
-namespace base { class SingleThreadTaskRunner; }
-
-namespace cc {
-
-// Thread provides basic infrastructure for messaging with the compositor in a
-// platform-neutral way.
-class CC_EXPORT Thread {
- public:
- virtual ~Thread() {}
-
- // Executes the callback on context's thread asynchronously.
- virtual void PostTask(base::Closure cb) = 0;
-
- // Executes the task after the specified delay.
- virtual void PostDelayedTask(base::Closure cb, base::TimeDelta delay) = 0;
-
- virtual bool BelongsToCurrentThread() const = 0;
-
- virtual base::SingleThreadTaskRunner* TaskRunner() = 0;
-};
-
-} // namespace cc
-
-#endif // CC_BASE_THREAD_H_
diff --git a/cc/base/thread_impl.cc b/cc/base/thread_impl.cc
deleted file mode 100644
index c76213d..0000000
--- a/cc/base/thread_impl.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "cc/base/thread_impl.h"
-
-#include "base/message_loop.h"
-
-namespace cc {
-
-scoped_ptr<Thread> ThreadImpl::CreateForCurrentThread() {
- return scoped_ptr<Thread>(
- new ThreadImpl(base::MessageLoopProxy::current())).Pass();
-}
-
-scoped_ptr<Thread> ThreadImpl::CreateForDifferentThread(
- scoped_refptr<base::MessageLoopProxy> thread) {
- return scoped_ptr<Thread>(new ThreadImpl(thread)).Pass();
-}
-
-ThreadImpl::~ThreadImpl() {}
-
-void ThreadImpl::PostTask(base::Closure cb) {
- thread_->PostTask(FROM_HERE, cb);
-}
-
-void ThreadImpl::PostDelayedTask(base::Closure cb, base::TimeDelta delay) {
- thread_->PostDelayedTask(FROM_HERE, cb, delay);
-}
-
-bool ThreadImpl::BelongsToCurrentThread() const {
- return thread_->BelongsToCurrentThread();
-}
-
-base::SingleThreadTaskRunner* ThreadImpl::TaskRunner() {
- return thread_.get();
-}
-
-ThreadImpl::ThreadImpl(scoped_refptr<base::MessageLoopProxy> thread)
- : thread_(thread) {}
-
-} // namespace cc
diff --git a/cc/base/thread_impl.h b/cc/base/thread_impl.h
deleted file mode 100644
index 9bc47a8..0000000
--- a/cc/base/thread_impl.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CC_BASE_THREAD_IMPL_H_
-#define CC_BASE_THREAD_IMPL_H_
-
-#include "base/callback.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "cc/base/cc_export.h"
-#include "cc/base/thread.h"
-
-namespace cc {
-
-// Implements cc::Thread in terms of base::MessageLoopProxy.
-class CC_EXPORT ThreadImpl : public Thread {
- public:
- // Creates a ThreadImpl wrapping the current thread.
- static scoped_ptr<cc::Thread> CreateForCurrentThread();
-
- // Creates a Thread wrapping a non-current thread.
- static scoped_ptr<cc::Thread> CreateForDifferentThread(
- scoped_refptr<base::MessageLoopProxy> thread);
-
- virtual ~ThreadImpl();
-
- virtual void PostTask(base::Closure cb) OVERRIDE;
- virtual void PostDelayedTask(base::Closure cb, base::TimeDelta delay)
- OVERRIDE;
- virtual bool BelongsToCurrentThread() const OVERRIDE;
- virtual base::SingleThreadTaskRunner* TaskRunner() OVERRIDE;
-
- private:
- explicit ThreadImpl(scoped_refptr<base::MessageLoopProxy> thread);
-
- scoped_refptr<base::MessageLoopProxy> thread_;
-
- DISALLOW_COPY_AND_ASSIGN(ThreadImpl);
-};
-
-} // namespace cc
-
-#endif // CC_BASE_THREAD_IMPL_H_
diff --git a/cc/cc.gyp b/cc/cc.gyp
index 0d344ac..d3f0cf1 100644
--- a/cc/cc.gyp
+++ b/cc/cc.gyp
@@ -42,9 +42,6 @@
'base/scoped_ptr_vector.h',
'base/switches.cc',
'base/switches.h',
- 'base/thread.h',
- 'base/thread_impl.cc',
- 'base/thread_impl.h',
'base/tiling_data.cc',
'base/tiling_data.h',
'base/util.h',
diff --git a/cc/layers/delegated_renderer_layer_impl_unittest.cc b/cc/layers/delegated_renderer_layer_impl_unittest.cc
index 6d8d383..6592a31 100644
--- a/cc/layers/delegated_renderer_layer_impl_unittest.cc
+++ b/cc/layers/delegated_renderer_layer_impl_unittest.cc
@@ -33,7 +33,7 @@ namespace {
class DelegatedRendererLayerImplTest : public testing::Test {
public:
DelegatedRendererLayerImplTest()
- : proxy_(scoped_ptr<Thread>()),
+ : proxy_(),
always_impl_thread_and_main_thread_blocked_(&proxy_) {
LayerTreeSettings settings;
settings.minimum_occlusion_tracking_size = gfx::Size();
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index e1354b9..bdcbc75 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -6,11 +6,12 @@
#include <algorithm>
+#include "base/location.h"
#include "base/metrics/histogram.h"
+#include "base/single_thread_task_runner.h"
#include "cc/animation/animation.h"
#include "cc/animation/animation_events.h"
#include "cc/animation/layer_animation_controller.h"
-#include "cc/base/thread.h"
#include "cc/layers/layer_impl.h"
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
@@ -657,12 +658,14 @@ static void RunCopyCallbackOnMainThread(scoped_ptr<CopyOutputRequest> request,
request->SendResult(result.Pass());
}
-static void PostCopyCallbackToMainThread(Thread* main_thread,
- scoped_ptr<CopyOutputRequest> request,
- scoped_ptr<CopyOutputResult> result) {
- main_thread->PostTask(base::Bind(&RunCopyCallbackOnMainThread,
- base::Passed(&request),
- base::Passed(&result)));
+static void PostCopyCallbackToMainThread(
+ scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner,
+ scoped_ptr<CopyOutputRequest> request,
+ scoped_ptr<CopyOutputResult> result) {
+ main_thread_task_runner->PostTask(FROM_HERE,
+ base::Bind(&RunCopyCallbackOnMainThread,
+ base::Passed(&request),
+ base::Passed(&result)));
}
void Layer::PushPropertiesTo(LayerImpl* layer) {
@@ -712,13 +715,15 @@ void Layer::PushPropertiesTo(LayerImpl* layer) {
for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin();
it != copy_requests_.end();
++it) {
+ scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner =
+ layer_tree_host()->proxy()->MainThreadTaskRunner();
scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it);
const CopyOutputRequest& original_request_ref = *original_request;
scoped_ptr<CopyOutputRequest> main_thread_request =
CopyOutputRequest::CreateRelayRequest(
original_request_ref,
base::Bind(&PostCopyCallbackToMainThread,
- layer_tree_host()->proxy()->MainThread(),
+ main_thread_task_runner,
base::Passed(&original_request)));
main_thread_copy_requests.push_back(main_thread_request.Pass());
}
diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc
index 0a3f607..daf4589 100644
--- a/cc/layers/layer_unittest.cc
+++ b/cc/layers/layer_unittest.cc
@@ -6,7 +6,6 @@
#include "cc/animation/keyframed_animation_curve.h"
#include "cc/base/math_util.h"
-#include "cc/base/thread.h"
#include "cc/layers/layer_impl.h"
#include "cc/resources/layer_painter.h"
#include "cc/test/animation_test_common.h"
@@ -41,7 +40,7 @@ class MockLayerTreeHost : public LayerTreeHost {
public:
explicit MockLayerTreeHost(LayerTreeHostClient* client)
: LayerTreeHost(client, LayerTreeSettings()) {
- Initialize(scoped_ptr<Thread>());
+ Initialize(NULL);
}
MOCK_METHOD0(SetNeedsCommit, void());
@@ -734,13 +733,11 @@ class LayerTreeHostFactory {
: client_(FakeLayerTreeHostClient::DIRECT_3D) {}
scoped_ptr<LayerTreeHost> Create() {
- return LayerTreeHost::Create(
- &client_, LayerTreeSettings(), scoped_ptr<Thread>()).Pass();
+ return LayerTreeHost::Create(&client_, LayerTreeSettings(), NULL).Pass();
}
scoped_ptr<LayerTreeHost> Create(LayerTreeSettings settings) {
- return LayerTreeHost::Create(&client_, settings, scoped_ptr<Thread>())
- .Pass();
+ return LayerTreeHost::Create(&client_, settings, NULL).Pass();
}
private:
diff --git a/cc/layers/nine_patch_layer_unittest.cc b/cc/layers/nine_patch_layer_unittest.cc
index 1221f18..69edc2c 100644
--- a/cc/layers/nine_patch_layer_unittest.cc
+++ b/cc/layers/nine_patch_layer_unittest.cc
@@ -4,7 +4,6 @@
#include "cc/layers/nine_patch_layer.h"
-#include "cc/base/thread.h"
#include "cc/debug/overdraw_metrics.h"
#include "cc/resources/prioritized_resource_manager.h"
#include "cc/resources/resource_provider.h"
@@ -32,7 +31,7 @@ class MockLayerTreeHost : public LayerTreeHost {
public:
explicit MockLayerTreeHost(LayerTreeHostClient* client)
: LayerTreeHost(client, LayerTreeSettings()) {
- Initialize(scoped_ptr<Thread>());
+ Initialize(NULL);
}
};
diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc
index e7d2283..aa97294 100644
--- a/cc/layers/scrollbar_layer_unittest.cc
+++ b/cc/layers/scrollbar_layer_unittest.cc
@@ -420,7 +420,7 @@ class MockLayerTreeHost : public LayerTreeHost {
MockLayerTreeHost(LayerTreeHostClient* client,
const LayerTreeSettings& settings)
: LayerTreeHost(client, settings) {
- Initialize(scoped_ptr<Thread>());
+ Initialize(NULL);
}
};
diff --git a/cc/layers/texture_layer.cc b/cc/layers/texture_layer.cc
index 7dc0acf..25b9b8f 100644
--- a/cc/layers/texture_layer.cc
+++ b/cc/layers/texture_layer.cc
@@ -7,7 +7,6 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "cc/base/thread.h"
#include "cc/layers/texture_layer_client.h"
#include "cc/layers/texture_layer_impl.h"
#include "cc/trees/layer_tree_host.h"
diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc
index d6201fa..ee4f469 100644
--- a/cc/layers/texture_layer_unittest.cc
+++ b/cc/layers/texture_layer_unittest.cc
@@ -7,7 +7,6 @@
#include <string>
#include "base/callback.h"
-#include "cc/base/thread.h"
#include "cc/layers/texture_layer_client.h"
#include "cc/layers/texture_layer_impl.h"
#include "cc/test/fake_impl_proxy.h"
@@ -33,7 +32,7 @@ class MockLayerTreeHost : public LayerTreeHost {
public:
explicit MockLayerTreeHost(LayerTreeHostClient* client)
: LayerTreeHost(client, LayerTreeSettings()) {
- Initialize(scoped_ptr<Thread>());
+ Initialize(NULL);
}
MOCK_METHOD0(AcquireLayerTextures, void());
diff --git a/cc/layers/tiled_layer_unittest.cc b/cc/layers/tiled_layer_unittest.cc
index c3d8d28..ae07e40 100644
--- a/cc/layers/tiled_layer_unittest.cc
+++ b/cc/layers/tiled_layer_unittest.cc
@@ -56,8 +56,9 @@ class TiledLayerTest : public testing::Test {
}
virtual void SetUp() {
- layer_tree_host_ = LayerTreeHost::Create(
- &fake_layer_impl_tree_host_client_, settings_, scoped_ptr<Thread>());
+ layer_tree_host_ = LayerTreeHost::Create(&fake_layer_impl_tree_host_client_,
+ settings_,
+ NULL);
proxy_ = layer_tree_host_->proxy();
resource_manager_ = PrioritizedResourceManager::Create(proxy_);
layer_tree_host_->InitializeOutputSurfaceIfNeeded();
@@ -97,7 +98,7 @@ class TiledLayerTest : public testing::Test {
DCHECK(queue_);
scoped_ptr<ResourceUpdateController> update_controller =
ResourceUpdateController::Create(NULL,
- NULL,
+ proxy_->ImplThreadTaskRunner(),
queue_.Pass(),
resource_provider_.get());
update_controller->Finalize();
diff --git a/cc/resources/prioritized_resource_unittest.cc b/cc/resources/prioritized_resource_unittest.cc
index 09f55aa..92ce9ff 100644
--- a/cc/resources/prioritized_resource_unittest.cc
+++ b/cc/resources/prioritized_resource_unittest.cc
@@ -17,8 +17,7 @@ namespace cc {
class PrioritizedResourceTest : public testing::Test {
public:
PrioritizedResourceTest()
- : proxy_(scoped_ptr<Thread>()),
- texture_size_(256, 256),
+ : texture_size_(256, 256),
texture_format_(GL_RGBA),
output_surface_(CreateFakeOutputSurface()) {
DebugScopedSetImplThread impl_thread(&proxy_);
diff --git a/cc/resources/resource_update_controller_unittest.cc b/cc/resources/resource_update_controller_unittest.cc
index 6196bd1..1060801 100644
--- a/cc/resources/resource_update_controller_unittest.cc
+++ b/cc/resources/resource_update_controller_unittest.cc
@@ -70,7 +70,7 @@ class WebGraphicsContext3DForUploadTest : public TestWebGraphicsContext3D {
class ResourceUpdateControllerTest : public Test {
public:
ResourceUpdateControllerTest()
- : proxy_(scoped_ptr<Thread>()),
+ : proxy_(),
queue_(make_scoped_ptr(new ResourceUpdateQueue)),
resource_manager_(PrioritizedResourceManager::Create(&proxy_)),
query_results_available_(0),
@@ -182,7 +182,7 @@ class ResourceUpdateControllerTest : public Test {
impl_thread_and_main_thread_blocked(&proxy_);
scoped_ptr<ResourceUpdateController> update_controller =
ResourceUpdateController::Create(NULL,
- NULL,
+ proxy_.ImplThreadTaskRunner(),
queue_.Pass(),
resource_provider_.get());
update_controller->Finalize();
diff --git a/cc/scheduler/rate_limiter.cc b/cc/scheduler/rate_limiter.cc
index f0d4431..68a152f 100644
--- a/cc/scheduler/rate_limiter.cc
+++ b/cc/scheduler/rate_limiter.cc
@@ -5,7 +5,8 @@
#include "cc/scheduler/rate_limiter.h"
#include "base/debug/trace_event.h"
-#include "cc/base/thread.h"
+#include "base/location.h"
+#include "base/single_thread_task_runner.h"
#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
namespace cc {
@@ -13,17 +14,17 @@ namespace cc {
scoped_refptr<RateLimiter> RateLimiter::Create(
WebKit::WebGraphicsContext3D* context,
RateLimiterClient* client,
- Thread* thread) {
- return make_scoped_refptr(new RateLimiter(context, client, thread));
+ base::SingleThreadTaskRunner* task_runner) {
+ return make_scoped_refptr(new RateLimiter(context, client, task_runner));
}
RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D* context,
RateLimiterClient* client,
- Thread* thread)
+ base::SingleThreadTaskRunner* task_runner)
: context_(context),
active_(false),
client_(client),
- thread_(thread) {
+ task_runner_(task_runner) {
DCHECK(context);
}
@@ -35,7 +36,8 @@ void RateLimiter::Start() {
TRACE_EVENT0("cc", "RateLimiter::Start");
active_ = true;
- thread_->PostTask(base::Bind(&RateLimiter::RateLimitContext, this));
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(&RateLimiter::RateLimitContext, this));
}
void RateLimiter::Stop() {
diff --git a/cc/scheduler/rate_limiter.h b/cc/scheduler/rate_limiter.h
index 0d2de38..04b9077 100644
--- a/cc/scheduler/rate_limiter.h
+++ b/cc/scheduler/rate_limiter.h
@@ -7,12 +7,12 @@
#include "base/memory/ref_counted.h"
+namespace base { class SingleThreadTaskRunner; }
+
namespace WebKit { class WebGraphicsContext3D; }
namespace cc {
-class Thread;
-
class RateLimiterClient {
public:
virtual void RateLimit() = 0;
@@ -31,7 +31,7 @@ class RateLimiter : public base::RefCounted<RateLimiter> {
static scoped_refptr<RateLimiter> Create(
WebKit::WebGraphicsContext3D* context,
RateLimiterClient* client,
- Thread* thread);
+ base::SingleThreadTaskRunner* task_runner);
void Start();
@@ -43,7 +43,7 @@ class RateLimiter : public base::RefCounted<RateLimiter> {
RateLimiter(WebKit::WebGraphicsContext3D* context,
RateLimiterClient* client,
- Thread* thread);
+ base::SingleThreadTaskRunner* task_runner);
~RateLimiter();
void RateLimitContext();
@@ -51,7 +51,7 @@ class RateLimiter : public base::RefCounted<RateLimiter> {
WebKit::WebGraphicsContext3D* context_;
bool active_;
RateLimiterClient* client_;
- Thread* thread_;
+ base::SingleThreadTaskRunner* task_runner_;
DISALLOW_COPY_AND_ASSIGN(RateLimiter);
};
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc
index d1997ea..757d746 100644
--- a/cc/scheduler/scheduler.cc
+++ b/cc/scheduler/scheduler.cc
@@ -7,7 +7,6 @@
#include "base/auto_reset.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
-#include "cc/base/thread.h"
namespace cc {
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"
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index 5e19eb3..2536646 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -17,7 +17,6 @@
#include "cc/animation/animation_registrar.h"
#include "cc/animation/layer_animation_controller.h"
#include "cc/base/math_util.h"
-#include "cc/base/thread.h"
#include "cc/debug/overdraw_metrics.h"
#include "cc/debug/rendering_stats_instrumentation.h"
#include "cc/input/top_controls_manager.h"
@@ -65,10 +64,10 @@ bool LayerTreeHost::AnyLayerTreeHostInstanceExists() {
scoped_ptr<LayerTreeHost> LayerTreeHost::Create(
LayerTreeHostClient* client,
const LayerTreeSettings& settings,
- scoped_ptr<Thread> impl_thread) {
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(client,
settings));
- if (!layer_tree_host->Initialize(impl_thread.Pass()))
+ if (!layer_tree_host->Initialize(impl_task_runner))
return scoped_ptr<LayerTreeHost>();
return layer_tree_host.Pass();
}
@@ -106,9 +105,10 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client,
debug_state_.RecordRenderingStats());
}
-bool LayerTreeHost::Initialize(scoped_ptr<Thread> impl_thread) {
- if (impl_thread)
- return InitializeProxy(ThreadProxy::Create(this, impl_thread.Pass()));
+bool LayerTreeHost::Initialize(
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
+ if (impl_task_runner)
+ return InitializeProxy(ThreadProxy::Create(this, impl_task_runner));
else
return InitializeProxy(SingleThreadProxy::Create(this));
}
@@ -485,7 +485,7 @@ void LayerTreeHost::SetNeedsRedraw() {
void LayerTreeHost::SetNeedsRedrawRect(gfx::Rect damage_rect) {
proxy_->SetNeedsRedraw(damage_rect);
- if (!proxy_->ImplThread())
+ if (!proxy_->HasImplThread())
client_->ScheduleComposite();
}
@@ -997,7 +997,7 @@ void LayerTreeHost::StartRateLimiter(WebKit::WebGraphicsContext3D* context3d) {
it->second->Start();
} else {
scoped_refptr<RateLimiter> rate_limiter =
- RateLimiter::Create(context3d, this, proxy_->MainThread());
+ RateLimiter::Create(context3d, this, proxy_->MainThreadTaskRunner());
rate_limiters_[context3d] = rate_limiter;
rate_limiter->Start();
}
@@ -1041,7 +1041,8 @@ void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints,
return;
// Top controls are only used in threaded mode.
- proxy_->ImplThread()->PostTask(
+ proxy_->ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&TopControlsManager::UpdateTopControlsState,
top_controls_manager_weak_ptr_,
constraints,
diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h
index 2c733fc..b3d004a 100644
--- a/cc/trees/layer_tree_host.h
+++ b/cc/trees/layer_tree_host.h
@@ -85,9 +85,10 @@ struct CC_EXPORT RendererCapabilities {
class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) {
public:
- static scoped_ptr<LayerTreeHost> Create(LayerTreeHostClient* client,
- const LayerTreeSettings& settings,
- scoped_ptr<Thread> impl_thread);
+ static scoped_ptr<LayerTreeHost> Create(
+ LayerTreeHostClient* client,
+ const LayerTreeSettings& settings,
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
virtual ~LayerTreeHost();
void SetLayerTreeHostClientReady();
@@ -261,7 +262,7 @@ class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) {
protected:
LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings);
- bool Initialize(scoped_ptr<Thread> impl_thread);
+ bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing);
private:
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index 8fa91ce..850768e 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -6,7 +6,6 @@
#include "cc/animation/layer_animation_controller.h"
#include "cc/base/math_util.h"
-#include "cc/base/thread.h"
#include "cc/layers/content_layer.h"
#include "cc/layers/content_layer_client.h"
#include "cc/layers/heads_up_display_layer_impl.h"
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index ffd48bf..bbae5e7 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -14,7 +14,6 @@
#include "cc/animation/scrollbar_animation_controller.h"
#include "cc/animation/timing_function.h"
#include "cc/base/math_util.h"
-#include "cc/base/thread.h"
#include "cc/base/util.h"
#include "cc/debug/debug_rect_history.h"
#include "cc/debug/frame_rate_counter.h"
@@ -768,6 +767,8 @@ void LayerTreeHostImpl::MainThreadHasStoppedFlinging() {
void LayerTreeHostImpl::UpdateBackgroundAnimateTicking(
bool should_background_tick) {
+ DCHECK(proxy_->IsImplThread());
+
bool enabled = should_background_tick &&
!animation_registrar_->active_animation_controllers().empty();
@@ -776,8 +777,10 @@ void LayerTreeHostImpl::UpdateBackgroundAnimateTicking(
if (!time_source_client_adapter_) {
time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create(
this,
- DelayBasedTimeSource::Create(LowFrequencyAnimationInterval(),
- proxy_->CurrentThread()->TaskRunner()));
+ DelayBasedTimeSource::Create(
+ LowFrequencyAnimationInterval(),
+ proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner()
+ : proxy_->MainThreadTaskRunner()));
}
time_source_client_adapter_->SetActive(enabled);
@@ -1539,7 +1542,7 @@ bool LayerTreeHostImpl::InitializeRenderer(
settings_.refresh_rate);
output_surface->InitializeBeginFrameEmulation(
- proxy_->ImplThread() ? proxy_->ImplThread()->TaskRunner() : NULL,
+ proxy_->ImplThreadTaskRunner(),
settings_.throttle_frame_production,
display_refresh_interval);
}
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 362f1f4..74aa4a0 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -62,7 +62,7 @@ class LayerTreeHostImplTest : public testing::Test,
public LayerTreeHostImplClient {
public:
LayerTreeHostImplTest()
- : proxy_(scoped_ptr<Thread>()),
+ : proxy_(),
always_impl_thread_(&proxy_),
always_main_thread_blocked_(&proxy_),
did_try_initialize_renderer_(false),
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index e8ea911..ed6dd2c 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -718,7 +718,7 @@ class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest {
// commit isn't required for updating the current frame time. We can
// only check for this in the multi-threaded case, since in the single-
// threaded case there will always be a commit between consecutive draws.
- if (ImplThread())
+ if (HasImplThread())
EXPECT_EQ(0, frame_);
}
@@ -1626,8 +1626,9 @@ class LayerTreeHostTestEvictTextures : public LayerTreeHostTest {
}
void PostEvictTextures() {
- DCHECK(ImplThread());
- ImplThread()->PostTask(
+ DCHECK(HasImplThread());
+ ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&LayerTreeHostTestEvictTextures::EvictTexturesOnImplThread,
base::Unretained(this)));
}
@@ -1880,8 +1881,7 @@ TEST(LayerTreeHostTest, LimitPartialUpdates) {
{
FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
- scoped_ptr<FakeProxy> proxy =
- make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>()));
+ scoped_ptr<FakeProxy> proxy(new FakeProxy);
proxy->GetRendererCapabilities().allow_partial_texture_updates = false;
proxy->SetMaxPartialTextureUpdates(5);
@@ -1899,8 +1899,7 @@ TEST(LayerTreeHostTest, LimitPartialUpdates) {
{
FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
- scoped_ptr<FakeProxy> proxy =
- make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>()));
+ scoped_ptr<FakeProxy> proxy(new FakeProxy);
proxy->GetRendererCapabilities().allow_partial_texture_updates = true;
proxy->SetMaxPartialTextureUpdates(5);
@@ -1918,8 +1917,7 @@ TEST(LayerTreeHostTest, LimitPartialUpdates) {
{
FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
- scoped_ptr<FakeProxy> proxy =
- make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>()));
+ scoped_ptr<FakeProxy> proxy(new FakeProxy);
proxy->GetRendererCapabilities().allow_partial_texture_updates = true;
proxy->SetMaxPartialTextureUpdates(20);
@@ -1940,7 +1938,7 @@ TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) {
settings.max_partial_texture_updates = 4;
scoped_ptr<LayerTreeHost> host =
- LayerTreeHost::Create(&client, settings, scoped_ptr<Thread>());
+ LayerTreeHost::Create(&client, settings, NULL);
EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded());
EXPECT_EQ(4u, host->settings().max_partial_texture_updates);
}
@@ -1952,7 +1950,7 @@ TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) {
settings.max_partial_texture_updates = 4;
scoped_ptr<LayerTreeHost> host =
- LayerTreeHost::Create(&client, settings, scoped_ptr<Thread>());
+ LayerTreeHost::Create(&client, settings, NULL);
EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded());
EXPECT_EQ(4u, host->settings().max_partial_texture_updates);
}
@@ -1964,7 +1962,7 @@ TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) {
settings.max_partial_texture_updates = 4;
scoped_ptr<LayerTreeHost> host =
- LayerTreeHost::Create(&client, settings, scoped_ptr<Thread>());
+ LayerTreeHost::Create(&client, settings, NULL);
EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded());
EXPECT_EQ(0u, host->settings().max_partial_texture_updates);
}
@@ -1977,7 +1975,7 @@ TEST(LayerTreeHostTest,
settings.max_partial_texture_updates = 4;
scoped_ptr<LayerTreeHost> host =
- LayerTreeHost::Create(&client, settings, scoped_ptr<Thread>());
+ LayerTreeHost::Create(&client, settings, NULL);
EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded());
EXPECT_EQ(0u, host->settings().max_partial_texture_updates);
}
@@ -2258,9 +2256,10 @@ class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled
virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
// The BeginFrame notification is turned off now but will get enabled
// once we return. End test while it's enabled.
- ImplThread()->PostTask(base::Bind(
- &LayerTreeHostTestBeginFrameNotification::EndTest,
- base::Unretained(this)));
+ ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest,
+ base::Unretained(this)));
}
virtual void AfterTest() OVERRIDE {}
@@ -2828,7 +2827,7 @@ class LayerTreeHostTestDeferredInitialize : public LayerTreeHostTest {
static_cast<FakePictureLayerImpl*>(host_impl->RootLayer());
if (!initialized_gl_) {
EXPECT_EQ(1u, layer_impl->append_quads_count());
- ImplThread()->PostTask(base::Bind(
+ ImplThreadTaskRunner()->PostTask(FROM_HERE, base::Bind(
&LayerTreeHostTestDeferredInitialize::DeferredInitializeAndRedraw,
base::Unretained(this),
base::Unretained(host_impl)));
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc
index f234996..d80373d 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -5,7 +5,6 @@
#include "cc/trees/layer_tree_host.h"
#include "base/basictypes.h"
-#include "cc/base/thread_impl.h"
#include "cc/layers/content_layer.h"
#include "cc/layers/heads_up_display_layer.h"
#include "cc/layers/io_surface_layer.h"
@@ -135,7 +134,7 @@ class LayerTreeHostContextTest : public LayerTreeTest {
virtual scoped_refptr<cc::ContextProvider>
OffscreenContextProviderForMainThread() OVERRIDE {
- DCHECK(!ImplThread());
+ DCHECK(!HasImplThread());
if (!offscreen_contexts_main_thread_.get() ||
offscreen_contexts_main_thread_->DestroyedOnMainThread()) {
@@ -151,7 +150,7 @@ class LayerTreeHostContextTest : public LayerTreeTest {
virtual scoped_refptr<cc::ContextProvider>
OffscreenContextProviderForCompositorThread() OVERRIDE {
- DCHECK(ImplThread());
+ DCHECK(HasImplThread());
if (!offscreen_contexts_compositor_thread_.get() ||
offscreen_contexts_compositor_thread_->DestroyedOnMainThread()) {
@@ -829,8 +828,9 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
}
void PostEvictTextures() {
- if (ImplThread()) {
- ImplThread()->PostTask(
+ if (HasImplThread()) {
+ ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(
&LayerTreeHostContextTestLostContextAndEvictTextures::
EvictTexturesOnImplThread,
@@ -1576,18 +1576,18 @@ class LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface
bool delegating_renderer,
bool impl_side_painting) {
scoped_ptr<base::Thread> impl_thread;
- scoped_ptr<cc::Thread> impl_ccthread;
if (threaded) {
impl_thread.reset(new base::Thread("LayerTreeTest"));
- impl_ccthread = cc::ThreadImpl::CreateForDifferentThread(
- impl_thread->message_loop_proxy());
- ASSERT_TRUE(impl_ccthread);
+ ASSERT_TRUE(impl_thread->Start());
+ ASSERT_TRUE(impl_thread->message_loop_proxy());
}
LayerTreeSettings settings;
settings.impl_side_painting = impl_side_painting;
- scoped_ptr<LayerTreeHost> layer_tree_host =
- LayerTreeHost::Create(this, settings, impl_ccthread.Pass());
+ scoped_ptr<LayerTreeHost> layer_tree_host = LayerTreeHost::Create(
+ this,
+ settings,
+ impl_thread ? impl_thread->message_loop_proxy() : NULL);
EXPECT_FALSE(layer_tree_host);
}
};
diff --git a/cc/trees/layer_tree_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc
index eef0e19..f4cf091 100644
--- a/cc/trees/layer_tree_host_unittest_scroll.cc
+++ b/cc/trees/layer_tree_host_unittest_scroll.cc
@@ -5,7 +5,6 @@
#include "cc/trees/layer_tree_host.h"
#include "base/memory/weak_ptr.h"
-#include "cc/base/thread_impl.h"
#include "cc/layers/content_layer.h"
#include "cc/layers/layer.h"
#include "cc/layers/layer_impl.h"
@@ -726,9 +725,7 @@ void BindInputHandlerOnCompositorThread(
TEST(LayerTreeHostFlingTest, DidStopFlingingThread) {
base::Thread impl_thread("cc");
- impl_thread.Start();
- scoped_ptr<Thread> impl_ccthread =
- ThreadImpl::CreateForDifferentThread(impl_thread.message_loop_proxy());
+ ASSERT_TRUE(impl_thread.Start());
bool received_stop_flinging = false;
LayerTreeSettings settings;
@@ -737,8 +734,11 @@ TEST(LayerTreeHostFlingTest, DidStopFlingingThread) {
impl_thread.message_loop_proxy().get(), &received_stop_flinging);
FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
+ ASSERT_TRUE(impl_thread.message_loop_proxy());
scoped_ptr<LayerTreeHost> layer_tree_host =
- LayerTreeHost::Create(&client, settings, impl_ccthread.Pass());
+ LayerTreeHost::Create(&client,
+ settings,
+ impl_thread.message_loop_proxy());
impl_thread.message_loop_proxy()
->PostTask(FROM_HERE,
diff --git a/cc/trees/proxy.cc b/cc/trees/proxy.cc
index fd39ed0..55a58af 100644
--- a/cc/trees/proxy.cc
+++ b/cc/trees/proxy.cc
@@ -4,31 +4,27 @@
#include "cc/trees/proxy.h"
-#include "cc/base/thread.h"
-#include "cc/base/thread_impl.h"
+#include "base/message_loop_proxy.h"
+#include "base/single_thread_task_runner.h"
namespace cc {
-Thread* Proxy::MainThread() const { return main_thread_.get(); }
-
-bool Proxy::HasImplThread() const { return impl_thread_; }
+base::SingleThreadTaskRunner* Proxy::MainThreadTaskRunner() const {
+ return main_task_runner_.get();
+}
-Thread* Proxy::ImplThread() const { return impl_thread_.get(); }
+bool Proxy::HasImplThread() const { return !!impl_task_runner_.get(); }
-Thread* Proxy::CurrentThread() const {
- if (MainThread() && MainThread()->BelongsToCurrentThread())
- return MainThread();
- if (ImplThread() && ImplThread()->BelongsToCurrentThread())
- return ImplThread();
- return NULL;
+base::SingleThreadTaskRunner* Proxy::ImplThreadTaskRunner() const {
+ return impl_task_runner_.get();
}
bool Proxy::IsMainThread() const {
#ifndef NDEBUG
- DCHECK(MainThread());
+ DCHECK(main_task_runner_.get());
if (impl_thread_is_overridden_)
return false;
- return MainThread()->BelongsToCurrentThread();
+ return main_task_runner_->BelongsToCurrentThread();
#else
return true;
#endif
@@ -38,7 +34,9 @@ bool Proxy::IsImplThread() const {
#ifndef NDEBUG
if (impl_thread_is_overridden_)
return true;
- return ImplThread() && ImplThread()->BelongsToCurrentThread();
+ if (!impl_task_runner_.get())
+ return false;
+ return impl_task_runner_->BelongsToCurrentThread();
#else
return true;
#endif
@@ -64,12 +62,13 @@ void Proxy::SetMainThreadBlocked(bool is_main_thread_blocked) {
}
#endif
-Proxy::Proxy(scoped_ptr<Thread> impl_thread)
- : main_thread_(ThreadImpl::CreateForCurrentThread()),
+Proxy::Proxy(
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner)
+ : main_task_runner_(base::MessageLoopProxy::current()),
#ifdef NDEBUG
- impl_thread_(impl_thread.Pass()) {}
+ impl_task_runner_(impl_task_runner) {}
#else
- impl_thread_(impl_thread.Pass()),
+ impl_task_runner_(impl_task_runner),
impl_thread_is_overridden_(false),
is_main_thread_blocked_(false) {}
#endif
diff --git a/cc/trees/proxy.h b/cc/trees/proxy.h
index 4e6171c..38cdbc7 100644
--- a/cc/trees/proxy.h
+++ b/cc/trees/proxy.h
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/logging.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/time.h"
#include "base/values.h"
@@ -16,6 +17,8 @@
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkPicture.h"
+namespace base { class SingleThreadTaskRunner; }
+
namespace gfx {
class Rect;
class Vector2d;
@@ -24,20 +27,15 @@ class Vector2d;
namespace cc {
class OutputSurface;
-class Thread;
struct RendererCapabilities;
// Abstract class responsible for proxying commands from the main-thread side of
// the compositor over to the compositor implementation.
class CC_EXPORT Proxy {
public:
- Thread* MainThread() const;
+ base::SingleThreadTaskRunner* MainThreadTaskRunner() const;
bool HasImplThread() const;
- Thread* ImplThread() const;
-
- // Returns 0 if the current thread is neither the main thread nor the impl
- // thread.
- Thread* CurrentThread() const;
+ base::SingleThreadTaskRunner* ImplThreadTaskRunner() const;
// Debug hooks.
bool IsMainThread() const;
@@ -103,14 +101,15 @@ class CC_EXPORT Proxy {
virtual std::string SchedulerStateAsStringForTesting();
protected:
- explicit Proxy(scoped_ptr<Thread> impl_thread);
+ explicit Proxy(
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
friend class DebugScopedSetImplThread;
friend class DebugScopedSetMainThread;
friend class DebugScopedSetMainThreadBlocked;
private:
- scoped_ptr<Thread> main_thread_;
- scoped_ptr<Thread> impl_thread_;
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_;
#ifndef NDEBUG
bool impl_thread_is_overridden_;
bool is_main_thread_blocked_;
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc
index 00bd8d1..92b7b68 100644
--- a/cc/trees/single_thread_proxy.cc
+++ b/cc/trees/single_thread_proxy.cc
@@ -6,7 +6,6 @@
#include "base/auto_reset.h"
#include "base/debug/trace_event.h"
-#include "cc/base/thread.h"
#include "cc/output/context_provider.h"
#include "cc/output/output_surface.h"
#include "cc/quads/draw_quad.h"
@@ -23,7 +22,7 @@ scoped_ptr<Proxy> SingleThreadProxy::Create(LayerTreeHost* layer_tree_host) {
}
SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layer_tree_host)
- : Proxy(scoped_ptr<Thread>()),
+ : Proxy(NULL),
layer_tree_host_(layer_tree_host),
created_offscreen_context_provider_(false),
next_frame_is_newly_committed_frame_(false),
@@ -194,7 +193,7 @@ void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) {
scoped_ptr<ResourceUpdateController> update_controller =
ResourceUpdateController::Create(
NULL,
- Proxy::MainThread()->TaskRunner(),
+ Proxy::MainThreadTaskRunner(),
queue.Pass(),
layer_tree_host_impl_->resource_provider());
update_controller->Finalize();
diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc
index 980f1d4..54d8105 100644
--- a/cc/trees/thread_proxy.cc
+++ b/cc/trees/thread_proxy.cc
@@ -10,7 +10,6 @@
#include "base/bind.h"
#include "base/debug/trace_event.h"
#include "base/metrics/histogram.h"
-#include "cc/base/thread.h"
#include "cc/input/input_handler.h"
#include "cc/output/context_provider.h"
#include "cc/output/output_surface.h"
@@ -55,15 +54,17 @@ struct ThreadProxy::SchedulerStateRequest {
std::string state;
};
-scoped_ptr<Proxy> ThreadProxy::Create(LayerTreeHost* layer_tree_host,
- scoped_ptr<Thread> impl_thread) {
+scoped_ptr<Proxy> ThreadProxy::Create(
+ LayerTreeHost* layer_tree_host,
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
return make_scoped_ptr(
- new ThreadProxy(layer_tree_host, impl_thread.Pass())).PassAs<Proxy>();
+ new ThreadProxy(layer_tree_host, impl_task_runner)).PassAs<Proxy>();
}
-ThreadProxy::ThreadProxy(LayerTreeHost* layer_tree_host,
- scoped_ptr<Thread> impl_thread)
- : Proxy(impl_thread.Pass()),
+ThreadProxy::ThreadProxy(
+ LayerTreeHost* layer_tree_host,
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner)
+ : Proxy(impl_task_runner),
animate_requested_(false),
commit_requested_(false),
commit_request_sent_to_impl_thread_(false),
@@ -117,7 +118,8 @@ bool ThreadProxy::CompositeAndReadback(void* pixels, gfx::Rect rect) {
{
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
CompletionEvent begin_frame_sent_to_main_thread_completion;
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::ForceCommitOnImplThread,
impl_thread_weak_ptr_,
&begin_frame_sent_to_main_thread_completion));
@@ -133,7 +135,8 @@ bool ThreadProxy::CompositeAndReadback(void* pixels, gfx::Rect rect) {
request.pixels = pixels;
{
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::RequestReadbackOnImplThread,
impl_thread_weak_ptr_,
&request));
@@ -177,7 +180,8 @@ void ThreadProxy::FinishAllRendering() {
// Make sure all GL drawing is finished on the impl thread.
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
CompletionEvent completion;
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::FinishAllRenderingOnImplThread,
impl_thread_weak_ptr_,
&completion));
@@ -191,9 +195,10 @@ bool ThreadProxy::IsStarted() const {
void ThreadProxy::SetLayerTreeHostClientReady() {
TRACE_EVENT0("cc", "ThreadProxy::SetLayerTreeHostClientReady");
- Proxy::ImplThread()->PostTask(base::Bind(
- &ThreadProxy::SetLayerTreeHostClientReadyOnImplThread,
- impl_thread_weak_ptr_));
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&ThreadProxy::SetLayerTreeHostClientReadyOnImplThread,
+ impl_thread_weak_ptr_));
}
void ThreadProxy::SetLayerTreeHostClientReadyOnImplThread() {
@@ -205,10 +210,12 @@ void ThreadProxy::SetVisible(bool visible) {
TRACE_EVENT0("cc", "ThreadProxy::SetVisible");
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
CompletionEvent completion;
- Proxy::ImplThread()->PostTask(base::Bind(&ThreadProxy::SetVisibleOnImplThread,
- impl_thread_weak_ptr_,
- &completion,
- visible));
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&ThreadProxy::SetVisibleOnImplThread,
+ impl_thread_weak_ptr_,
+ &completion,
+ visible));
completion.Wait();
}
@@ -254,7 +261,8 @@ void ThreadProxy::DoCreateAndInitializeOutputSurface() {
CompletionEvent completion;
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::InitializeOutputSurfaceOnImplThread,
impl_thread_weak_ptr_,
&completion,
@@ -282,8 +290,8 @@ void ThreadProxy::OnOutputSurfaceInitializeAttempted(
layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success);
if (result == LayerTreeHost::CreateFailedButTryAgain) {
if (!output_surface_creation_callback_.callback().is_null()) {
- Proxy::MainThread()->PostTask(
- output_surface_creation_callback_.callback());
+ Proxy::MainThreadTaskRunner()->PostTask(
+ FROM_HERE, output_surface_creation_callback_.callback());
}
} else {
output_surface_creation_callback_.Cancel();
@@ -307,8 +315,10 @@ void ThreadProxy::SetNeedsAnimate() {
if (commit_request_sent_to_impl_thread_)
return;
commit_request_sent_to_impl_thread_ = true;
- Proxy::ImplThread()->PostTask(base::Bind(
- &ThreadProxy::SetNeedsCommitOnImplThread, impl_thread_weak_ptr_));
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&ThreadProxy::SetNeedsCommitOnImplThread,
+ impl_thread_weak_ptr_));
}
void ThreadProxy::SetNeedsCommit() {
@@ -321,14 +331,17 @@ void ThreadProxy::SetNeedsCommit() {
if (commit_request_sent_to_impl_thread_)
return;
commit_request_sent_to_impl_thread_ = true;
- Proxy::ImplThread()->PostTask(base::Bind(
- &ThreadProxy::SetNeedsCommitOnImplThread, impl_thread_weak_ptr_));
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&ThreadProxy::SetNeedsCommitOnImplThread,
+ impl_thread_weak_ptr_));
}
void ThreadProxy::DidLoseOutputSurfaceOnImplThread() {
DCHECK(IsImplThread());
TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread");
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::CheckOutputSurfaceStatusOnImplThread,
impl_thread_weak_ptr_));
}
@@ -351,7 +364,8 @@ void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() {
void ThreadProxy::OnSwapBuffersCompleteOnImplThread() {
DCHECK(IsImplThread());
TRACE_EVENT0("cc", "ThreadProxy::OnSwapBuffersCompleteOnImplThread");
- Proxy::MainThread()->PostTask(
+ Proxy::MainThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_));
}
@@ -396,10 +410,12 @@ void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread(
DCHECK(IsImplThread());
TRACE_EVENT0("cc",
"ThreadProxy::PostAnimationEventsToMainThreadOnImplThread");
- Proxy::MainThread()->PostTask(base::Bind(&ThreadProxy::SetAnimationEvents,
- main_thread_weak_ptr_,
- base::Passed(&events),
- wall_clock_time));
+ Proxy::MainThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&ThreadProxy::SetAnimationEvents,
+ main_thread_weak_ptr_,
+ base::Passed(&events),
+ wall_clock_time));
}
bool ThreadProxy::ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes,
@@ -464,9 +480,11 @@ bool ThreadProxy::IsInsideDraw() { return inside_draw_; }
void ThreadProxy::SetNeedsRedraw(gfx::Rect damage_rect) {
DCHECK(IsMainThread());
TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw");
- Proxy::ImplThread()->PostTask(base::Bind(
- &ThreadProxy::SetNeedsRedrawRectOnImplThread,
- impl_thread_weak_ptr_, damage_rect));
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&ThreadProxy::SetNeedsRedrawRectOnImplThread,
+ impl_thread_weak_ptr_,
+ damage_rect));
}
void ThreadProxy::SetDeferCommits(bool defer_commits) {
@@ -480,7 +498,8 @@ void ThreadProxy::SetDeferCommits(bool defer_commits) {
TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this);
if (!defer_commits_ && pending_deferred_commit_)
- Proxy::MainThread()->PostTask(
+ Proxy::MainThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::BeginFrameOnMainThread,
main_thread_weak_ptr_,
base::Passed(&pending_deferred_commit_)));
@@ -517,7 +536,8 @@ void ThreadProxy::DidInitializeVisibleTileOnImplThread() {
void ThreadProxy::MainThreadHasStoppedFlinging() {
DCHECK(IsMainThread());
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::MainThreadHasStoppedFlingingOnImplThread,
impl_thread_weak_ptr_));
}
@@ -529,12 +549,13 @@ void ThreadProxy::MainThreadHasStoppedFlingingOnImplThread() {
void ThreadProxy::Start(scoped_ptr<OutputSurface> first_output_surface) {
DCHECK(IsMainThread());
- DCHECK(Proxy::ImplThread());
+ DCHECK(Proxy::HasImplThread());
DCHECK(first_output_surface);
// Create LayerTreeHostImpl.
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
CompletionEvent completion;
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::InitializeImplOnImplThread,
base::Unretained(this),
&completion));
@@ -559,7 +580,8 @@ void ThreadProxy::Stop() {
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
CompletionEvent completion;
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::FinishGLOnImplThread,
impl_thread_weak_ptr_,
&completion));
@@ -569,7 +591,8 @@ void ThreadProxy::Stop() {
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
CompletionEvent completion;
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread,
impl_thread_weak_ptr_,
&completion));
@@ -586,7 +609,8 @@ void ThreadProxy::Stop() {
void ThreadProxy::ForceSerializeOnSwapBuffers() {
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
CompletionEvent completion;
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::ForceSerializeOnSwapBuffersOnImplThread,
impl_thread_weak_ptr_,
&completion));
@@ -621,7 +645,8 @@ void ThreadProxy::ScheduledActionSendBeginFrameToMainThread() {
}
begin_frame_state->memory_allocation_limit_bytes =
layer_tree_host_impl_->memory_allocation_limit_bytes();
- Proxy::MainThread()->PostTask(
+ Proxy::MainThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::BeginFrameOnMainThread,
main_thread_weak_ptr_,
base::Passed(&begin_frame_state)));
@@ -667,9 +692,10 @@ void ThreadProxy::BeginFrameOnMainThread(
commit_request_sent_to_impl_thread_ = false;
TRACE_EVENT0("cc", "EarlyOut_NotVisible");
- Proxy::ImplThread()->PostTask(base::Bind(
- &ThreadProxy::BeginFrameAbortedByMainThreadOnImplThread,
- impl_thread_weak_ptr_));
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&ThreadProxy::BeginFrameAbortedByMainThreadOnImplThread,
+ impl_thread_weak_ptr_));
return;
}
@@ -743,7 +769,8 @@ void ThreadProxy::BeginFrameOnMainThread(
base::TimeTicks start_time = stats_instrumentation->StartRecording();
CompletionEvent completion;
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::StartCommitOnImplThread,
impl_thread_weak_ptr_,
&completion,
@@ -804,7 +831,7 @@ void ThreadProxy::StartCommitOnImplThread(
current_resource_update_controller_on_impl_thread_ =
ResourceUpdateController::Create(
this,
- Proxy::ImplThread()->TaskRunner(),
+ Proxy::ImplThreadTaskRunner(),
queue.Pass(),
layer_tree_host_impl_->resource_provider());
current_resource_update_controller_on_impl_thread_->PerformMoreUpdates(
@@ -880,7 +907,8 @@ void ThreadProxy::ScheduledActionActivatePendingTreeIfNeeded() {
void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() {
DCHECK(IsImplThread());
- Proxy::MainThread()->PostTask(
+ Proxy::MainThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::CreateAndInitializeOutputSurface,
main_thread_weak_ptr_));
}
@@ -983,7 +1011,8 @@ ThreadProxy::ScheduledActionDrawAndSwapInternal(bool forced_draw) {
// Tell the main thread that the the newly-commited frame was drawn.
if (next_frame_is_newly_committed_frame_on_impl_thread_) {
next_frame_is_newly_committed_frame_on_impl_thread_ = false;
- Proxy::MainThread()->PostTask(
+ Proxy::MainThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_));
}
@@ -1038,7 +1067,8 @@ void ThreadProxy::AcquireLayerTextures() {
TRACE_EVENT0("cc", "ThreadProxy::AcquireLayerTextures");
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
CompletionEvent completion;
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::AcquireLayerTexturesForMainThreadOnImplThread,
impl_thread_weak_ptr_,
&completion));
@@ -1125,7 +1155,8 @@ void ThreadProxy::CreateAndInitializeOutputSurface() {
bool has_initialized_output_surface_on_impl_thread = true;
{
CompletionEvent completion;
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::HasInitializedOutputSurfaceOnImplThread,
impl_thread_weak_ptr_,
&completion,
@@ -1251,10 +1282,12 @@ scoped_ptr<base::Value> ThreadProxy::AsValue() const {
{
DebugScopedSetMainThreadBlocked main_thread_blocked(
const_cast<ThreadProxy*>(this));
- Proxy::ImplThread()->PostTask(base::Bind(&ThreadProxy::AsValueOnImplThread,
- impl_thread_weak_ptr_,
- &completion,
- state.get()));
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&ThreadProxy::AsValueOnImplThread,
+ impl_thread_weak_ptr_,
+ &completion,
+ state.get()));
completion.Wait();
}
return state.PassAs<base::Value>();
@@ -1272,7 +1305,8 @@ bool ThreadProxy::CommitPendingForTesting() {
CommitPendingRequest commit_pending_request;
{
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::CommitPendingOnImplThreadForTesting,
impl_thread_weak_ptr_,
&commit_pending_request));
@@ -1298,7 +1332,8 @@ std::string ThreadProxy::SchedulerStateAsStringForTesting() {
SchedulerStateRequest scheduler_state_request;
{
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::SchedulerStateAsStringOnImplThreadForTesting,
impl_thread_weak_ptr_,
&scheduler_state_request));
@@ -1320,7 +1355,8 @@ skia::RefPtr<SkPicture> ThreadProxy::CapturePicture() {
skia::RefPtr<SkPicture> picture;
{
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
- Proxy::ImplThread()->PostTask(
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::CapturePictureOnImplThread,
impl_thread_weak_ptr_,
&completion,
@@ -1384,7 +1420,8 @@ void ThreadProxy::RenewTreePriority() {
if (renew_tree_priority_on_impl_thread_pending_)
return;
- Proxy::ImplThread()->PostDelayedTask(
+ Proxy::ImplThreadTaskRunner()->PostDelayedTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::RenewTreePriorityOnImplThread,
weak_factory_on_impl_thread_.GetWeakPtr()),
delay);
@@ -1400,7 +1437,8 @@ void ThreadProxy::RenewTreePriorityOnImplThread() {
}
void ThreadProxy::RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) {
- Proxy::ImplThread()->PostDelayedTask(
+ Proxy::ImplThreadTaskRunner()->PostDelayedTask(
+ FROM_HERE,
base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread,
impl_thread_weak_ptr_),
delay);
diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h
index 4f26d35..94fcee5 100644
--- a/cc/trees/thread_proxy.h
+++ b/cc/trees/thread_proxy.h
@@ -18,6 +18,8 @@
#include "cc/trees/layer_tree_host_impl.h"
#include "cc/trees/proxy.h"
+namespace base { class SingleThreadTaskRunner; }
+
namespace cc {
class ContextProvider;
@@ -26,15 +28,15 @@ class LayerTreeHost;
class ResourceUpdateQueue;
class Scheduler;
class ScopedThreadProxy;
-class Thread;
class ThreadProxy : public Proxy,
LayerTreeHostImplClient,
SchedulerClient,
ResourceUpdateControllerClient {
public:
- static scoped_ptr<Proxy> Create(LayerTreeHost* layer_tree_host,
- scoped_ptr<Thread> impl_thread);
+ static scoped_ptr<Proxy> Create(
+ LayerTreeHost* layer_tree_host,
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
virtual ~ThreadProxy();
@@ -108,7 +110,8 @@ class ThreadProxy : public Proxy,
virtual void ReadyToFinalizeTextureUpdates() OVERRIDE;
private:
- ThreadProxy(LayerTreeHost* layer_tree_host, scoped_ptr<Thread> impl_thread);
+ ThreadProxy(LayerTreeHost* layer_tree_host,
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
struct BeginFrameAndCommitState {
BeginFrameAndCommitState();
diff --git a/cc/trees/tree_synchronizer_unittest.cc b/cc/trees/tree_synchronizer_unittest.cc
index 68b2d24..d70e4ef 100644
--- a/cc/trees/tree_synchronizer_unittest.cc
+++ b/cc/trees/tree_synchronizer_unittest.cc
@@ -483,7 +483,7 @@ TEST_F(TreeSynchronizerTest, SyncMaskReplicaAndReplicaMaskLayers) {
TEST_F(TreeSynchronizerTest, SynchronizeAnimations) {
LayerTreeSettings settings;
- FakeProxy proxy((scoped_ptr<Thread>()));
+ FakeProxy proxy;
DebugScopedSetImplThread impl(&proxy);
FakeRenderingStatsInstrumentation stats_instrumentation;
scoped_ptr<LayerTreeHostImpl> host_impl =