~ubuntu-branches/ubuntu/precise/qtwebkit-source/precise

« back to all changes in this revision

Viewing changes to Source/WebCore/platform/Timer.h

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-07-20 14:43:31 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20110720144331-8w1nbdtw1jq74sjn
Tags: 2.2~2011week27-0ubuntu1
* Merge from Debian vcs, remaining changes:
  - Rename source package to qtwebkit-source.
  - Use the lzma dh sequence.
  - Add qwebview designer plugin.
  - Drop qtmobility-dev build-dependency and disable geolocation.
  - Make libqtwebkit-dev depend on ${shlibs:Depends} as we are shipping
    the qwebview designer plugin.
* Drop transitional package libqtwebkit4-declarative.
* New upstream release.
* Refresh patches.
* Drop kubuntu_01_include_files.diff, not needed anymore.
* Disable linux_amd64_no_overcommit.diff, fixed upstream.
* Disable 05_sparc_unaligned_access.diff, 06_kfreebsd_strnstr.diff and
  09_hurd.diff for now, architectures not supported on Ubuntu.
* Use the GStreamer multimedia backend.
  - Build-depend on libgstreamer0.10-dev and
    libgstreamer-plugins-base0.10-dev.
* Remove upstream Source/Makefile which makes dh_auto_clean fail.
* Fix include and lib path in qtdesigner-qwebview/qwebview.pro.
* Add README.source explaining how to create a new upstream tarball.
* Add kubuntu_fix_jit_warnings_i386.diff to fix FTBFS on i386 due to -Werror.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
7
 * 1. Redistributions of source code must retain the above copyright
 
8
 *    notice, this list of conditions and the following disclaimer.
 
9
 * 2. Redistributions in binary form must reproduce the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer in the
 
11
 *    documentation and/or other materials provided with the distribution.
 
12
 *
 
13
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
24
 */
 
25
 
 
26
#ifndef Timer_h
 
27
#define Timer_h
 
28
 
 
29
#include <wtf/Noncopyable.h>
 
30
#include <wtf/Threading.h>
 
31
 
 
32
namespace WebCore {
 
33
 
 
34
// Time intervals are all in seconds.
 
35
 
 
36
class TimerHeapElement;
 
37
 
 
38
class TimerBase {
 
39
    WTF_MAKE_NONCOPYABLE(TimerBase); WTF_MAKE_FAST_ALLOCATED;
 
40
public:
 
41
    TimerBase();
 
42
    virtual ~TimerBase();
 
43
 
 
44
    void start(double nextFireInterval, double repeatInterval);
 
45
 
 
46
    void startRepeating(double repeatInterval) { start(repeatInterval, repeatInterval); }
 
47
    void startOneShot(double interval) { start(interval, 0); }
 
48
 
 
49
    void stop();
 
50
    bool isActive() const;
 
51
 
 
52
    double nextFireInterval() const;
 
53
    double repeatInterval() const { return m_repeatInterval; }
 
54
 
 
55
    void augmentFireInterval(double delta) { setNextFireTime(m_nextFireTime + delta); }
 
56
    void augmentRepeatInterval(double delta) { augmentFireInterval(delta); m_repeatInterval += delta; }
 
57
 
 
58
    static void fireTimersInNestedEventLoop();
 
59
 
 
60
private:
 
61
    virtual void fired() = 0;
 
62
 
 
63
    void checkConsistency() const;
 
64
    void checkHeapIndex() const;
 
65
 
 
66
    void setNextFireTime(double);
 
67
 
 
68
    bool inHeap() const { return m_heapIndex != -1; }
 
69
 
 
70
    void heapDecreaseKey();
 
71
    void heapDelete();
 
72
    void heapDeleteMin();
 
73
    void heapIncreaseKey();
 
74
    void heapInsert();
 
75
    void heapPop();
 
76
    void heapPopMin();
 
77
 
 
78
    double m_nextFireTime; // 0 if inactive
 
79
    double m_repeatInterval; // 0 if not repeating
 
80
    int m_heapIndex; // -1 if not in heap
 
81
    unsigned m_heapInsertionOrder; // Used to keep order among equal-fire-time timers
 
82
 
 
83
#ifndef NDEBUG
 
84
    ThreadIdentifier m_thread;
 
85
#endif
 
86
 
 
87
    friend class TimerHeapElement;
 
88
    friend class ThreadTimers;
 
89
    friend bool operator<(const TimerHeapElement&, const TimerHeapElement&);
 
90
};
 
91
 
 
92
template <typename TimerFiredClass> class Timer : public TimerBase {
 
93
public:
 
94
    typedef void (TimerFiredClass::*TimerFiredFunction)(Timer*);
 
95
 
 
96
    Timer(TimerFiredClass* o, TimerFiredFunction f)
 
97
        : m_object(o), m_function(f) { }
 
98
 
 
99
private:
 
100
    virtual void fired() { (m_object->*m_function)(this); }
 
101
 
 
102
    TimerFiredClass* m_object;
 
103
    TimerFiredFunction m_function;
 
104
};
 
105
 
 
106
inline bool TimerBase::isActive() const
 
107
{
 
108
    ASSERT(m_thread == currentThread());
 
109
    return m_nextFireTime;
 
110
}
 
111
 
 
112
}
 
113
 
 
114
#endif