Factor out the logic which determines how much capacity is needed for the TransferCache.
Factor out the logic which determines how much capacity is needed for the TransferCache.

PiperOrigin-RevId: 381019470
Change-Id: Ic106165e8267c83e31d8ffa0a1bc687d522f03c6

google/tcmalloc,google/tcmalloc,google/tcmalloc