author | Francois Marier <francois@mozilla.com> |
Mon, 19 Oct 2015 14:13:49 -0700 | |
changeset 268422 | 4d5282dd38b8a23111ffc1b4f9488f523d00a1f8 |
parent 268421 | 835e1dd60d3c1960c2c36a760abedce85d34667f |
child 268423 | a186c0afb34f1cf5d17ac9b5c959f5f9a434a65f |
push id | 29551 |
push user | cbook@mozilla.com |
push date | Tue, 20 Oct 2015 10:01:15 +0000 |
treeherder | mozilla-central@f7b746b4e913 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | gcp |
bugs | 1215396 |
milestone | 44.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
toolkit/components/url-classifier/ProtocolParser.cpp | file | annotate | diff | comparison | revisions |
--- a/toolkit/components/url-classifier/ProtocolParser.cpp +++ b/toolkit/components/url-classifier/ProtocolParser.cpp @@ -229,17 +229,16 @@ ProtocolParser::ProcessChunkControl(cons if (StringEndsWith(mTableUpdate->TableName(), NS_LITERAL_CSTRING("-shavar")) || StringEndsWith(mTableUpdate->TableName(), NS_LITERAL_CSTRING("-simple"))) { // Accommodate test tables ending in -simple for now. mChunkState.type = (command == 'a') ? CHUNK_ADD : CHUNK_SUB; } else if (StringEndsWith(mTableUpdate->TableName(), NS_LITERAL_CSTRING("-digest256"))) { - PARSER_LOG(("Processing digest256 data")); mChunkState.type = (command == 'a') ? CHUNK_ADD_DIGEST : CHUNK_SUB_DIGEST; } nsresult rv; switch (mChunkState.type) { case CHUNK_ADD: rv = mTableUpdate->NewAddChunk(mChunkState.num); if (NS_FAILED(rv)) { return rv; @@ -308,17 +307,16 @@ ProtocolParser::ProcessChunk(bool* aDone // Pull the chunk out of the pending stream data. nsAutoCString chunk; chunk.Assign(Substring(mPending, 0, mChunkState.length)); mPending.Cut(0, mChunkState.length); *aDone = false; mState = PROTOCOL_STATE_CONTROL; - PARSER_LOG(("Handling a %d-byte chunk", chunk.Length())); if (StringEndsWith(mTableUpdate->TableName(), NS_LITERAL_CSTRING("-shavar"))) { return ProcessShaChunk(chunk); } if (StringEndsWith(mTableUpdate->TableName(), NS_LITERAL_CSTRING("-digest256"))) { return ProcessDigestChunk(chunk); } @@ -331,16 +329,18 @@ ProtocolParser::ProcessChunk(bool* aDone nsresult ProtocolParser::ProcessPlaintextChunk(const nsACString& aChunk) { if (!mTableUpdate) { NS_WARNING("Chunk received with no table."); return NS_ERROR_FAILURE; } + PARSER_LOG(("Handling a %d-byte simple chunk", aChunk.Length())); + nsTArray<nsCString> lines; ParseString(PromiseFlatCString(aChunk), '\n', lines); // non-hashed tables need to be hashed for (uint32_t i = 0; i < lines.Length(); i++) { nsCString& line = lines[i]; if (mChunkState.type == CHUNK_ADD) { @@ -404,16 +404,20 @@ ProtocolParser::ProcessShaChunk(const ns Prefix domain; domain.Assign(Substring(aChunk, start, DOMAIN_SIZE)); start += DOMAIN_SIZE; // Then a count of entries. uint8_t numEntries = static_cast<uint8_t>(aChunk[start]); start++; + PARSER_LOG(("Handling a %d-byte shavar chunk containing %u entries" + " for domain %X", aChunk.Length(), numEntries, + domain.ToUint32())); + nsresult rv; if (mChunkState.type == CHUNK_ADD && mChunkState.hashSize == PREFIX_SIZE) { rv = ProcessHostAdd(domain, numEntries, aChunk, &start); } else if (mChunkState.type == CHUNK_ADD && mChunkState.hashSize == COMPLETE_SIZE) { rv = ProcessHostAddComplete(numEntries, aChunk, &start); } else if (mChunkState.type == CHUNK_SUB && mChunkState.hashSize == PREFIX_SIZE) { rv = ProcessHostSub(domain, numEntries, aChunk, &start); } else if (mChunkState.type == CHUNK_SUB && mChunkState.hashSize == COMPLETE_SIZE) { @@ -429,16 +433,18 @@ ProtocolParser::ProcessShaChunk(const ns } return NS_OK; } nsresult ProtocolParser::ProcessDigestChunk(const nsACString& aChunk) { + PARSER_LOG(("Handling a %d-byte digest256 chunk", aChunk.Length())); + if (mChunkState.type == CHUNK_ADD_DIGEST) { return ProcessDigestAdd(aChunk); } if (mChunkState.type == CHUNK_SUB_DIGEST) { return ProcessDigestSub(aChunk); } return NS_ERROR_UNEXPECTED; } @@ -510,16 +516,17 @@ ProtocolParser::ProcessHostAdd(const Pre if (*aStart + (PREFIX_SIZE * aNumEntries) > aChunk.Length()) { NS_WARNING("Chunk is not long enough to contain the expected entries."); return NS_ERROR_FAILURE; } for (uint8_t i = 0; i < aNumEntries; i++) { Prefix hash; hash.Assign(Substring(aChunk, *aStart, PREFIX_SIZE)); + PARSER_LOG(("Add prefix %X", hash.ToUint32())); nsresult rv = mTableUpdate->NewAddPrefix(mChunkState.num, hash); if (NS_FAILED(rv)) { return rv; } *aStart += PREFIX_SIZE; } return NS_OK; @@ -540,16 +547,17 @@ ProtocolParser::ProcessHostSub(const Pre const nsCSubstring& addChunkStr = Substring(aChunk, *aStart, 4); *aStart += 4; uint32_t addChunk; memcpy(&addChunk, addChunkStr.BeginReading(), 4); addChunk = PR_ntohl(addChunk); + PARSER_LOG(("Sub prefix (addchunk=%u)", addChunk)); nsresult rv = mTableUpdate->NewSubPrefix(addChunk, aDomain, mChunkState.num); if (NS_FAILED(rv)) { return rv; } return NS_OK; } if (*aStart + ((PREFIX_SIZE + 4) * aNumEntries) > aChunk.Length()) { @@ -564,16 +572,17 @@ ProtocolParser::ProcessHostSub(const Pre uint32_t addChunk; memcpy(&addChunk, addChunkStr.BeginReading(), 4); addChunk = PR_ntohl(addChunk); Prefix prefix; prefix.Assign(Substring(aChunk, *aStart, PREFIX_SIZE)); *aStart += PREFIX_SIZE; + PARSER_LOG(("Sub prefix %X (addchunk=%u)", prefix.ToUint32(), addChunk)); nsresult rv = mTableUpdate->NewSubPrefix(addChunk, prefix, mChunkState.num); if (NS_FAILED(rv)) { return rv; } } return NS_OK; }