dom/time/TimeManager.h
author btian <btian@mozilla.com>
Fri, 14 Jul 2017 09:56:33 +0800
changeset 369216 10677a3988fc028ae07c324f410d1c520bcd6082
parent 282426 e22b3043887ed36bf2c634c2924a7c8d39d226b1
child 401029 7c637da65c1fec33fc36a014485acad5413e09ea
permissions -rw-r--r--
Bug 1379925 - Part 2: Revise method |updateWith| based on spec change. r=baku MozReview-Commit-ID: FpTGFlMvl0S

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 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(nsPIDOMWindowInner* aWindow)
    : mWindow(aWindow)
  {
  }

  nsPIDOMWindowInner* GetParentObject() const
  {
    return mWindow;
  }
  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;

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

private:
  ~TimeManager() {}

  nsCOMPtr<nsPIDOMWindowInner> mWindow;
};

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

#endif //mozilla_dom_time_TimeManager_h