author Mike Hommey <>
Thu, 26 Mar 2015 12:07:17 +0900
changeset 258314 fc1e894eec2fbd34b745cd94f505080427d24705
parent 257987 a20c7910a82fa2df2f3398c1108d102bac9128b0
child 285571 76f11db99d95ba24e6994d202604970ce5dc57b7
permissions -rw-r--r--
Bug 1147207 - Add a ComposedFinder class that acts like a FileFinder proxy over multiple FileFinders. r=gps, a=sledru

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 */

#ifndef GMPTimerParent_h_
#define GMPTimerParent_h_

#include "mozilla/gmp/PGMPTimerParent.h"
#include "nsITimer.h"
#include "nsCOMPtr.h"
#include "nsClassHashtable.h"
#include "nsHashKeys.h"
#include "nsAutoPtr.h"
#include "mozilla/Monitor.h"
#include "nsIThread.h"

namespace mozilla {
namespace gmp {

class GMPTimerParent : public PGMPTimerParent {
  explicit GMPTimerParent(nsIThread* aGMPThread);

  void Shutdown();

  virtual bool RecvSetTimer(const uint32_t& aTimerId,
                            const uint32_t& aTimeoutMs) override;
  virtual void ActorDestroy(ActorDestroyReason aWhy) override;

  ~GMPTimerParent() {}

  static void GMPTimerExpired(nsITimer *aTimer, void *aClosure);

  struct Context {
    Context() {
    ~Context() {
    nsCOMPtr<nsITimer> mTimer;
    nsRefPtr<GMPTimerParent> mParent; // Note: live timers keep the GMPTimerParent alive.
    uint32_t mId;

  static PLDHashOperator
  CancelTimers(nsPtrHashKey<Context>* aContext, void* aClosure);

  void TimerExpired(Context* aContext);

  nsTHashtable<nsPtrHashKey<Context>> mTimers;

  nsCOMPtr<nsIThread> mGMPThread;

  bool mIsOpen;

} // namespace gmp
} // namespace mozilla

#endif // GMPTimerParent_h_