Commit 5c00b854 authored by Sebastian Hengst's avatar Sebastian Hengst
Browse files

merge mozilla-inbound to mozilla-central. r=merge a=merge

MozReview-Commit-ID: AlcL6XYDkf
parents 909ee1f5 dc118fd9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
// Turn off budget throttling for the profile server
user_pref("dom.timeout.enable_budget_timer_throttling", false);

build/pgo/profileserver.py

100644 → 100755
+6 −0
Original line number Diff line number Diff line
@@ -45,13 +45,19 @@ if __name__ == '__main__':
        # TODO: refactor this into mozprofile
        prefpath = os.path.join(
            build.topsrcdir, "testing", "profiles", "prefs_general.js")
        overridepath = os.path.join(
            build.topsrcdir, "build", "pgo", "prefs_override.js")

        prefs = {}
        prefs.update(Preferences.read_prefs(prefpath))
        prefs.update(Preferences.read_prefs(overridepath))

        interpolation = {"server": "%s:%d" % httpd.httpd.server_address,
                         "OOP": "false"}
        prefs = json.loads(json.dumps(prefs) % interpolation)
        for pref in prefs:
            prefs[pref] = Preferences.cast(prefs[pref])

        profile = FirefoxProfile(profile=profilePath,
                                 preferences=prefs,
                                 addons=[os.path.join(
+107 −0
Original line number Diff line number Diff line
@@ -10,6 +10,10 @@

#include "mozilla/Base64.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/dom/IdleDeadline.h"
#include "mozilla/dom/WindowBinding.h" // For IdleRequestCallback/Options
#include "nsThreadUtils.h"

namespace mozilla {
namespace dom {
@@ -264,6 +268,109 @@ ChromeUtils::ShallowClone(GlobalObject& aGlobal,
  aRetval.set(obj);
}

namespace {
  class IdleDispatchRunnable final : public IdleRunnable
                                   , public nsITimerCallback
  {
  public:
    NS_DECL_ISUPPORTS_INHERITED

    IdleDispatchRunnable(nsIGlobalObject* aParent,
                         IdleRequestCallback& aCallback)
      : IdleRunnable("ChromeUtils::IdleDispatch")
      , mCallback(&aCallback)
      , mParent(aParent)
    {}

    NS_IMETHOD Run() override
    {
      if (mCallback) {
        CancelTimer();

        auto deadline = mDeadline - TimeStamp::ProcessCreation();

        ErrorResult rv;
        RefPtr<IdleDeadline> idleDeadline =
          new IdleDeadline(mParent, mTimedOut, deadline.ToMilliseconds());

        mCallback->Call(*idleDeadline, rv, "ChromeUtils::IdleDispatch handler");
        mCallback = nullptr;
        mParent = nullptr;

        rv.SuppressException();
        return rv.StealNSResult();
      }
      return NS_OK;
    }

    void SetDeadline(TimeStamp aDeadline) override
    {
      mDeadline = aDeadline;
    }

    NS_IMETHOD Notify(nsITimer* aTimer) override
    {
      mTimedOut = true;
      SetDeadline(TimeStamp::Now());
      return Run();
    }

    void SetTimer(uint32_t aDelay, nsIEventTarget* aTarget) override
    {
      MOZ_ASSERT(aTarget);
      MOZ_ASSERT(!mTimer);
      mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
      if (mTimer) {
        mTimer->SetTarget(aTarget);
        mTimer->InitWithCallback(this, aDelay, nsITimer::TYPE_ONE_SHOT);
      }
    }

  protected:
    virtual ~IdleDispatchRunnable()
    {
      CancelTimer();
    }

  private:
    void CancelTimer()
    {
      if (mTimer) {
        mTimer->Cancel();
        mTimer = nullptr;
      }
    }

    RefPtr<IdleRequestCallback> mCallback;
    nsCOMPtr<nsIGlobalObject> mParent;

    nsCOMPtr<nsITimer> mTimer;

    TimeStamp mDeadline{};
    bool mTimedOut = false;
  };

  NS_IMPL_ISUPPORTS_INHERITED(IdleDispatchRunnable, IdleRunnable, nsITimerCallback)
} // anonymous namespace

/* static */ void
ChromeUtils::IdleDispatch(const GlobalObject& aGlobal,
                          IdleRequestCallback& aCallback,
                          const IdleRequestOptions& aOptions,
                          ErrorResult& aRv)
{
  nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
  MOZ_ASSERT(global);

  auto runnable = MakeRefPtr<IdleDispatchRunnable>(global, aCallback);

  if (aOptions.mTimeout.WasPassed()) {
    aRv = NS_IdleDispatchToCurrentThread(runnable.forget(), aOptions.mTimeout.Value());
  } else {
    aRv = NS_IdleDispatchToCurrentThread(runnable.forget());
  }
}

/* static */ void
ChromeUtils::OriginAttributesToSuffix(dom::GlobalObject& aGlobal,
                                      const dom::OriginAttributesDictionary& aAttrs,
+7 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ class HeapSnapshot;
namespace dom {

class ArrayBufferViewOrArrayBuffer;
class IdleRequestCallback;
struct IdleRequestOptions;
class PrecompiledScript;
class Promise;

@@ -145,6 +147,11 @@ public:
                           JS::HandleObject aTarget,
                           JS::MutableHandleObject aRetval,
                           ErrorResult& aRv);

  static void IdleDispatch(const GlobalObject& global,
                           IdleRequestCallback& callback,
                           const IdleRequestOptions& options,
                           ErrorResult& aRv);
};

} // namespace dom
+25 −7
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
namespace mozilla {
namespace dom {

NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(IdleDeadline, mWindow)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(IdleDeadline, mWindow, mGlobal)
NS_IMPL_CYCLE_COLLECTING_ADDREF(IdleDeadline)
NS_IMPL_CYCLE_COLLECTING_RELEASE(IdleDeadline)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IdleDeadline)
@@ -30,6 +30,17 @@ IdleDeadline::IdleDeadline(nsPIDOMWindowInner* aWindow, bool aDidTimeout,
  : mWindow(aWindow)
  , mDidTimeout(aDidTimeout)
  , mDeadline(aDeadline)
{
  bool hasHadSHO;
  mGlobal = aWindow->GetDoc()->GetScriptHandlingObject(hasHadSHO);
}

IdleDeadline::IdleDeadline(nsIGlobalObject* aGlobal, bool aDidTimeout,
                           DOMHighResTimeStamp aDeadline)
  : mWindow(nullptr)
  , mGlobal(aGlobal)
  , mDidTimeout(aDidTimeout)
  , mDeadline(aDeadline)
{
}

@@ -50,6 +61,7 @@ IdleDeadline::TimeRemaining()
    return 0.0;
  }

  if (mWindow) {
    RefPtr<Performance> performance = mWindow->GetPerformance();
    if (!performance) {
      // If there is no performance object the window is partially torn
@@ -60,6 +72,12 @@ IdleDeadline::TimeRemaining()
    return std::max(mDeadline - performance->Now(), 0.0);
  }

  // If there's no window, we're in a system scope, and can just use
  // a high-resolution TimeStamp::Now();
  auto timestamp = TimeStamp::Now() - TimeStamp::ProcessCreation();
  return std::max(mDeadline - timestamp.ToMilliseconds(), 0.0);
}

bool
IdleDeadline::DidTimeout() const
{
Loading