зеркало из https://github.com/mozilla/gecko-dev.git
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 : 53398213bf38e582248f1954bbdb46fd53348e40
This commit is contained in:
Родитель
10fe9ddbf2
Коммит
777fb5e47f
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -519,6 +513,8 @@ nsUrlClassifierDBServiceWorker::UpdateStream(const nsACString& chunk)
|
|||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mProtocolParser);
|
||||
|
||||
NS_ENSURE_STATE(mInStream);
|
||||
|
||||
HandlePendingLookups();
|
||||
|
@ -535,6 +531,8 @@ nsUrlClassifierDBServiceWorker::FinishStream()
|
|||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mProtocolParser);
|
||||
|
||||
NS_ENSURE_STATE(mInStream);
|
||||
NS_ENSURE_STATE(mUpdateObserver);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче