2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-06-29 22:38:29 +04:00
|
|
|
|
|
|
|
#ifndef __IPC_GLUE_MESSAGEPUMP_H__
|
|
|
|
#define __IPC_GLUE_MESSAGEPUMP_H__
|
|
|
|
|
|
|
|
#include "base/message_pump_default.h"
|
2009-11-24 00:01:12 +03:00
|
|
|
#include "base/time.h"
|
2013-10-23 12:28:24 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2009-11-24 00:01:12 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2009-07-02 01:19:32 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2013-10-23 12:28:24 +04:00
|
|
|
class nsIThread;
|
|
|
|
class nsITimer;
|
2009-07-02 01:19:32 +04:00
|
|
|
|
2009-06-29 22:38:29 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
|
2013-10-23 12:28:24 +04:00
|
|
|
class DoWorkRunnable;
|
2009-11-24 00:01:12 +03:00
|
|
|
|
2013-10-23 12:28:24 +04:00
|
|
|
class MessagePump : public base::MessagePumpDefault
|
2009-11-24 00:01:12 +03:00
|
|
|
{
|
2013-10-23 12:28:24 +04:00
|
|
|
friend class DoWorkRunnable;
|
|
|
|
|
2009-11-24 00:01:12 +03:00
|
|
|
public:
|
2013-10-23 12:28:24 +04:00
|
|
|
MessagePump();
|
2009-11-24 00:01:12 +03:00
|
|
|
|
2013-10-23 12:28:24 +04:00
|
|
|
// From base::MessagePump.
|
|
|
|
virtual void
|
|
|
|
Run(base::MessagePump::Delegate* aDelegate) MOZ_OVERRIDE;
|
2009-11-24 00:01:12 +03:00
|
|
|
|
2013-10-23 12:28:24 +04:00
|
|
|
// From base::MessagePump.
|
|
|
|
virtual void
|
|
|
|
ScheduleWork() MOZ_OVERRIDE;
|
2009-11-24 00:01:12 +03:00
|
|
|
|
2013-10-23 12:28:24 +04:00
|
|
|
// From base::MessagePump.
|
|
|
|
virtual void
|
|
|
|
ScheduleWorkForNestedLoop() MOZ_OVERRIDE;
|
2009-11-24 00:01:12 +03:00
|
|
|
|
2013-10-23 12:28:24 +04:00
|
|
|
// From base::MessagePump.
|
|
|
|
virtual void
|
|
|
|
ScheduleDelayedWork(const base::TimeTicks& aDelayedWorkTime) MOZ_OVERRIDE;
|
2009-06-29 22:38:29 +04:00
|
|
|
|
2013-10-23 12:28:24 +04:00
|
|
|
protected:
|
|
|
|
virtual ~MessagePump();
|
2009-11-24 00:01:12 +03:00
|
|
|
|
2013-10-23 12:28:24 +04:00
|
|
|
private:
|
|
|
|
// Only called by DoWorkRunnable.
|
2009-11-24 00:01:12 +03:00
|
|
|
void DoDelayedWork(base::MessagePump::Delegate* aDelegate);
|
2009-07-02 01:19:32 +04:00
|
|
|
|
2013-10-23 12:28:24 +04:00
|
|
|
protected:
|
|
|
|
// mDelayedWorkTimer and mThread are set in Run() by this class or its
|
|
|
|
// subclasses.
|
2009-11-24 00:01:12 +03:00
|
|
|
nsCOMPtr<nsITimer> mDelayedWorkTimer;
|
2009-07-02 01:19:32 +04:00
|
|
|
nsIThread* mThread;
|
2013-10-23 12:28:24 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Only accessed by this class.
|
|
|
|
nsRefPtr<DoWorkRunnable> mDoWorkEvent;
|
2009-06-29 22:38:29 +04:00
|
|
|
};
|
|
|
|
|
2013-10-23 12:28:24 +04:00
|
|
|
class MessagePumpForChildProcess MOZ_FINAL: public MessagePump
|
2009-06-29 22:38:29 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
MessagePumpForChildProcess()
|
|
|
|
: mFirstRun(true)
|
|
|
|
{ }
|
|
|
|
|
2013-10-23 12:28:24 +04:00
|
|
|
virtual void Run(base::MessagePump::Delegate* aDelegate) MOZ_OVERRIDE;
|
2009-06-29 22:38:29 +04:00
|
|
|
|
|
|
|
private:
|
2013-10-23 12:28:24 +04:00
|
|
|
~MessagePumpForChildProcess()
|
|
|
|
{ }
|
|
|
|
|
2009-06-29 22:38:29 +04:00
|
|
|
bool mFirstRun;
|
|
|
|
};
|
|
|
|
|
2013-10-23 16:01:24 +04:00
|
|
|
class MessagePumpForNonMainThreads MOZ_FINAL : public MessagePump
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MessagePumpForNonMainThreads()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void Run(base::MessagePump::Delegate* aDelegate) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
private:
|
|
|
|
~MessagePumpForNonMainThreads()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2009-06-29 22:38:29 +04:00
|
|
|
} /* namespace ipc */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
|
|
|
#endif /* __IPC_GLUE_MESSAGEPUMP_H__ */
|