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