return (mFlags & THROWS_DO_ERROR_FLAG) ? NS_ERROR_FAILURE : NS_OK;
if (mLevel >= mMaxLevel) return NS_OK;  if (mFlags & BATCH_FLAG) { result = mTXMgr->BeginBatch(); if (NS_FAILED(result)) { return result; } }  PRInt32 cLevel = mLevel + 1;  for (int i = 1; i <= mNumChildrenPerNode; i++) { PRInt32 flags = mErrorFlags & THROWS_DO_ERROR_FLAG;  if ((mErrorFlags & THROWS_REDO_ERROR_FLAG) && i == mNumChildrenPerNode) {  flags = THROWS_REDO_ERROR_FLAG; mErrorFlags = mErrorFlags & (~THROWS_REDO_ERROR_FLAG); } else if ((mErrorFlags & THROWS_UNDO_ERROR_FLAG) && i == 1) {  flags = THROWS_UNDO_ERROR_FLAG; mErrorFlags = mErrorFlags & (~THROWS_UNDO_ERROR_FLAG); }  flags |= mFlags & BATCH_FLAG;  AggregateTransaction *tximpl = new AggregateTransaction(mTXMgr, cLevel, i, mMaxLevel, mNumChildrenPerNode, flags);  if (!tximpl) { printf("ERROR: Failed to allocate AggregateTransaction %d, level %d. (%d)\n", i, mLevel, result);  if (mFlags & BATCH_FLAG) mTXMgr->EndBatch();  return NS_ERROR_OUT_OF_MEMORY; }  nsITransaction *tx = 0; result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d, level %d. (%d)\n", i, mLevel, result);  if (mFlags & BATCH_FLAG) mTXMgr->EndBatch();  return result; }  result = mTXMgr->DoTransaction(tx);  if (NS_FAILED(result)) {   tx->Release();  if (mFlags & BATCH_FLAG) mTXMgr->EndBatch();  return result; }  tx->Release(); }  if (mFlags & BATCH_FLAG) mTXMgr->EndBatch();  return result;
  NS_IMETHOD DoTransaction()  {    //    // Make sure DoTransaction() is called in the order we expect!    // Notice that we don't check to see if we go past the end of the array.    // This is done on purpose since we want to crash if the order array is out    // of date.    //    if (sDoOrderArr && mVal != sDoOrderArr[sDoCount]) {      printf("ERROR: ~SimpleTransaction expected %d got %d.\n",             mVal, sDoOrderArr[sDoCount]);      exit(NS_ERROR_FAILURE);    }    ++sDoCount;#ifdef ENABLE_DEBUG_PRINTFS    printf("\nSimpleTransaction.DoTransaction: %d - 0x%.8x\n", mVal, (PRInt32)this);#endif // ENABLE_DEBUG_PRINTFS    return (mFlags & THROWS_DO_ERROR_FLAG) ? NS_ERROR_FAILURE : NS_OK;  }