1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style license that can be
5 // found in the LICENSE file.
7 #ifndef BASE_MESSAGE_PUMP_QT_H_
8 #define BASE_MESSAGE_PUMP_QT_H_
12 #include "base/message_pump.h"
13 #include "base/time.h"
19 class MessagePumpForUI
;
21 class MessagePumpQt
: public QObject
{
25 MessagePumpQt(MessagePumpForUI
& pump
);
28 virtual bool event(QEvent
* e
);
29 void scheduleDelayedIfNeeded(const TimeTicks
& delayed_work_time
);
32 void dispatchDelayed();
35 base::MessagePumpForUI
& pump
;
39 // This class implements a MessagePump needed for TYPE_UI MessageLoops on
40 // XP_LINUX platforms using QApplication event loop
41 class MessagePumpForUI
: public MessagePump
{
46 virtual void Run(Delegate
* delegate
);
48 virtual void ScheduleWork();
49 virtual void ScheduleDelayedWork(const TimeTicks
& delayed_work_time
);
51 // Internal methods used for processing the pump callbacks. They are
52 // public for simplicity but should not be used directly.
53 // HandleDispatch is called after the poll has completed.
54 void HandleDispatch();
57 // We may make recursive calls to Run, so we save state that needs to be
58 // separate between them in this structure type.
62 // Used to flag that the current Run() invocation should return ASAP.
65 // Used to count how many Run() invocations are on the stack.
71 // This is the time when we need to do delayed work.
72 TimeTicks delayed_work_time_
;
74 // MessagePump implementation for Qt based on the GLib implement.
75 // On Qt we use a QObject base class and the
76 // default qApp in order to process events through QEventLoop.
77 MessagePumpQt qt_pump
;
79 DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI
);
84 #endif // BASE_MESSAGE_PUMP_QT_H_