| Index: trunk/src/cc/trees/single_thread_proxy.cc
 | 
| ===================================================================
 | 
| --- trunk/src/cc/trees/single_thread_proxy.cc	(revision 287765)
 | 
| +++ trunk/src/cc/trees/single_thread_proxy.cc	(working copy)
 | 
| @@ -36,13 +36,8 @@
 | 
|      : Proxy(main_task_runner, NULL),
 | 
|        layer_tree_host_(layer_tree_host),
 | 
|        client_(client),
 | 
| -      timing_history_(layer_tree_host->rendering_stats_instrumentation()),
 | 
|        next_frame_is_newly_committed_frame_(false),
 | 
| -      inside_draw_(false),
 | 
| -      defer_commits_(false),
 | 
| -      commit_was_deferred_(false),
 | 
| -      commit_requested_(false),
 | 
| -      weak_factory_(this) {
 | 
| +      inside_draw_(false) {
 | 
|    TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy");
 | 
|    DCHECK(Proxy::IsMainThread());
 | 
|    DCHECK(layer_tree_host);
 | 
| @@ -82,26 +77,13 @@
 | 
|    TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady");
 | 
|    // Scheduling is controlled by the embedder in the single thread case, so
 | 
|    // nothing to do.
 | 
| -  DCHECK(Proxy::IsMainThread());
 | 
| -  DebugScopedSetImplThread impl(this);
 | 
| -  if (layer_tree_host_->settings().single_thread_proxy_scheduler &&
 | 
| -      !scheduler_on_impl_thread_) {
 | 
| -    SchedulerSettings scheduler_settings(layer_tree_host_->settings());
 | 
| -    scheduler_on_impl_thread_ = Scheduler::Create(this,
 | 
| -                                                  scheduler_settings,
 | 
| -                                                  layer_tree_host_->id(),
 | 
| -                                                  MainThreadTaskRunner());
 | 
| -    scheduler_on_impl_thread_->SetCanStart();
 | 
| -    scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
 | 
| -  }
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::SetVisible(bool visible) {
 | 
|    TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible");
 | 
|    DebugScopedSetImplThread impl(this);
 | 
|    layer_tree_host_impl_->SetVisible(visible);
 | 
| -  if (scheduler_on_impl_thread_)
 | 
| -    scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
 | 
| +
 | 
|    // Changing visibility could change ShouldComposite().
 | 
|    UpdateBackgroundAnimateTicking();
 | 
|  }
 | 
| @@ -128,14 +110,9 @@
 | 
|  
 | 
|    layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success);
 | 
|  
 | 
| -  if (success) {
 | 
| -    if (scheduler_on_impl_thread_)
 | 
| -      scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface();
 | 
| -  } else if (Proxy::MainThreadTaskRunner()) {
 | 
| -    MainThreadTaskRunner()->PostTask(
 | 
| -        FROM_HERE,
 | 
| -        base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface,
 | 
| -                   weak_factory_.GetWeakPtr()));
 | 
| +  if (!success) {
 | 
| +    // Force another recreation attempt to happen by requesting another commit.
 | 
| +    SetNeedsCommit();
 | 
|    }
 | 
|  }
 | 
|  
 | 
| @@ -149,40 +126,17 @@
 | 
|    TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate");
 | 
|    DCHECK(Proxy::IsMainThread());
 | 
|    client_->ScheduleAnimation();
 | 
| -  SetNeedsCommit();
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::SetNeedsUpdateLayers() {
 | 
|    TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers");
 | 
|    DCHECK(Proxy::IsMainThread());
 | 
| -  SetNeedsCommit();
 | 
| +  client_->ScheduleComposite();
 | 
|  }
 | 
|  
 | 
| -void SingleThreadProxy::DoCommit(base::TimeTicks frame_begin_time) {
 | 
| +void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) {
 | 
|    TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit");
 | 
|    DCHECK(Proxy::IsMainThread());
 | 
| -  layer_tree_host_->WillBeginMainFrame();
 | 
| -  layer_tree_host_->UpdateClientAnimations(frame_begin_time);
 | 
| -  layer_tree_host_->AnimateLayers(frame_begin_time);
 | 
| -  layer_tree_host_->Layout();
 | 
| -  commit_requested_ = false;
 | 
| -
 | 
| -  if (PrioritizedResourceManager* contents_texture_manager =
 | 
| -          layer_tree_host_->contents_texture_manager()) {
 | 
| -    contents_texture_manager->UnlinkAndClearEvictedBackings();
 | 
| -    contents_texture_manager->SetMaxMemoryLimitBytes(
 | 
| -        layer_tree_host_impl_->memory_allocation_limit_bytes());
 | 
| -    contents_texture_manager->SetExternalPriorityCutoff(
 | 
| -        layer_tree_host_impl_->memory_allocation_priority_cutoff());
 | 
| -  }
 | 
| -
 | 
| -  scoped_ptr<ResourceUpdateQueue> queue =
 | 
| -      make_scoped_ptr(new ResourceUpdateQueue);
 | 
| -
 | 
| -  layer_tree_host_->UpdateLayers(queue.get());
 | 
| -
 | 
| -  layer_tree_host_->WillCommit();
 | 
| -
 | 
|    // Commit immediately.
 | 
|    {
 | 
|      DebugScopedSetMainThreadBlocked main_thread_blocked(this);
 | 
| @@ -204,7 +158,7 @@
 | 
|      scoped_ptr<ResourceUpdateController> update_controller =
 | 
|          ResourceUpdateController::Create(
 | 
|              NULL,
 | 
| -            MainThreadTaskRunner(),
 | 
| +            Proxy::MainThreadTaskRunner(),
 | 
|              queue.Pass(),
 | 
|              layer_tree_host_impl_->resource_provider());
 | 
|      update_controller->Finalize();
 | 
| @@ -216,8 +170,6 @@
 | 
|  
 | 
|      layer_tree_host_impl_->CommitComplete();
 | 
|  
 | 
| -    UpdateBackgroundAnimateTicking();
 | 
| -
 | 
|  #if DCHECK_IS_ON
 | 
|      // In the single-threaded case, the scale and scroll deltas should never be
 | 
|      // touched on the impl layer tree.
 | 
| @@ -234,64 +186,30 @@
 | 
|      stats_instrumentation->AccumulateAndClearMainThreadStats();
 | 
|    }
 | 
|    layer_tree_host_->CommitComplete();
 | 
| -  layer_tree_host_->DidBeginMainFrame();
 | 
| -  timing_history_.DidCommit();
 | 
| -
 | 
|    next_frame_is_newly_committed_frame_ = true;
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::SetNeedsCommit() {
 | 
|    DCHECK(Proxy::IsMainThread());
 | 
| -  DebugScopedSetImplThread impl(this);
 | 
|    client_->ScheduleComposite();
 | 
| -  if (scheduler_on_impl_thread_)
 | 
| -    scheduler_on_impl_thread_->SetNeedsCommit();
 | 
| -  commit_requested_ = true;
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) {
 | 
|    TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsRedraw");
 | 
| -  DCHECK(Proxy::IsMainThread());
 | 
| -  DebugScopedSetImplThread impl(this);
 | 
| +  SetNeedsRedrawRectOnImplThread(damage_rect);
 | 
|    client_->ScheduleComposite();
 | 
| -  SetNeedsRedrawRectOnImplThread(damage_rect);
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::SetNextCommitWaitsForActivation() {
 | 
|    // There is no activation here other than commit. So do nothing.
 | 
| -  DCHECK(Proxy::IsMainThread());
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::SetDeferCommits(bool defer_commits) {
 | 
| -  DCHECK(Proxy::IsMainThread());
 | 
| -  // Deferring commits only makes sense if there's a scheduler.
 | 
| -  if (!scheduler_on_impl_thread_)
 | 
| -    return;
 | 
| -  if (defer_commits_ == defer_commits)
 | 
| -    return;
 | 
| -
 | 
| -  if (defer_commits)
 | 
| -    TRACE_EVENT_ASYNC_BEGIN0("cc", "SingleThreadProxy::SetDeferCommits", this);
 | 
| -  else
 | 
| -    TRACE_EVENT_ASYNC_END0("cc", "SingleThreadProxy::SetDeferCommits", this);
 | 
| -
 | 
| -  defer_commits_ = defer_commits;
 | 
| -  if (!defer_commits_ && commit_was_deferred_) {
 | 
| -    scheduler_on_impl_thread_->NotifyBeginMainFrameStarted();
 | 
| -    scheduler_on_impl_thread_->NotifyReadyToCommit();
 | 
| -    commit_was_deferred_ = false;
 | 
| -  }
 | 
|  }
 | 
|  
 | 
| -bool SingleThreadProxy::CommitRequested() const {
 | 
| -  DCHECK(Proxy::IsMainThread());
 | 
| -  return commit_requested_;
 | 
| -}
 | 
| +bool SingleThreadProxy::CommitRequested() const { return false; }
 | 
|  
 | 
| -bool SingleThreadProxy::BeginMainFrameRequested() const {
 | 
| -  DCHECK(Proxy::IsMainThread());
 | 
| -  return commit_requested_;
 | 
| -}
 | 
| +bool SingleThreadProxy::BeginMainFrameRequested() const { return false; }
 | 
|  
 | 
|  size_t SingleThreadProxy::MaxPartialTextureUpdates() const {
 | 
|    return std::numeric_limits<size_t>::max();
 | 
| @@ -307,7 +225,6 @@
 | 
|      BlockingTaskRunner::CapturePostTasks blocked;
 | 
|      layer_tree_host_->DeleteContentsTexturesOnImplThread(
 | 
|          layer_tree_host_impl_->resource_provider());
 | 
| -    scheduler_on_impl_thread_.reset();
 | 
|      layer_tree_host_impl_.reset();
 | 
|    }
 | 
|    layer_tree_host_ = NULL;
 | 
| @@ -318,19 +235,15 @@
 | 
|        "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw);
 | 
|    DCHECK(Proxy::IsImplThread());
 | 
|    UpdateBackgroundAnimateTicking();
 | 
| -  if (scheduler_on_impl_thread_)
 | 
| -    scheduler_on_impl_thread_->SetCanDraw(can_draw);
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::NotifyReadyToActivate() {
 | 
| -  // Impl-side painting only.
 | 
| +  // Thread-only feature.
 | 
|    NOTREACHED();
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::SetNeedsRedrawOnImplThread() {
 | 
|    client_->ScheduleComposite();
 | 
| -  if (scheduler_on_impl_thread_)
 | 
| -    scheduler_on_impl_thread_->SetNeedsRedraw();
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::SetNeedsAnimateOnImplThread() {
 | 
| @@ -338,14 +251,17 @@
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::SetNeedsManageTilesOnImplThread() {
 | 
| -  // Impl-side painting only.
 | 
| +  // Thread-only/Impl-side-painting-only feature.
 | 
|    NOTREACHED();
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::SetNeedsRedrawRectOnImplThread(
 | 
|      const gfx::Rect& damage_rect) {
 | 
| +  // TODO(brianderson): Once we move render_widget scheduling into this class,
 | 
| +  // we can treat redraw requests more efficiently than CommitAndRedraw
 | 
| +  // requests.
 | 
|    layer_tree_host_impl_->SetViewportDamage(damage_rect);
 | 
| -  SetNeedsRedrawOnImplThread();
 | 
| +  SetNeedsCommit();
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() {
 | 
| @@ -355,8 +271,6 @@
 | 
|  
 | 
|  void SingleThreadProxy::SetNeedsCommitOnImplThread() {
 | 
|    client_->ScheduleComposite();
 | 
| -  if (scheduler_on_impl_thread_)
 | 
| -    scheduler_on_impl_thread_->SetNeedsCommit();
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread(
 | 
| @@ -393,53 +307,66 @@
 | 
|        layer_tree_host_impl_->GetRendererCapabilities().MainThreadCapabilities();
 | 
|  }
 | 
|  
 | 
| -void SingleThreadProxy::DidManageTiles() {
 | 
| -  // Impl-side painting only.
 | 
| -  NOTREACHED();
 | 
| -}
 | 
| -
 | 
|  void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() {
 | 
|    TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread");
 | 
| -  {
 | 
| -    DebugScopedSetMainThread main(this);
 | 
| -    // This must happen before we notify the scheduler as it may try to recreate
 | 
| -    // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE.
 | 
| -    layer_tree_host_->DidLoseOutputSurface();
 | 
| -  }
 | 
| +  // Cause a commit so we can notice the lost context.
 | 
| +  SetNeedsCommitOnImplThread();
 | 
|    client_->DidAbortSwapBuffers();
 | 
| -  if (scheduler_on_impl_thread_)
 | 
| -    scheduler_on_impl_thread_->DidLoseOutputSurface();
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::DidSwapBuffersOnImplThread() {
 | 
| -  TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersOnImplThread");
 | 
| -  if (scheduler_on_impl_thread_)
 | 
| -    scheduler_on_impl_thread_->DidSwapBuffers();
 | 
|    client_->DidPostSwapBuffers();
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() {
 | 
|    TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread");
 | 
| -  if (scheduler_on_impl_thread_)
 | 
| -    scheduler_on_impl_thread_->DidSwapBuffersComplete();
 | 
| -  layer_tree_host_->DidCompleteSwapBuffers();
 | 
| +  client_->DidCompleteSwapBuffers();
 | 
|  }
 | 
|  
 | 
| -void SingleThreadProxy::BeginFrame(const BeginFrameArgs& args) {
 | 
| -  TRACE_EVENT0("cc", "SingleThreadProxy::BeginFrame");
 | 
| -  if (scheduler_on_impl_thread_)
 | 
| -    scheduler_on_impl_thread_->BeginImplFrame(args);
 | 
| -}
 | 
| -
 | 
| +// Called by the legacy scheduling path (e.g. where render_widget does the
 | 
| +// scheduling)
 | 
|  void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) {
 | 
|    TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately");
 | 
|    DCHECK(Proxy::IsMainThread());
 | 
|    DCHECK(!layer_tree_host_->output_surface_lost());
 | 
|  
 | 
| -  DoCommit(frame_begin_time);
 | 
| +  layer_tree_host_->AnimateLayers(frame_begin_time);
 | 
|  
 | 
| +  if (PrioritizedResourceManager* contents_texture_manager =
 | 
| +          layer_tree_host_->contents_texture_manager()) {
 | 
| +    contents_texture_manager->UnlinkAndClearEvictedBackings();
 | 
| +    contents_texture_manager->SetMaxMemoryLimitBytes(
 | 
| +        layer_tree_host_impl_->memory_allocation_limit_bytes());
 | 
| +    contents_texture_manager->SetExternalPriorityCutoff(
 | 
| +        layer_tree_host_impl_->memory_allocation_priority_cutoff());
 | 
| +  }
 | 
| +
 | 
| +  scoped_ptr<ResourceUpdateQueue> queue =
 | 
| +      make_scoped_ptr(new ResourceUpdateQueue);
 | 
| +  layer_tree_host_->UpdateLayers(queue.get());
 | 
| +  layer_tree_host_->WillCommit();
 | 
| +  DoCommit(queue.Pass());
 | 
| +  layer_tree_host_->DidBeginMainFrame();
 | 
| +
 | 
|    LayerTreeHostImpl::FrameData frame;
 | 
| -  DoComposite(frame_begin_time, &frame);
 | 
| +  if (DoComposite(frame_begin_time, &frame)) {
 | 
| +    {
 | 
| +      DebugScopedSetMainThreadBlocked main_thread_blocked(this);
 | 
| +      DebugScopedSetImplThread impl(this);
 | 
| +
 | 
| +      // This CapturePostTasks should be destroyed before
 | 
| +      // DidCommitAndDrawFrame() is called since that goes out to the embedder,
 | 
| +      // and we want the embedder to receive its callbacks before that.
 | 
| +      // NOTE: This maintains consistent ordering with the ThreadProxy since
 | 
| +      // the DidCommitAndDrawFrame() must be post-tasked from the impl thread
 | 
| +      // there as the main thread is not blocked, so any posted tasks inside
 | 
| +      // the swap buffers will execute first.
 | 
| +      BlockingTaskRunner::CapturePostTasks blocked;
 | 
| +
 | 
| +      layer_tree_host_impl_->SwapBuffers(frame);
 | 
| +    }
 | 
| +    DidSwapFrame();
 | 
| +  }
 | 
|  }
 | 
|  
 | 
|  void SingleThreadProxy::AsValueInto(base::debug::TracedValue* state) const {
 | 
| @@ -479,11 +406,13 @@
 | 
|        !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer());
 | 
|  }
 | 
|  
 | 
| -DrawResult SingleThreadProxy::DoComposite(base::TimeTicks frame_begin_time,
 | 
| -                                          LayerTreeHostImpl::FrameData* frame) {
 | 
| +bool SingleThreadProxy::DoComposite(
 | 
| +    base::TimeTicks frame_begin_time,
 | 
| +    LayerTreeHostImpl::FrameData* frame) {
 | 
|    TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite");
 | 
|    DCHECK(!layer_tree_host_->output_surface_lost());
 | 
|  
 | 
| +  bool lost_output_surface = false;
 | 
|    {
 | 
|      DebugScopedSetImplThread impl(this);
 | 
|      base::AutoReset<bool> mark_inside(&inside_draw_, true);
 | 
| @@ -494,11 +423,9 @@
 | 
|      // CanDraw() as well.
 | 
|      if (!ShouldComposite()) {
 | 
|        UpdateBackgroundAnimateTicking();
 | 
| -      return DRAW_ABORTED_CANT_DRAW;
 | 
| +      return false;
 | 
|      }
 | 
|  
 | 
| -    timing_history_.DidStartDrawing();
 | 
| -
 | 
|      layer_tree_host_impl_->Animate(
 | 
|          layer_tree_host_impl_->CurrentFrameTimeTicks());
 | 
|      UpdateBackgroundAnimateTicking();
 | 
| @@ -508,43 +435,24 @@
 | 
|        layer_tree_host_impl_->DrawLayers(frame, frame_begin_time);
 | 
|        layer_tree_host_impl_->DidDrawAllLayers(*frame);
 | 
|      }
 | 
| +    lost_output_surface = layer_tree_host_impl_->IsContextLost();
 | 
|  
 | 
|      bool start_ready_animations = true;
 | 
|      layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
 | 
|  
 | 
|      layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
 | 
| -
 | 
| -    timing_history_.DidFinishDrawing();
 | 
|    }
 | 
|  
 | 
| -  {
 | 
| -    DebugScopedSetImplThread impl(this);
 | 
| -
 | 
| -    if (layer_tree_host_impl_->IsContextLost()) {
 | 
| -      DidLoseOutputSurfaceOnImplThread();
 | 
| -    } else {
 | 
| -      // This CapturePostTasks should be destroyed before
 | 
| -      // DidCommitAndDrawFrame() is called since that goes out to the
 | 
| -      // embedder,
 | 
| -      // and we want the embedder to receive its callbacks before that.
 | 
| -      // NOTE: This maintains consistent ordering with the ThreadProxy since
 | 
| -      // the DidCommitAndDrawFrame() must be post-tasked from the impl thread
 | 
| -      // there as the main thread is not blocked, so any posted tasks inside
 | 
| -      // the swap buffers will execute first.
 | 
| -      DebugScopedSetMainThreadBlocked main_thread_blocked(this);
 | 
| -
 | 
| -      BlockingTaskRunner::CapturePostTasks blocked;
 | 
| -      layer_tree_host_impl_->SwapBuffers(*frame);
 | 
| -    }
 | 
| +  if (lost_output_surface) {
 | 
| +    layer_tree_host_->DidLoseOutputSurface();
 | 
| +    return false;
 | 
|    }
 | 
| -  DidCommitAndDrawFrame();
 | 
|  
 | 
| -  return DRAW_SUCCESS;
 | 
| +  return true;
 | 
|  }
 | 
|  
 | 
| -void SingleThreadProxy::DidCommitAndDrawFrame() {
 | 
| +void SingleThreadProxy::DidSwapFrame() {
 | 
|    if (next_frame_is_newly_committed_frame_) {
 | 
| -    DebugScopedSetMainThread main(this);
 | 
|      next_frame_is_newly_committed_frame_ = false;
 | 
|      layer_tree_host_->DidCommitAndDrawFrame();
 | 
|    }
 | 
| @@ -552,117 +460,4 @@
 | 
|  
 | 
|  bool SingleThreadProxy::CommitPendingForTesting() { return false; }
 | 
|  
 | 
| -void SingleThreadProxy::SetNeedsBeginFrame(bool enable) {
 | 
| -  layer_tree_host_impl_->SetNeedsBeginFrame(enable);
 | 
| -}
 | 
| -
 | 
| -void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) {
 | 
| -  layer_tree_host_impl_->WillBeginImplFrame(args);
 | 
| -}
 | 
| -
 | 
| -void SingleThreadProxy::ScheduledActionSendBeginMainFrame() {
 | 
| -  TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame");
 | 
| -  // Although this proxy is single-threaded, it's problematic to synchronously
 | 
| -  // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame.  This
 | 
| -  // could cause a commit to occur in between a series of SetNeedsCommit calls
 | 
| -  // (i.e. property modifications) causing some to fall on one frame and some to
 | 
| -  // fall on the next.  Doing it asynchronously instead matches the semantics of
 | 
| -  // ThreadProxy::SetNeedsCommit where SetNeedsCommit will not cause a
 | 
| -  // synchronous commit.
 | 
| -  MainThreadTaskRunner()->PostTask(
 | 
| -      FROM_HERE,
 | 
| -      base::Bind(&SingleThreadProxy::BeginMainFrame,
 | 
| -                 weak_factory_.GetWeakPtr()));
 | 
| -}
 | 
| -
 | 
| -void SingleThreadProxy::BeginMainFrame() {
 | 
| -  if (defer_commits_) {
 | 
| -    DCHECK(!commit_was_deferred_);
 | 
| -    commit_was_deferred_ = true;
 | 
| -    layer_tree_host_->DidDeferCommit();
 | 
| -    return;
 | 
| -  }
 | 
| -  timing_history_.DidBeginMainFrame();
 | 
| -
 | 
| -  DCHECK(scheduler_on_impl_thread_);
 | 
| -  scheduler_on_impl_thread_->NotifyBeginMainFrameStarted();
 | 
| -  scheduler_on_impl_thread_->NotifyReadyToCommit();
 | 
| -}
 | 
| -
 | 
| -DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapIfPossible() {
 | 
| -  DebugScopedSetImplThread impl(this);
 | 
| -  if (layer_tree_host_impl_->IsContextLost()) {
 | 
| -    DidCommitAndDrawFrame();
 | 
| -    return DRAW_SUCCESS;
 | 
| -  }
 | 
| -
 | 
| -  LayerTreeHostImpl::FrameData frame;
 | 
| -  return DoComposite(layer_tree_host_impl_->CurrentFrameTimeTicks(), &frame);
 | 
| -}
 | 
| -
 | 
| -DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapForced() {
 | 
| -  NOTREACHED();
 | 
| -  return INVALID_RESULT;
 | 
| -}
 | 
| -
 | 
| -void SingleThreadProxy::ScheduledActionCommit() {
 | 
| -  DebugScopedSetMainThread main(this);
 | 
| -  DoCommit(layer_tree_host_impl_->CurrentFrameTimeTicks());
 | 
| -}
 | 
| -
 | 
| -void SingleThreadProxy::ScheduledActionAnimate() {
 | 
| -  TRACE_EVENT0("cc", "ScheduledActionAnimate");
 | 
| -  layer_tree_host_impl_->Animate(
 | 
| -      layer_tree_host_impl_->CurrentFrameTimeTicks());
 | 
| -}
 | 
| -
 | 
| -void SingleThreadProxy::ScheduledActionUpdateVisibleTiles() {
 | 
| -  // Impl-side painting only.
 | 
| -  NOTREACHED();
 | 
| -}
 | 
| -
 | 
| -void SingleThreadProxy::ScheduledActionActivateSyncTree() {
 | 
| -}
 | 
| -
 | 
| -void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() {
 | 
| -  DebugScopedSetMainThread main(this);
 | 
| -  DCHECK(scheduler_on_impl_thread_);
 | 
| -  // If possible, create the output surface in a post task.  Synchronously
 | 
| -  // creating the output surface makes tests more awkward since this differs
 | 
| -  // from the ThreadProxy behavior.  However, sometimes there is no
 | 
| -  // task runner.
 | 
| -  if (Proxy::MainThreadTaskRunner()) {
 | 
| -    MainThreadTaskRunner()->PostTask(
 | 
| -        FROM_HERE,
 | 
| -        base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface,
 | 
| -                   weak_factory_.GetWeakPtr()));
 | 
| -  } else {
 | 
| -    CreateAndInitializeOutputSurface();
 | 
| -  }
 | 
| -}
 | 
| -
 | 
| -void SingleThreadProxy::ScheduledActionManageTiles() {
 | 
| -  // Impl-side painting only.
 | 
| -  NOTREACHED();
 | 
| -}
 | 
| -
 | 
| -void SingleThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) {
 | 
| -}
 | 
| -
 | 
| -base::TimeDelta SingleThreadProxy::DrawDurationEstimate() {
 | 
| -  return timing_history_.DrawDurationEstimate();
 | 
| -}
 | 
| -
 | 
| -base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() {
 | 
| -  return timing_history_.BeginMainFrameToCommitDurationEstimate();
 | 
| -}
 | 
| -
 | 
| -base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() {
 | 
| -  return timing_history_.CommitToActivateDurationEstimate();
 | 
| -}
 | 
| -
 | 
| -void SingleThreadProxy::DidBeginImplFrameDeadline() {
 | 
| -  layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
 | 
| -}
 | 
| -
 | 
|  }  // namespace cc
 | 
| 
 |