dom/time/TimeManager.h
author Ehsan Akhgari <ehsan.akhgari@gmail.com>
Thu, 06 Feb 2014 13:28:14 -0500
changeset 167353 20a329b254aed056453d859c65a13639c293d433
parent 134707 4eba1004b5ebaf48aef4cb96caab9d079fdd06b1
child 177628 de7487db16d9df8f72eaeb4d6cc7288b47cedb54
permissions -rw-r--r--
Bug 968643 - Part 1: Stop using [PrefControlled]; r=bzbarsky

/* 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 mozilla_dom_time_TimeManager_h
#define mozilla_dom_time_TimeManager_h

#include "mozilla/Attributes.h"
#include "nsISupports.h"
#include "nsPIDOMWindow.h"
#include "nsWrapperCache.h"

namespace mozilla {
namespace dom {

class Date;

namespace time {

class TimeManager MOZ_FINAL : public nsISupports
                            , public nsWrapperCache
{
public:
  static bool PrefEnabled(JSContext* aCx, JSObject* aGlobal)
  {
#ifdef MOZ_TIME_MANAGER
    return true;
#else
    return false;
#endif
  }

  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TimeManager)

  explicit TimeManager(nsPIDOMWindow* aWindow)
    : mWindow(aWindow)
  {
    SetIsDOMBinding();
  }

  nsPIDOMWindow* GetParentObject() const
  {
    return mWindow;
  }
  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope);

  void Set(Date& aDate);
  void Set(double aTime);

private:
  nsCOMPtr<nsPIDOMWindow> mWindow;
};

} // namespace time
} // namespace dom
} // namespace mozilla

#endif //mozilla_dom_time_TimeManager_h