ipc/glue/MessagePump.h
author jar@chromium.org, L. David Baron <dbaron@dbaron.org>
Thu, 21 Feb 2013 18:10:59 -0800
changeset 122585 85b91048c1cd1cbb9c389621ef425a183161c92d
parent 100623 fdd99385caaf4606f3398066d786b35db810c131
child 139598 ed39337cc38f9573bfc6a82e1680e221fe2c0a60
permissions -rw-r--r--
Bug 842550: Switch to using TimeTicks rather than Time in message loops. rs=cjones The ipc/chromium/src/base/ changes here (except those mentioned below) are the majority of the base/ changes (excluding those that patch code that does not exist yet in our copy) in: > From: jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> > Date: Sat, 6 Nov 2010 22:23:29 +0000 (+0000) > Subject: Switch to using TimeTicks rather than Time in message loops > X-Git-Url: http://git.chromium.org/gitweb/?p=chromium.git;a=commitdiff_plain;h=f592c218c18bd1f8308489aaef2e329244ced330 > > Switch to using TimeTicks rather than Time in message loops > > Switch to using TimeTicks rather than Time so that we > are not dependent on changes in the system clock. > > r=mbelshe,darin > Review URL: http://codereview.chromium.org/3884001 > > git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65322 0039d316-1c4b-4281-b951-d872f2087c98 The ipc/glue changes, and the message_pump_android.* and message_pump_qt.* changes in ipc/chromium/src/base/, change signatures to match.

/* 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/. */

#ifndef __IPC_GLUE_MESSAGEPUMP_H__
#define __IPC_GLUE_MESSAGEPUMP_H__

#include "base/basictypes.h"
#include "base/message_pump_default.h"
#include "base/time.h"

#include "nsAutoPtr.h"
#include "nsCOMPtr.h"

#include "nsIRunnable.h"
#include "nsIThread.h"
#include "nsITimer.h"
#include "mozilla/Attributes.h"

namespace mozilla {
namespace ipc {

class MessagePump;

class DoWorkRunnable MOZ_FINAL : public nsIRunnable,
                                 public nsITimerCallback
{
public:
  DoWorkRunnable(MessagePump* aPump)
  : mPump(aPump) { }

  NS_DECL_ISUPPORTS
  NS_DECL_NSIRUNNABLE
  NS_DECL_NSITIMERCALLBACK

private:
  MessagePump* mPump;
};

class MessagePump : public base::MessagePumpDefault
{

public:
  MessagePump();

  virtual void Run(base::MessagePump::Delegate* aDelegate);
  virtual void ScheduleWork();
  virtual void ScheduleWorkForNestedLoop();
  virtual void ScheduleDelayedWork(const base::TimeTicks& delayed_work_time);

  void DoDelayedWork(base::MessagePump::Delegate* aDelegate);

private:
  nsRefPtr<DoWorkRunnable> mDoWorkEvent;
  nsCOMPtr<nsITimer> mDelayedWorkTimer;

  // Weak!
  nsIThread* mThread;
};

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__ */