Bug 1434662 - Move initialization code to ProtocolParser::Begin(). r=gcp

Repurpose the previously unused Begin() function to initialize
ProtocolParser objects and also assert that we are not reusing
objects across update since that's not supported.

MozReview-Commit-ID: HIGGgOr388h
This commit is contained in:
Francois Marier
2018-04-19 17:10:45 -07:00
parent 24b2416f1a
commit 4974622a06
3 changed files with 26 additions and 8 deletions

View File

@@ -90,6 +90,25 @@ ProtocolParser::CleanupUpdates()
mTableUpdates.Clear();
}
nsresult
ProtocolParser::Begin(const nsACString& aTable,
const nsTArray<nsCString>& aUpdateTables)
{
// ProtocolParser objects should never be reused.
MOZ_ASSERT(mPending.IsEmpty());
MOZ_ASSERT(mTableUpdates.IsEmpty());
MOZ_ASSERT(mForwards.IsEmpty());
MOZ_ASSERT(mRequestedTables.IsEmpty());
MOZ_ASSERT(mTablesToReset.IsEmpty());
if (!aTable.IsEmpty()) {
SetCurrentTable(aTable);
}
SetRequestedTables(aUpdateTables);
return NS_OK;
}
TableUpdate *
ProtocolParser::GetTableUpdate(const nsACString& aTable)
{