dom/time/TimeManager.h
author Wes Kocher <wkocher@mozilla.com>
Mon, 09 Dec 2013 20:45:54 -0800
changeset 159631 cd37573496575d867f6951fba24584da42787081
parent 134707 4eba1004b5ebaf48aef4cb96caab9d079fdd06b1
child 167353 20a329b254aed056453d859c65a13639c293d433
permissions -rw-r--r--
Merge m-c to inbound

/* 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()
  {
#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