mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
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 --HG-- extra : rebase_source : f9f83b1c7bd79faa40fc1d7cb594dcb14a66fe09
This commit is contained in:
parent
dcbfde282e
commit
65577c0773
@ -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)
|
||||
{
|
||||
|
@ -38,7 +38,8 @@ public:
|
||||
mRequestedTables = aRequestTables;
|
||||
}
|
||||
|
||||
nsresult Begin();
|
||||
nsresult Begin(const nsACString& aTable,
|
||||
const nsTArray<nsCString>& aUpdateTables);
|
||||
virtual nsresult AppendStream(const nsACString& aData) = 0;
|
||||
|
||||
uint32_t UpdateWaitSec() { return mUpdateWaitSec; }
|
||||
|
@ -472,13 +472,7 @@ nsUrlClassifierDBServiceWorker::BeginStream(const nsACString &table)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (!table.IsEmpty()) {
|
||||
mProtocolParser->SetCurrentTable(table);
|
||||
}
|
||||
|
||||
mProtocolParser->SetRequestedTables(mUpdateTables);
|
||||
|
||||
return NS_OK;
|
||||
return mProtocolParser->Begin(table, mUpdateTables);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -515,6 +509,8 @@ nsUrlClassifierDBServiceWorker::BeginStream(const nsACString &table)
|
||||
NS_IMETHODIMP
|
||||
nsUrlClassifierDBServiceWorker::UpdateStream(const nsACString& chunk)
|
||||
{
|
||||
MOZ_ASSERT(mProtocolParser);
|
||||
|
||||
if (gShuttingDownThread) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
@ -530,6 +526,8 @@ nsUrlClassifierDBServiceWorker::UpdateStream(const nsACString& chunk)
|
||||
NS_IMETHODIMP
|
||||
nsUrlClassifierDBServiceWorker::FinishStream()
|
||||
{
|
||||
MOZ_ASSERT(mProtocolParser);
|
||||
|
||||
if (gShuttingDownThread) {
|
||||
LOG(("shutting down"));
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
Loading…
Reference in New Issue
Block a user