Httpcache transaction's mode to be set to WRITE before creating entry describes the
code path that may lead to mode_ being set to NONE(do not use entry) and state
being set to STATE_CREATE_ENTRY.

While the intention of DoRestartPartialRequest() is to set the mode to WRITE before
setting the state to STATE_CREATE_ENTRY, ResetPartialState() ends up overwriting the
mode_ to NONE via HttpCache::Writers::EraseTransaction. Both are doing the correct
thing independently so changing the order of mode_ = WRITE and calling
ResetPartialState() should fix the issue.

This leads to another dcheck to be hit which is that RecordHistograms should only
be invoked once. To fix that this CL also moves the calling site of RecordHistograms()
to the destructor of HttpCache::Transaction which makes the invariant that RecordHistograms
should only be called once, easier to follow in the code.

TEST: net_unittests --gtest_filter=*RangeGET_OverlappingRangesCouldntConditionalize
Bug: 986211
Change-Id: I176b6187dc69aa23de73d45263da104da622e0bf
Reviewed-by: Zhongyi Shi <>
Commit-Queue: Shivani Sharma <>
Cr-Commit-Position: refs/heads/master@{#685901}
2 files changed