Lazily build the app list model.
[chromium-blink-merge.git] / ui / compositor / compositor_vsync_manager.cc
blobf51847ca7bf2cf508c5d7a456bb55ee0e0dd22ba
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/compositor/compositor_vsync_manager.h"
7 namespace ui {
9 CompositorVSyncManager::CompositorVSyncManager()
10 : authoritative_vsync_interval_(base::TimeDelta::FromSeconds(0)) {
13 CompositorVSyncManager::~CompositorVSyncManager() {}
15 void CompositorVSyncManager::SetAuthoritativeVSyncInterval(
16 base::TimeDelta interval) {
17 authoritative_vsync_interval_ = interval;
18 last_interval_ = interval;
19 NotifyObservers(last_timebase_, last_interval_);
22 void CompositorVSyncManager::UpdateVSyncParameters(base::TimeTicks timebase,
23 base::TimeDelta interval) {
24 if (authoritative_vsync_interval_ != base::TimeDelta::FromSeconds(0))
25 interval = authoritative_vsync_interval_;
26 last_timebase_ = timebase;
27 last_interval_ = interval;
28 NotifyObservers(timebase, interval);
31 void CompositorVSyncManager::AddObserver(Observer* observer) {
32 observer_list_.AddObserver(observer);
33 observer->OnUpdateVSyncParameters(last_timebase_, last_interval_);
36 void CompositorVSyncManager::RemoveObserver(Observer* observer) {
37 observer_list_.RemoveObserver(observer);
40 void CompositorVSyncManager::NotifyObservers(base::TimeTicks timebase,
41 base::TimeDelta interval) {
42 FOR_EACH_OBSERVER(CompositorVSyncManager::Observer, observer_list_,
43 OnUpdateVSyncParameters(timebase, interval));
46 } // namespace ui