content: Allow reuse of large discardable memory allocations.

Instead of purging large allocations as soon as they are released,
insert them into the free list and allow them to be reused. This
improves the performance when repeatedly allocating large buffers
of a similar size.

To avoid a regression in the ability to discard memory, large
allocations can only be reused if the size is a perfect fit.

This is implemented by adding a 'slack' argument to the
SearchFreeList function. When searching the free list, only spans
that are less or equal to blocks requested + slack are considered
and worse fitting spans will be ignored.

BUG=460995
TEST=content_unittests --gtest_filter=DiscardableSharedMemoryHeapTest.Slack

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

Cr-Commit-Position: refs/heads/master@{#319907}
4 files changed