Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / frame / PlatformEventController.cpp
blob41efb77d5b6e9e9f052f312b322c722af4036390
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 "config.h"
6 #include "core/frame/PlatformEventController.h"
8 #include "core/page/Page.h"
10 namespace blink {
12 PlatformEventController::PlatformEventController(Page* page)
13 : PageLifecycleObserver(page)
14 , m_hasEventListener(false)
15 , m_isActive(false)
16 , m_timer(this, &PlatformEventController::oneShotCallback)
20 PlatformEventController::~PlatformEventController()
24 void PlatformEventController::oneShotCallback(Timer<PlatformEventController>* timer)
26 ASSERT_UNUSED(timer, timer == &m_timer);
27 ASSERT(hasLastData());
28 ASSERT(!m_timer.isActive());
30 didUpdateData();
33 void PlatformEventController::startUpdating()
35 if (m_isActive)
36 return;
38 if (hasLastData() && !m_timer.isActive()) {
39 // Make sure to fire the data as soon as possible.
40 m_timer.startOneShot(0, FROM_HERE);
43 registerWithDispatcher();
44 m_isActive = true;
47 void PlatformEventController::stopUpdating()
49 if (!m_isActive)
50 return;
52 if (m_timer.isActive())
53 m_timer.stop();
55 unregisterWithDispatcher();
56 m_isActive = false;
59 void PlatformEventController::pageVisibilityChanged()
61 if (!m_hasEventListener)
62 return;
64 if (page()->visibilityState() == PageVisibilityStateVisible)
65 startUpdating();
66 else
67 stopUpdating();
70 } // namespace blink