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__
|
|
|
|
|
|
|
|
#include "base/message_pump_default.h"
|
2009-11-23 21:01:12 +00:00
|
|
|
#include "base/time.h"
|
2013-10-23 08:28:24 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2009-11-23 21:01:12 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2009-07-01 21:19:32 +00:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2013-10-23 08:28:24 +00:00
|
|
|
class nsIThread;
|
|
|
|
class nsITimer;
|
2009-07-01 21:19:32 +00:00
|
|
|
|
2009-06-29 18:38:29 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
|
2013-10-23 08:28:24 +00:00
|
|
|
class DoWorkRunnable;
|
2009-11-23 21:01:12 +00:00
|
|
|
|
2013-10-23 08:28:24 +00:00
|
|
|
class MessagePump : public base::MessagePumpDefault
|
2009-11-23 21:01:12 +00:00
|
|
|
{
|
2013-10-23 08:28:24 +00:00
|
|
|
friend class DoWorkRunnable;
|
|
|
|
|
2009-11-23 21:01:12 +00:00
|
|
|
public:
|
2013-10-23 08:28:24 +00:00
|
|
|
MessagePump();
|
2009-11-23 21:01:12 +00:00
|
|
|
|
2013-10-23 08:28:24 +00:00
|
|
|
// From base::MessagePump.
|
|
|
|
virtual void
|
|
|
|
Run(base::MessagePump::Delegate* aDelegate) MOZ_OVERRIDE;
|
2009-11-23 21:01:12 +00:00
|
|
|
|
2013-10-23 08:28:24 +00:00
|
|
|
// From base::MessagePump.
|
|
|
|
virtual void
|
|
|
|
ScheduleWork() MOZ_OVERRIDE;
|
2009-11-23 21:01:12 +00:00
|
|
|
|
2013-10-23 08:28:24 +00:00
|
|
|
// From base::MessagePump.
|
|
|
|
virtual void
|
|
|
|
ScheduleWorkForNestedLoop() MOZ_OVERRIDE;
|
2009-11-23 21:01:12 +00:00
|
|
|
|
2013-10-23 08:28:24 +00:00
|
|
|
// From base::MessagePump.
|
|
|
|
virtual void
|
|
|
|
ScheduleDelayedWork(const base::TimeTicks& aDelayedWorkTime) MOZ_OVERRIDE;
|
2009-06-29 18:38:29 +00:00
|
|
|
|
2013-10-23 08:28:24 +00:00
|
|
|
protected:
|
|
|
|
virtual ~MessagePump();
|
2009-11-23 21:01:12 +00:00
|
|
|
|
2013-10-23 08:28:24 +00:00
|
|
|
private:
|
|
|
|
// Only called by DoWorkRunnable.
|
2009-11-23 21:01:12 +00:00
|
|
|
void DoDelayedWork(base::MessagePump::Delegate* aDelegate);
|
2009-07-01 21:19:32 +00:00
|
|
|
|
2013-10-23 08:28:24 +00:00
|
|
|
protected:
|
|
|
|
// mDelayedWorkTimer and mThread are set in Run() by this class or its
|
|
|
|
// subclasses.
|
2009-11-23 21:01:12 +00:00
|
|
|
nsCOMPtr<nsITimer> mDelayedWorkTimer;
|
2009-07-01 21:19:32 +00:00
|
|
|
nsIThread* mThread;
|
2013-10-23 08:28:24 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Only accessed by this class.
|
|
|
|
nsRefPtr<DoWorkRunnable> mDoWorkEvent;
|
2009-06-29 18:38:29 +00:00
|
|
|
};
|
|
|
|
|
2013-10-23 08:28:24 +00:00
|
|
|
class MessagePumpForChildProcess MOZ_FINAL: public MessagePump
|
2009-06-29 18:38:29 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
MessagePumpForChildProcess()
|
|
|
|
: mFirstRun(true)
|
|
|
|
{ }
|
|
|
|
|
2013-10-23 08:28:24 +00:00
|
|
|
virtual void Run(base::MessagePump::Delegate* aDelegate) MOZ_OVERRIDE;
|
2009-06-29 18:38:29 +00:00
|
|
|
|
|
|
|
private:
|
2013-10-23 08:28:24 +00:00
|
|
|
~MessagePumpForChildProcess()
|
|
|
|
{ }
|
|
|
|
|
2009-06-29 18:38:29 +00:00
|
|
|
bool mFirstRun;
|
|
|
|
};
|
|
|
|
|
2013-10-23 12:01:24 +00:00
|
|
|
class MessagePumpForNonMainThreads MOZ_FINAL : public MessagePump
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MessagePumpForNonMainThreads()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void Run(base::MessagePump::Delegate* aDelegate) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
private:
|
|
|
|
~MessagePumpForNonMainThreads()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2009-06-29 18:38:29 +00:00
|
|
|
} /* namespace ipc */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
|
|
|
#endif /* __IPC_GLUE_MESSAGEPUMP_H__ */
|