1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72

ash / wm / overview / delayed_animation_observer_impl.cc [blame]

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/wm/overview/delayed_animation_observer_impl.h"

#include "ash/wm/overview/overview_delegate.h"
#include "base/functional/bind.h"
#include "base/task/single_thread_task_runner.h"

namespace ash {

ForceDelayObserver::ForceDelayObserver(base::TimeDelta delay) {
  base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
      FROM_HERE,
      base::BindOnce(&ForceDelayObserver::Finish,
                     weak_ptr_factory_.GetWeakPtr()),
      delay);
}

ForceDelayObserver::~ForceDelayObserver() = default;

void ForceDelayObserver::SetOwner(OverviewDelegate* owner) {
  owner_ = owner;
}

void ForceDelayObserver::Shutdown() {
  owner_ = nullptr;
}

void ForceDelayObserver::Finish() {
  if (owner_)
    owner_->RemoveAndDestroyEnterAnimationObserver(this);
}

EnterAnimationObserver::EnterAnimationObserver() = default;

EnterAnimationObserver::~EnterAnimationObserver() = default;

void EnterAnimationObserver::OnImplicitAnimationsCompleted() {
  if (owner_)
    owner_->RemoveAndDestroyEnterAnimationObserver(this);
}

void EnterAnimationObserver::SetOwner(OverviewDelegate* owner) {
  DCHECK(!owner_);
  owner_ = owner;
}

void EnterAnimationObserver::Shutdown() {
  owner_ = nullptr;
}

ExitAnimationObserver::ExitAnimationObserver() = default;

ExitAnimationObserver::~ExitAnimationObserver() = default;

void ExitAnimationObserver::OnImplicitAnimationsCompleted() {
  if (owner_)
    owner_->RemoveAndDestroyExitAnimationObserver(this);
}

void ExitAnimationObserver::SetOwner(OverviewDelegate* owner) {
  DCHECK(!owner_);
  owner_ = owner;
}

void ExitAnimationObserver::Shutdown() {
  owner_ = nullptr;
}

}  // namespace ash