gfx/layers/apz/src/TaskThrottler.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*- */
     2 /* vim: set sw=2 sts=2 ts=8 et tw=80 : */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #include "TaskThrottler.h"
     9 namespace mozilla {
    10 namespace layers {
    12 TaskThrottler::TaskThrottler(const TimeStamp& aTimeStamp)
    13   : mOutstanding(false)
    14   , mQueuedTask(nullptr)
    15   , mStartTime(aTimeStamp)
    16   , mMean(1)
    17 { }
    19 void
    20 TaskThrottler::PostTask(const tracked_objects::Location& aLocation,
    21                         CancelableTask* aTask, const TimeStamp& aTimeStamp)
    22 {
    23   aTask->SetBirthPlace(aLocation);
    25   if (mOutstanding) {
    26     if (mQueuedTask) {
    27       mQueuedTask->Cancel();
    28     }
    29     mQueuedTask = aTask;
    30   } else {
    31     mStartTime = aTimeStamp;
    32     aTask->Run();
    33     delete aTask;
    34     mOutstanding = true;
    35   }
    36 }
    38 void
    39 TaskThrottler::TaskComplete(const TimeStamp& aTimeStamp)
    40 {
    41   if (!mOutstanding) {
    42     return;
    43   }
    45   mMean.insert(aTimeStamp - mStartTime);
    47   if (mQueuedTask) {
    48     mStartTime = aTimeStamp;
    49     mQueuedTask->Run();
    50     mQueuedTask = nullptr;
    51   } else {
    52     mOutstanding = false;
    53   }
    54 }
    56 TimeDuration
    57 TaskThrottler::TimeSinceLastRequest(const TimeStamp& aTimeStamp)
    58 {
    59   return aTimeStamp - mStartTime;
    60 }
    62 }
    63 }

mercurial