editor/txmgr/nsTransactionStack.h
author Benjamin Chen <bechen@mozilla.com>
Mon, 18 Aug 2014 11:42:49 +0800
changeset 200264 53c7fcb7ead91a2bda0ec1fd26de32c8058e04dd
parent 190971 1f9ddc6738f63865f02dd7823df817ae51e29f7e
child 266617 91d4539e00cecb658604e021675a923c60ef3235
permissions -rw-r--r--
Bug 1047022 - Remove manual addref for Session object. Let MediaRecorder hold reference to Session that makes a cycle reference, break it in DestrotedRunnable(). r=roc

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 nsTransactionStack_h__
#define nsTransactionStack_h__

#include <deque>
#include "nsAutoPtr.h"

class nsCycleCollectionTraversalCallback;
class nsTransactionItem;

class nsTransactionStack
{
public:
  enum Type { FOR_UNDO, FOR_REDO };

  explicit nsTransactionStack(Type aType);
  ~nsTransactionStack();

  void Push(nsTransactionItem *aTransactionItem);
  already_AddRefed<nsTransactionItem> Pop();
  already_AddRefed<nsTransactionItem> PopBottom();
  already_AddRefed<nsTransactionItem> Peek();
  already_AddRefed<nsTransactionItem> GetItem(int32_t aIndex);
  void Clear();
  int32_t GetSize() { return mDeque.size(); }

  void DoUnlink() { Clear(); }
  void DoTraverse(nsCycleCollectionTraversalCallback &cb);

private:
  std::deque<nsRefPtr<nsTransactionItem> > mDeque;
  const Type mType;
};

#endif // nsTransactionStack_h__