mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1924513 - Remove code guarded by MOZ_SAFEBROWSING_DUMP_FAILED_UPDATES r=dimi
Differential Revision: https://phabricator.services.mozilla.com/D225508
This commit is contained in:
parent
4b060b8c46
commit
3f3edff318
@ -1081,80 +1081,6 @@ nsresult Classifier::CleanToDelete() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef MOZ_SAFEBROWSING_DUMP_FAILED_UPDATES
|
||||
|
||||
already_AddRefed<nsIFile> Classifier::GetFailedUpdateDirectroy() {
|
||||
nsCString failedUpdatekDirName = STORE_DIRECTORY + nsCString("-failedupdate");
|
||||
|
||||
nsCOMPtr<nsIFile> failedUpdatekDirectory;
|
||||
if (NS_FAILED(
|
||||
mCacheDirectory->Clone(getter_AddRefs(failedUpdatekDirectory))) ||
|
||||
NS_FAILED(failedUpdatekDirectory->AppendNative(failedUpdatekDirName))) {
|
||||
LOG(("Failed to init failedUpdatekDirectory."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return failedUpdatekDirectory.forget();
|
||||
}
|
||||
|
||||
nsresult Classifier::DumpRawTableUpdates(const nsACString& aRawUpdates) {
|
||||
LOG(("Dumping raw table updates..."));
|
||||
|
||||
DumpFailedUpdate();
|
||||
|
||||
nsCOMPtr<nsIFile> failedUpdatekDirectory = GetFailedUpdateDirectroy();
|
||||
|
||||
// Create tableupdate.bin and dump raw table update data.
|
||||
nsCOMPtr<nsIFile> rawTableUpdatesFile;
|
||||
nsCOMPtr<nsIOutputStream> outputStream;
|
||||
if (NS_FAILED(
|
||||
failedUpdatekDirectory->Clone(getter_AddRefs(rawTableUpdatesFile))) ||
|
||||
NS_FAILED(
|
||||
rawTableUpdatesFile->AppendNative(nsCString("tableupdates.bin"))) ||
|
||||
NS_FAILED(NS_NewLocalFileOutputStream(
|
||||
getter_AddRefs(outputStream), rawTableUpdatesFile,
|
||||
PR_WRONLY | PR_TRUNCATE | PR_CREATE_FILE))) {
|
||||
LOG(("Failed to create file to dump raw table updates."));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Write out the data.
|
||||
uint32_t written;
|
||||
nsresult rv = outputStream->Write(aRawUpdates.BeginReading(),
|
||||
aRawUpdates.Length(), &written);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(written == aRawUpdates.Length(), NS_ERROR_FAILURE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult Classifier::DumpFailedUpdate() {
|
||||
LOG(("Dumping failed update..."));
|
||||
|
||||
nsCOMPtr<nsIFile> failedUpdatekDirectory = GetFailedUpdateDirectroy();
|
||||
|
||||
// Remove the "failed update" directory no matter it exists or not.
|
||||
// Failure is fine because the directory may not exist.
|
||||
failedUpdatekDirectory->Remove(true);
|
||||
|
||||
nsCString failedUpdatekDirName;
|
||||
nsresult rv = failedUpdatekDirectory->GetNativeLeafName(failedUpdatekDirName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Copy the in-use directory to a clean "failed update" directory.
|
||||
nsCOMPtr<nsIFile> inUseDirectory;
|
||||
if (NS_FAILED(mRootStoreDirectory->Clone(getter_AddRefs(inUseDirectory))) ||
|
||||
NS_FAILED(inUseDirectory->CopyToNative(nullptr, failedUpdatekDirName))) {
|
||||
LOG(("Failed to move in-use to the \"failed update\" directory %s",
|
||||
failedUpdatekDirName.get()));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
#endif // MOZ_SAFEBROWSING_DUMP_FAILED_UPDATES
|
||||
|
||||
/**
|
||||
* This function copies the files one by one to the destination folder.
|
||||
* Before copying a file, it checks ::ShouldAbort and returns
|
||||
|
@ -93,10 +93,6 @@ class Classifier {
|
||||
nsresult ReadNoiseEntries(const Prefix& aPrefix, const nsACString& aTableName,
|
||||
uint32_t aCount, PrefixArray& aNoiseEntries);
|
||||
|
||||
#ifdef MOZ_SAFEBROWSING_DUMP_FAILED_UPDATES
|
||||
nsresult DumpRawTableUpdates(const nsACString& aRawUpdates);
|
||||
#endif
|
||||
|
||||
static void SplitTables(const nsACString& str, nsTArray<nsCString>& tables);
|
||||
|
||||
// Given a root store directory, return a private store directory
|
||||
@ -149,11 +145,6 @@ class Classifier {
|
||||
// and on-disk data.
|
||||
void RemoveUpdateIntermediaries();
|
||||
|
||||
#ifdef MOZ_SAFEBROWSING_DUMP_FAILED_UPDATES
|
||||
already_AddRefed<nsIFile> GetFailedUpdateDirectroy();
|
||||
nsresult DumpFailedUpdate();
|
||||
#endif
|
||||
|
||||
nsresult ScanStoreDir(nsIFile* aDirectory,
|
||||
const nsTArray<nsCString>& aExtensions,
|
||||
nsTArray<nsCString>& aTables);
|
||||
|
@ -124,9 +124,6 @@ nsresult ProtocolParserV2::AppendStream(const nsACString& aData) {
|
||||
if (!mPending.Append(aData, mozilla::fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
#ifdef MOZ_SAFEBROWSING_DUMP_FAILED_UPDATES
|
||||
mRawUpdate.Append(aData);
|
||||
#endif
|
||||
|
||||
bool done = false;
|
||||
while (!done) {
|
||||
|
@ -27,10 +27,6 @@ class ProtocolParser {
|
||||
|
||||
nsresult Status() const { return mUpdateStatus; }
|
||||
|
||||
#ifdef MOZ_SAFEBROWSING_DUMP_FAILED_UPDATES
|
||||
virtual nsCString GetRawTableUpdates() const { return mPending; }
|
||||
#endif
|
||||
|
||||
virtual void SetCurrentTable(const nsACString& aTable) = 0;
|
||||
|
||||
void SetRequestedTables(const nsTArray<nsCString>& aRequestTables) {
|
||||
@ -100,12 +96,6 @@ class ProtocolParserV2 final : public ProtocolParser {
|
||||
return mForwards;
|
||||
}
|
||||
|
||||
#ifdef MOZ_SAFEBROWSING_DUMP_FAILED_UPDATES
|
||||
// Unfortunately we have to override to return mRawUpdate which
|
||||
// will not be modified during the parsing, unlike mPending.
|
||||
virtual nsCString GetRawTableUpdates() const override { return mRawUpdate; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
virtual RefPtr<TableUpdate> CreateTableUpdate(
|
||||
const nsACString& aTableName) const override;
|
||||
@ -163,10 +153,6 @@ class ProtocolParserV2 final : public ProtocolParser {
|
||||
|
||||
// Updates to apply to the current table being parsed.
|
||||
RefPtr<TableUpdateV2> mTableUpdate;
|
||||
|
||||
#ifdef MOZ_SAFEBROWSING_DUMP_FAILED_UPDATES
|
||||
nsCString mRawUpdate; // Keep a copy of mPending before it's processed.
|
||||
#endif
|
||||
};
|
||||
|
||||
// Helpers to parse the "proto" list format.
|
||||
|
@ -734,11 +734,6 @@ nsUrlClassifierDBServiceWorker::FinishStream() {
|
||||
mTableUpdates.AppendElements(mProtocolParser->GetTableUpdates());
|
||||
mProtocolParser->ForgetTableUpdates();
|
||||
|
||||
#ifdef MOZ_SAFEBROWSING_DUMP_FAILED_UPDATES
|
||||
// The assignment involves no string copy since the source string is
|
||||
// sharable.
|
||||
mRawTableUpdates = mProtocolParser->GetRawTableUpdates();
|
||||
#endif
|
||||
} else {
|
||||
LOG(
|
||||
("nsUrlClassifierDBService::FinishStream Failed to parse the stream "
|
||||
@ -795,18 +790,8 @@ nsUrlClassifierDBServiceWorker::FinishUpdate() {
|
||||
|
||||
RefPtr<nsUrlClassifierDBServiceWorker> self = this;
|
||||
nsresult rv = mClassifier->AsyncApplyUpdates(
|
||||
mTableUpdates, [self](nsresult aRv) -> void {
|
||||
#ifdef MOZ_SAFEBROWSING_DUMP_FAILED_UPDATES
|
||||
if (NS_FAILED(aRv) && NS_ERROR_OUT_OF_MEMORY != aRv &&
|
||||
NS_ERROR_UC_UPDATE_SHUTDOWNING != aRv) {
|
||||
self->mClassifier->DumpRawTableUpdates(self->mRawTableUpdates);
|
||||
}
|
||||
// Invalidate the raw table updates.
|
||||
self->mRawTableUpdates.Truncate();
|
||||
#endif
|
||||
|
||||
self->NotifyUpdateObserver(aRv);
|
||||
});
|
||||
mTableUpdates,
|
||||
[self](nsresult aRv) -> void { self->NotifyUpdateObserver(aRv); });
|
||||
mTableUpdates.Clear(); // Classifier is working on its copy.
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -271,11 +271,6 @@ class nsUrlClassifierDBServiceWorker final : public nsIUrlClassifierDBService {
|
||||
|
||||
// list of pending lookups
|
||||
nsTArray<PendingLookup> mPendingLookups;
|
||||
|
||||
#ifdef MOZ_SAFEBROWSING_DUMP_FAILED_UPDATES
|
||||
// The raw update response for debugging.
|
||||
nsCString mRawTableUpdates;
|
||||
#endif
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsUrlClassifierDBService,
|
||||
|
@ -1140,13 +1140,6 @@ def telemetry_on_by_default(reporting, is_nightly):
|
||||
|
||||
set_define("MOZ_TELEMETRY_ON_BY_DEFAULT", True, when=telemetry_on_by_default)
|
||||
|
||||
# Safe browing
|
||||
# ==============================================================
|
||||
set_define(
|
||||
"MOZ_SAFEBROWSING_DUMP_FAILED_UPDATES", True, when=milestone.is_nightly | moz_debug
|
||||
)
|
||||
|
||||
|
||||
# Miscellaneous programs
|
||||
# ==============================================================
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user