Index: cc/trees/threaded_channel.cc |
diff --git a/cc/trees/threaded_channel.cc b/cc/trees/threaded_channel.cc |
index 3bc44c93efad6231bfd7c86ca208422562680a46..434ebef58fd3168e70f578e65fd3b17be6c5dccf 100644 |
--- a/cc/trees/threaded_channel.cc |
+++ b/cc/trees/threaded_channel.cc |
@@ -25,7 +25,8 @@ ThreadedChannel::ThreadedChannel( |
: proxy_main_(thread_proxy), |
proxy_impl_(thread_proxy), |
main_task_runner_(main_task_runner), |
- impl_task_runner_(impl_task_runner) {} |
+ impl_task_runner_(impl_task_runner), |
+ impl_weak_factory_(this) {} |
void ThreadedChannel::SetThrottleFrameProductionOnImpl(bool throttle) { |
ImplThreadTaskRunner()->PostTask( |
@@ -39,12 +40,174 @@ void ThreadedChannel::SetLayerTreeHostClientReadyOnImpl() { |
proxy_impl_->GetImplWeakPtr())); |
} |
+void ThreadedChannel::InitializeOutputSurfaceOnImpl( |
+ OutputSurface* output_surface) { |
+ ImplThreadTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&ProxyImpl::InitializeOutputSurfaceOnImpl, |
+ proxy_impl_->GetImplWeakPtr(), output_surface)); |
+} |
+ |
+void ThreadedChannel::MainThreadHasStoppedFlingingOnImpl() { |
+ ImplThreadTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&ProxyImpl::MainThreadHasStoppedFlingingOnImpl, |
+ proxy_impl_->GetImplWeakPtr())); |
+} |
+ |
+void ThreadedChannel::SetInputThrottledUntilCommitOnImpl(bool is_throttled) { |
+ ImplThreadTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&ProxyImpl::SetInputThrottledUntilCommitOnImpl, |
+ proxy_impl_->GetImplWeakPtr(), is_throttled)); |
+} |
+ |
+void ThreadedChannel::SetDeferCommitsOnImpl(bool defer_commits) { |
+ ImplThreadTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&ProxyImpl::SetDeferCommitsOnImpl, |
+ proxy_impl_->GetImplWeakPtr(), defer_commits)); |
+} |
+ |
+void ThreadedChannel::FinishAllRenderingOnImpl() { |
+ CompletionEvent completion; |
+ ImplThreadTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&ThreadedChannel::BlockingFinishAllRenderingOnImpl, |
+ impl_thread_weak_ptr_, &completion)); |
+ completion.Wait(); |
+} |
+ |
+void ThreadedChannel::BlockingFinishAllRenderingOnImpl( |
+ CompletionEvent* completion) { |
+ proxy_impl_->FinishAllRenderingOnImpl(); |
+ completion->Signal(); |
+} |
+ |
+void ThreadedChannel::SetVisibleOnImpl(bool visible) { |
+ CompletionEvent completion; |
+ ImplThreadTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&ThreadedChannel::BlockingSetVisibleOnImpl, |
+ impl_thread_weak_ptr_, &completion, visible)); |
+ completion.Wait(); |
+} |
+ |
+void ThreadedChannel::BlockingSetVisibleOnImpl(CompletionEvent* completion, |
+ bool visible) { |
+ proxy_impl_->SetVisibleOnImpl(visible); |
+ completion->Signal(); |
+} |
+ |
+void ThreadedChannel::ReleaseOutputSurfaceOnImpl() { |
+ CompletionEvent completion; |
+ ImplThreadTaskRunner()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&ThreadedChannel::BlockingReleaseOutputSurfaceOnImpl, |
+ impl_thread_weak_ptr_, &completion)); |
+ completion.Wait(); |
+} |
+ |
+void ThreadedChannel::BlockingReleaseOutputSurfaceOnImpl( |
+ CompletionEvent* completion) { |
+ proxy_impl_->ReleaseOutputSurfaceOnImpl(); |
+ completion->Signal(); |
+} |
+ |
+void ThreadedChannel::FinishGLOnImpl() { |
+ CompletionEvent completion; |
+ ImplThreadTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&ThreadedChannel::BlockingFinishGLOnImpl, |
+ impl_thread_weak_ptr_, &completion)); |
+ completion.Wait(); |
+} |
+ |
+void ThreadedChannel::BlockingFinishGLOnImpl(CompletionEvent* completion) { |
+ proxy_impl_->FinishGLOnImpl(); |
+ completion->Signal(); |
+} |
+ |
+void ThreadedChannel::MainFrameWillHappenOnImplForTesting( |
+ bool* main_frame_will_happen) { |
+ CompletionEvent completion; |
+ ImplThreadTaskRunner()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&ThreadedChannel::BlockingMainFrameWillHappenOnImplForTesting, |
+ impl_thread_weak_ptr_, &completion, main_frame_will_happen)); |
+ completion.Wait(); |
+} |
+ |
+void ThreadedChannel::BlockingMainFrameWillHappenOnImplForTesting( |
+ CompletionEvent* completion, |
+ bool* main_frame_will_happen) { |
+ proxy_impl_->MainFrameWillHappenOnImplForTesting(main_frame_will_happen); |
+ completion->Signal(); |
+} |
+ |
void ThreadedChannel::DidCompleteSwapBuffers() { |
MainThreadTaskRunner()->PostTask( |
FROM_HERE, base::Bind(&ProxyMain::DidCompleteSwapBuffers, |
proxy_main_->GetMainWeakPtr())); |
} |
+void ThreadedChannel::SetRendererCapabilitiesMainCopy( |
+ const RendererCapabilities& capabilities) { |
+ MainThreadTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&ProxyMain::SetRendererCapabilitiesMainCopy, |
+ proxy_main_->GetMainWeakPtr(), capabilities)); |
+} |
+ |
+void ThreadedChannel::BeginMainFrameNotExpectedSoon() { |
+ MainThreadTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&ProxyMain::BeginMainFrameNotExpectedSoon, |
+ proxy_main_->GetMainWeakPtr())); |
+} |
+ |
+void ThreadedChannel::DidCommitAndDrawFrame() { |
+ MainThreadTaskRunner()->PostTask(FROM_HERE, |
+ base::Bind(&ProxyMain::DidCommitAndDrawFrame, |
+ proxy_main_->GetMainWeakPtr())); |
+} |
+ |
+void ThreadedChannel::SetAnimationEvents( |
+ scoped_ptr<AnimationEventsVector> queue) { |
+ MainThreadTaskRunner()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&ProxyMain::SetAnimationEvents, proxy_main_->GetMainWeakPtr(), |
+ base::Passed(&queue))); |
+} |
+ |
+void ThreadedChannel::DidLoseOutputSurface() { |
+ MainThreadTaskRunner()->PostTask(FROM_HERE, |
+ base::Bind(&ProxyMain::DidLoseOutputSurface, |
+ proxy_main_->GetMainWeakPtr())); |
+} |
+ |
+void ThreadedChannel::RequestNewOutputSurface() { |
+ MainThreadTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&ProxyMain::RequestNewOutputSurface, |
+ proxy_main_->GetMainWeakPtr())); |
+} |
+ |
+void ThreadedChannel::DidInitializeOutputSurface( |
+ bool success, |
+ const RendererCapabilities& capabilities) { |
+ MainThreadTaskRunner()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&ProxyMain::DidInitializeOutputSurface, |
+ proxy_main_->GetMainWeakPtr(), success, capabilities)); |
+} |
+ |
+void ThreadedChannel::DidCompletePageScaleAnimation() { |
+ MainThreadTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&ProxyMain::DidCompletePageScaleAnimation, |
+ proxy_main_->GetMainWeakPtr())); |
+} |
+ |
+void ThreadedChannel::PostFrameTimingEventsToMain( |
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
+ scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
+ MainThreadTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&ProxyMain::PostFrameTimingEventsToMain, |
+ proxy_main_->GetMainWeakPtr(), |
+ base::Passed(composite_events.Pass()), |
+ base::Passed(main_frame_events.Pass()))); |
+} |
+ |
ThreadedChannel::~ThreadedChannel() { |
TRACE_EVENT0("cc", "ThreadChannel::~ThreadChannel"); |
} |
@@ -57,4 +220,12 @@ base::SingleThreadTaskRunner* ThreadedChannel::ImplThreadTaskRunner() const { |
return impl_task_runner_.get(); |
} |
+void ThreadedChannel::InitImplThreadWeakPtr() { |
+ impl_thread_weak_ptr_ = impl_weak_factory_.GetWeakPtr(); |
+} |
+ |
+void ThreadedChannel::InvalidateImplThreadWeakPtr() { |
+ impl_weak_factory_.InvalidateWeakPtrs(); |
+} |
+ |
} // namespace cc |