author Tim Huang <tihuang@mozilla.com>
Tue, 12 Dec 2017 15:25:49 -0600
changeset 398586 9c586454144b4eef9e9a8ab53e3d1a8c3f84ac3c
parent 396602 0b8cec51ffc2c3112c01901bba0cb96ab995729e
child 402306 9e42baec7ea6e7a10f4f47e9ed070be60ba9a65d
permissions -rw-r--r--
Bug 1404608 - Reveal the real operating system when fingerprinting resistance is enabled. r=arthuredelstein,smaug This patch makes Firefox not to lie about the real operating system when pref 'privacy.resistFingerprinting' is true. This will also change the testcase as well. MozReview-Commit-ID: Gdnp2lMU3wr

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

#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/Mutex.h"

class nsIRunnable;

namespace mozilla {

enum class EventPriority


// AbstractEventQueue is an abstract base class for all our unsynchronized event
// queue implementations:
// - EventQueue: A queue of runnables. Used for non-main threads.
// - PrioritizedEventQueue: Contains a queue for each priority level.
//       Has heuristics to decide which queue to pop from. Events are
//       pushed into the queue corresponding to their priority.
//       Used for the main thread.
// Since AbstractEventQueue implementations are unsynchronized, they should be
// wrapped in an outer SynchronizedEventQueue implementation (like
// ThreadEventQueue).
class AbstractEventQueue
  // Add an event to the end of the queue. Implementors are free to use
  // aPriority however they wish. They may ignore it if the runnable has its own
  // intrinsic priority (via nsIRunnablePriority).
  virtual void PutEvent(already_AddRefed<nsIRunnable>&& aEvent,
                        EventPriority aPriority,
                        const MutexAutoLock& aProofOfLock) = 0;

  // Get an event from the front of the queue. aPriority is an out param. If the
  // implementation supports priorities, then this should be the same priority
  // that the event was pushed with. aPriority may be null. This should return
  // null if the queue is non-empty but the event in front is not ready to run.
  virtual already_AddRefed<nsIRunnable> GetEvent(EventPriority* aPriority,
                                                 const MutexAutoLock& aProofOfLock) = 0;

  // Returns true if the queue is empty. Implies !HasReadyEvent().
  virtual bool IsEmpty(const MutexAutoLock& aProofOfLock) = 0;

  // Returns true if the queue is non-empty and if the event in front is ready
  // to run. Implies !IsEmpty(). This should return true iff GetEvent returns a
  // non-null value.
  virtual bool HasReadyEvent(const MutexAutoLock& aProofOfLock) = 0;

  // Returns the number of events in the queue.
  virtual size_t Count(const MutexAutoLock& aProofOfLock) const = 0;

  virtual void EnableInputEventPrioritization(const MutexAutoLock& aProofOfLock) = 0;
  virtual void FlushInputEventPrioritization(const MutexAutoLock& aProofOfLock) = 0;
  virtual void SuspendInputEventPrioritization(const MutexAutoLock& aProofOfLock) = 0;
  virtual void ResumeInputEventPrioritization(const MutexAutoLock& aProofOfLock) = 0;

  virtual ~AbstractEventQueue() {}

} // namespace mozilla

#endif // mozilla_AbstractEventQueue_h