Reland of Implement cache counting for the simple and memory backends - with fixed tests.

Patchset #1 is a reland of https://codereview.chromium.org/1398053002/ which was reverted in https://codereview.chromium.org/1401053004/.

Patchset #2 is a quick fix of the failing unittest which caused the revert.

==========================================================

Reland of Implement cache counting for the simple and memory backends. (patchset #1 id:1 of https://codereview.chromium.org/1401053004/ )

Reason for revert:
The original CL was reverted because of a failing unittest. The results in the unittest are off by 8 bytes. 8 bytes is the size of the second-to-last entry, which is the last one where we wrote to the stream #1. As the comment in this unittest already mentions, writing to the stream #1 triggers another operation that is asynchronous and can possibly happen after the call to CalculateSizeOfAllEntries. Apparently, this didn't happen on Linux, but it did happen on Windows.

The test can be fixed by only writing to the stream #0.

Original issue's description:
> Revert of Implement cache counting for the simple and memory backends. (patchset #3 id:40001 of https://codereview.chromium.org/1398053002/ )
>
> Reason for revert:
> Causes test failures on XP bot:
> https://build.chromium.org/p/chromium.win/builders/XP%20Tests%20%281%29/builds/40465/steps/net_unittests%20on%20Windows-XP-SP3/logs/DiskCacheBackendTest.SimpleCacheCalculateSizeOfAllEntries
>
> DiskCacheBackendTest.SimpleCacheCalculateSizeOfAllEntries (run #1):
> [ RUN      ] DiskCacheBackendTest.SimpleCacheCalculateSizeOfAllEntries
> c:uild\slave\win_builderuild\src
> et\disk_cacheackend_unittest.cc(1730): error: Value of: result
>   Actual: 7447
> Expected: (count - 1) * count / 2 + total_metadata_size
> Which is: 7455
> c:uild\slave\win_builderuild\src
> et\disk_cacheackend_unittest.cc(1747): error: Value of: new_result
>   Actual: 8243
> Expected: result + last_entry_size + GetEntryMetadataSize(key)
> Which is: 8235
> c:uild\slave\win_builderuild\src
> et\disk_cacheackend_unittest.cc(1751): error: Value of: new_result
>   Actual: 7455
> Expected: result
> Which is: 7447
> [  FAILED  ] DiskCacheBackendTest.SimpleCacheCalculateSizeOfAllEntries (171 ms)
>
> Original issue's description:
> > Implement cache counting for the simple and memory backends.
> >
> > This is a followup to https://codereview.chromium.org/1304363013/, which implemented it for the blockfile backend.
> >
> > BUG=510028
> >
> > Committed: https://crrev.com/a319545886d0e297b88301f01b804432bea602f7
> > Cr-Commit-Position: refs/heads/master@{#354037}
>
> TBR=gavinp@chromium.org,pasko@chromium.org,ttuttle@chromium.org,msramek@chromium.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=510028
>
> Committed: https://crrev.com/81c61dd0811b103aeca08e1a5184db725fdb19fb
> Cr-Commit-Position: refs/heads/master@{#354118}

R=gavinp@chromium.org,pasko@chromium.org,ttuttle@chromium.org,mpearson@chromium.org
TBR=gavinp@chromium.org
BUG=510028

Review URL: https://codereview.chromium.org/1401923006

Cr-Commit-Position: refs/heads/master@{#354757}
6 files changed