2012-05-21 04:12:37 -07: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 11:38:29 -07:00
|
|
|
|
|
|
|
#ifndef __IPC_GLUE_MESSAGEPUMP_H__
|
|
|
|
#define __IPC_GLUE_MESSAGEPUMP_H__
|
|
|
|
|
2009-11-23 13:01:12 -08:00
|
|
|
#include "base/basictypes.h"
|
2009-06-29 11:38:29 -07:00
|
|
|
#include "base/message_pump_default.h"
|
2009-11-23 13:01:12 -08:00
|
|
|
#include "base/time.h"
|
2009-06-29 11:38:29 -07:00
|
|
|
|
2009-11-23 13:01:12 -08:00
|
|
|
#include "nsAutoPtr.h"
|
2009-07-01 14:19:32 -07:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2009-11-23 13:01:12 -08:00
|
|
|
#include "nsIRunnable.h"
|
|
|
|
#include "nsIThread.h"
|
|
|
|
#include "nsITimer.h"
|
2012-07-26 12:17:38 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2009-07-01 14:19:32 -07:00
|
|
|
|
2009-06-29 11:38:29 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
|
2009-11-23 13:01:12 -08:00
|
|
|
class MessagePump;
|
|
|
|
|
2012-07-26 12:17:38 -07:00
|
|
|
class DoWorkRunnable MOZ_FINAL : public nsIRunnable,
|
|
|
|
public nsITimerCallback
|
2009-11-23 13:01:12 -08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DoWorkRunnable(MessagePump* aPump)
|
|
|
|
: mPump(aPump) { }
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
NS_DECL_NSITIMERCALLBACK
|
|
|
|
|
|
|
|
private:
|
|
|
|
MessagePump* mPump;
|
|
|
|
};
|
|
|
|
|
2009-06-29 11:38:29 -07:00
|
|
|
class MessagePump : public base::MessagePumpDefault
|
|
|
|
{
|
2009-11-23 13:01:12 -08:00
|
|
|
|
2009-06-29 11:38:29 -07:00
|
|
|
public:
|
2009-07-01 14:19:32 -07:00
|
|
|
MessagePump();
|
2009-06-29 11:38:29 -07:00
|
|
|
|
|
|
|
virtual void Run(base::MessagePump::Delegate* aDelegate);
|
2009-07-01 14:19:32 -07:00
|
|
|
virtual void ScheduleWork();
|
2010-08-19 13:31:47 -07:00
|
|
|
virtual void ScheduleWorkForNestedLoop();
|
2013-02-21 18:10:59 -08:00
|
|
|
virtual void ScheduleDelayedWork(const base::TimeTicks& delayed_work_time);
|
2009-11-23 13:01:12 -08:00
|
|
|
|
|
|
|
void DoDelayedWork(base::MessagePump::Delegate* aDelegate);
|
2009-07-01 14:19:32 -07:00
|
|
|
|
|
|
|
private:
|
2009-11-23 13:01:12 -08:00
|
|
|
nsRefPtr<DoWorkRunnable> mDoWorkEvent;
|
|
|
|
nsCOMPtr<nsITimer> mDelayedWorkTimer;
|
2009-07-01 14:19:32 -07:00
|
|
|
|
|
|
|
// Weak!
|
|
|
|
nsIThread* mThread;
|
2009-06-29 11:38:29 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class MessagePumpForChildProcess : public MessagePump
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MessagePumpForChildProcess()
|
|
|
|
: mFirstRun(true)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void Run(base::MessagePump::Delegate* aDelegate);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool mFirstRun;
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ipc */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
|
|
|
#endif /* __IPC_GLUE_MESSAGEPUMP_H__ */
|