ipc/chromium/src/base/message_pump_qt.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Copyright (c) 2010 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 #ifndef BASE_MESSAGE_PUMP_QT_H_
     6 #define BASE_MESSAGE_PUMP_QT_H_
     8 #include <qobject.h>
    10 #include "base/message_pump.h"
    11 #include "base/time.h"
    13 class QTimer;
    15 namespace base {
    17 class MessagePumpForUI;
    19 class MessagePumpQt : public QObject {
    20   Q_OBJECT
    22  public:
    23   MessagePumpQt(MessagePumpForUI &pump);
    24   ~MessagePumpQt();
    26   virtual bool event (QEvent *e);
    27   void scheduleDelayedIfNeeded(const TimeTicks& delayed_work_time);
    29  public Q_SLOTS:
    30   void dispatchDelayed();
    32  private:
    33   base::MessagePumpForUI &pump;
    34   QTimer* mTimer;
    35 };
    37 // This class implements a MessagePump needed for TYPE_UI MessageLoops on
    38 // OS_LINUX platforms using QApplication event loop
    39 class MessagePumpForUI : public MessagePump {
    41  public:
    42   MessagePumpForUI();
    43   ~MessagePumpForUI();
    45   virtual void Run(Delegate* delegate);
    46   virtual void Quit();
    47   virtual void ScheduleWork();
    48   virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time);
    50   // Internal methods used for processing the pump callbacks.  They are
    51   // public for simplicity but should not be used directly.
    52   // HandleDispatch is called after the poll has completed.
    53   void HandleDispatch();
    55  private:
    56   // We may make recursive calls to Run, so we save state that needs to be
    57   // separate between them in this structure type.
    58   struct RunState {
    59     Delegate* delegate;
    61     // Used to flag that the current Run() invocation should return ASAP.
    62     bool should_quit;
    64     // Used to count how many Run() invocations are on the stack.
    65     int run_depth;
    66   };
    68   RunState* state_;
    70   // This is the time when we need to do delayed work.
    71   TimeTicks delayed_work_time_;
    73   // MessagePump implementation for Qt based on the GLib implement.
    74   // On Qt we use a QObject base class and the
    75   // default qApp in order to process events through QEventLoop.
    76   MessagePumpQt qt_pump;
    78   DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI);
    79 };
    81 }  // namespace base
    83 #endif  // BASE_MESSAGE_PUMP_QT_H_

mercurial