Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Issue 1230113012: [net] Better StopCaching() handling for HttpCache::Transaction. (Closed)

Created:
5 years, 5 months ago by asanka
Modified:
3 years, 11 months ago
CC:
cbentzel+watch_chromium.org, chromium-reviews, gavinp+disk_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[net] Better StopCaching() handling for HttpCache::Transaction. When StopCaching() is called, HttpCache::Transaction previously switched to passthrough mode. Doing so prevents the transaction from issuing any network requests or cache reads that may be necessary to fulfil the request. This resulted in premature termination of the stream in a way that is indistinguishable from successful completion. This patch changes the semantics of StopCaching() such that: * Transactions that were reading exclusively from the cache will continue reading from the cache. * Transactions that prefer the cache will use a cache entry if one exists and is able to respond to the request. * Transactions that call StopCaching() prior to Start() other than those that prefer the cache will bypass the cache and go directly to the network. * Transactions that were writing to the cache will release the cache lock on the next Read() cycle. * If a transaction was not reading from a network request that would fulfil the entire remainder of the response, it will initiate a new network request that will. BUG=89567

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Total comments: 8

Patch Set 4 : Address comments #

Patch Set 5 : Release cache lock early and request open range if it's the final range. #

Total comments: 22

Patch Set 6 : #

Patch Set 7 : #

Patch Set 8 : #

Patch Set 9 : #

Total comments: 74

Patch Set 10 : #

Patch Set 11 : #

Patch Set 12 : #

Total comments: 66

Patch Set 13 : Disallow StopCaching() before Start() and don't delete truncated entries aggressively. #

Patch Set 14 : Add missing MockTransaction initializers #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+1272 lines, -350 lines) Patch
M net/http/disk_based_cert_cache_unittest.cc View 1 2 3 1 chunk +3 lines, -3 lines 0 comments Download
M net/http/http_cache.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +17 lines, -11 lines 0 comments Download
M net/http/http_cache.cc View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +25 lines, -51 lines 0 comments Download
M net/http/http_cache_transaction.h View 1 2 3 4 5 6 7 8 9 10 11 12 7 chunks +50 lines, -18 lines 0 comments Download
M net/http/http_cache_transaction.cc View 1 2 3 4 5 6 7 8 9 10 11 12 37 chunks +279 lines, -158 lines 3 comments Download
M net/http/http_cache_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 17 chunks +752 lines, -37 lines 0 comments Download
M net/http/http_transaction.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +4 lines, -1 line 0 comments Download
M net/http/http_transaction_test_util.h View 1 2 3 4 5 6 7 8 9 10 11 12 4 chunks +17 lines, -5 lines 0 comments Download
M net/http/http_transaction_test_util.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 11 chunks +43 lines, -37 lines 1 comment Download
M net/http/mock_http_cache.h View 1 2 3 4 5 6 7 8 9 2 chunks +7 lines, -0 lines 0 comments Download
M net/http/mock_http_cache.cc View 1 2 3 4 5 6 7 8 9 2 chunks +10 lines, -0 lines 0 comments Download
M net/http/partial_data.h View 1 2 3 4 5 6 7 8 9 3 chunks +12 lines, -4 lines 0 comments Download
M net/http/partial_data.cc View 1 2 3 4 5 6 7 8 9 10 chunks +51 lines, -25 lines 0 comments Download
M net/url_request/url_request.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +2 lines, -0 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 29 (3 generated)
asanka
PTAL? hubbe: FYI since you seem to be working on the same files.
5 years, 5 months ago (2015-07-16 01:52:50 UTC) #2
asanka
On 2015/07/16 at 01:52:50, asanka wrote: > PTAL? > > hubbe: FYI since you seem ...
5 years, 5 months ago (2015-07-16 13:26:13 UTC) #3
hubbe
https://codereview.chromium.org/1230113012/diff/40001/net/http/http_cache_transaction.cc File net/http/http_cache_transaction.cc (right): https://codereview.chromium.org/1230113012/diff/40001/net/http/http_cache_transaction.cc#newcode2657 net/http/http_cache_transaction.cc:2657: DCHECK_EQ(STATE_NONE, next_state_); Shouldn't these DCHECKs go first? https://codereview.chromium.org/1230113012/diff/40001/net/http/http_cache_transaction.h File ...
5 years, 5 months ago (2015-07-16 15:56:12 UTC) #5
asanka
https://codereview.chromium.org/1230113012/diff/40001/net/http/http_cache_unittest.cc File net/http/http_cache_unittest.cc (right): https://codereview.chromium.org/1230113012/diff/40001/net/http/http_cache_unittest.cc#newcode7080 net/http/http_cache_unittest.cc:7080: // The only thing we can test right now. ...
5 years, 5 months ago (2015-07-16 16:16:58 UTC) #6
hubbe
https://codereview.chromium.org/1230113012/diff/40001/net/http/http_cache_unittest.cc File net/http/http_cache_unittest.cc (right): https://codereview.chromium.org/1230113012/diff/40001/net/http/http_cache_unittest.cc#newcode7080 net/http/http_cache_unittest.cc:7080: // The only thing we can test right now. ...
5 years, 5 months ago (2015-07-16 16:57:53 UTC) #7
asanka
https://codereview.chromium.org/1230113012/diff/40001/net/http/http_cache_transaction.cc File net/http/http_cache_transaction.cc (right): https://codereview.chromium.org/1230113012/diff/40001/net/http/http_cache_transaction.cc#newcode2657 net/http/http_cache_transaction.cc:2657: DCHECK_EQ(STATE_NONE, next_state_); On 2015/07/16 at 15:56:12, hubbe wrote: > ...
5 years, 5 months ago (2015-07-16 17:57:00 UTC) #8
rvargas (doing something else)
I've been looking at the bug report and I think that the bug is somewhere ...
5 years, 5 months ago (2015-07-16 19:22:56 UTC) #9
asanka
On 2015/07/16 at 19:22:56, rvargas wrote: > I've been looking at the bug report and ...
5 years, 5 months ago (2015-07-16 21:05:23 UTC) #10
rvargas (doing something else)
On 2015/07/16 21:05:23, asanka wrote: > On 2015/07/16 at 19:22:56, rvargas wrote: > > I've ...
5 years, 5 months ago (2015-07-16 22:59:29 UTC) #11
asanka
On 2015/07/16 at 22:59:29, rvargas wrote: > On 2015/07/16 21:05:23, asanka wrote: > > On ...
5 years, 5 months ago (2015-07-17 00:08:33 UTC) #12
asanka
On 2015/07/17 at 00:08:33, asanka wrote: > On 2015/07/16 at 22:59:29, rvargas wrote: > > ...
5 years, 5 months ago (2015-07-17 00:40:43 UTC) #13
rvargas (doing something else)
On 2015/07/17 00:40:43, asanka wrote: > On 2015/07/17 at 00:08:33, asanka wrote: > > On ...
5 years, 5 months ago (2015-07-17 01:20:01 UTC) #14
asanka
On 2015/07/17 at 01:20:01, rvargas wrote: > On 2015/07/17 00:40:43, asanka wrote: > > On ...
5 years, 5 months ago (2015-07-17 15:23:58 UTC) #15
rvargas (doing something else)
On 2015/07/17 15:23:58, asanka wrote: > On 2015/07/17 at 01:20:01, rvargas wrote: > > On ...
5 years, 5 months ago (2015-07-17 18:05:50 UTC) #16
asanka
On 2015/07/17 at 18:05:50, rvargas wrote: > On 2015/07/17 15:23:58, asanka wrote: > > On ...
5 years, 5 months ago (2015-07-17 18:58:51 UTC) #17
asanka
rvargas@ and I had an OOB conversation. As promised there, here's a brief overview of ...
5 years, 5 months ago (2015-07-20 23:18:58 UTC) #18
rvargas (doing something else)
I still think we should change the API to specify that StopCaching should not be ...
5 years, 4 months ago (2015-07-27 22:25:12 UTC) #19
asanka
Sorry about the delay. Got distracted by a few things. I've updated the description to ...
5 years, 4 months ago (2015-08-18 22:46:59 UTC) #20
rvargas (doing something else)
Thanks. https://codereview.chromium.org/1230113012/diff/80001/net/http/partial_data.cc File net/http/partial_data.cc (right): https://codereview.chromium.org/1230113012/diff/80001/net/http/partial_data.cc#newcode444 net/http/partial_data.cc:444: return byte_range_.HasLastBytePosition() On 2015/08/18 22:46:59, asanka wrote: > ...
5 years, 4 months ago (2015-08-19 23:46:39 UTC) #21
asanka
PTAL? This simplifies the HttpCache <-> HttpCache::Transaction interaction a bit by making it the Cache's ...
5 years, 3 months ago (2015-09-04 19:09:04 UTC) #22
rvargas (doing something else)
Sorry for the delay. Almost there. https://codereview.chromium.org/1230113012/diff/160001/net/http/http_cache_transaction.cc File net/http/http_cache_transaction.cc (right): https://codereview.chromium.org/1230113012/diff/160001/net/http/http_cache_transaction.cc#newcode460 net/http/http_cache_transaction.cc:460: if (stopped_caching_ && ...
5 years, 3 months ago (2015-09-11 23:56:18 UTC) #23
rvargas (doing something else)
I haven't looked at the tests in detail. https://codereview.chromium.org/1230113012/diff/220001/net/http/disk_based_cert_cache_unittest.cc File net/http/disk_based_cert_cache_unittest.cc (right): https://codereview.chromium.org/1230113012/diff/220001/net/http/disk_based_cert_cache_unittest.cc#newcode48 net/http/disk_based_cert_cache_unittest.cc:48: key, ...
5 years, 3 months ago (2015-09-15 01:07:39 UTC) #25
asanka
https://codereview.chromium.org/1230113012/diff/160001/net/http/http_cache_transaction.cc File net/http/http_cache_transaction.cc (right): https://codereview.chromium.org/1230113012/diff/160001/net/http/http_cache_transaction.cc#newcode1889 net/http/http_cache_transaction.cc:1889: // have to keep the entry around to be ...
5 years, 3 months ago (2015-09-17 21:59:41 UTC) #26
asanka
https://codereview.chromium.org/1230113012/diff/220001/net/http/http_transaction_test_util.cc File net/http/http_transaction_test_util.cc (left): https://codereview.chromium.org/1230113012/diff/220001/net/http/http_transaction_test_util.cc#oldcode52 net/http/http_transaction_test_util.cc:52: 0, On 2015/09/15 at 01:07:39, rvargas (slow to respond) ...
5 years, 3 months ago (2015-09-17 22:20:29 UTC) #27
rvargas (doing something else)
Just looking at the comments, not the new code. Sorry for the delay. https://codereview.chromium.org/1230113012/diff/160001/net/http/http_cache_transaction.cc File ...
5 years, 3 months ago (2015-09-19 01:09:35 UTC) #28
rvargas (doing something else)
5 years, 3 months ago (2015-09-21 22:06:00 UTC) #29
Looks good. I think the only big thing from PS14 is to clarify the point(s) that
we use to switch to network.

https://codereview.chromium.org/1230113012/diff/220001/net/http/http_cache_tr...
File net/http/http_cache_transaction.cc (right):

https://codereview.chromium.org/1230113012/diff/220001/net/http/http_cache_tr...
net/http/http_cache_transaction.cc:465: read_buf_len_ = buf_len;
On 2015/09/17 21:59:41, asanka wrote:
> On 2015/09/11 at 23:56:18, rvargas (slow to respond) wrote:
> > Why do we need another member? (vs io_buf_len_)
> 
> When we are switching to a single network request, the transaction might need
to
> overwrite io_buf_len_ to write the truncated bit.

Acknowledged.

https://codereview.chromium.org/1230113012/diff/220001/net/http/http_cache_tr...
net/http/http_cache_transaction.cc:1355: return 0;
On 2015/09/11 23:56:18, rvargas (slow to respond) wrote:
> nit: OK (or result).

Missed?

https://codereview.chromium.org/1230113012/diff/220001/net/http/http_cache_tr...
net/http/http_cache_transaction.cc:1799: if (request_->method != "GET") {
On 2015/09/17 21:59:41, asanka wrote:
> On 2015/09/11 at 23:56:18, rvargas (slow to respond) wrote:
> > Isn't it easier to check for this in StopCaching?
> 
> Check moved there. See earlier confusion about whether StopCaching() could be
> called before Start().

but PS14 still has the if here...

https://codereview.chromium.org/1230113012/diff/220001/net/http/http_cache_tr...
net/http/http_cache_transaction.cc:2005:
AbandonCacheEntry(CompletionCallback());
On 2015/09/17 21:59:40, asanka wrote:
> On 2015/09/11 at 23:56:18, rvargas (slow to respond) wrote:
> > This is not doing the same checks that the dtor performs.
> 
> Different circumstances.
> When we get here, the network transaction is done reading and all data from
the
> network was written to disk. Hence the condition is trying to determine how
> confident we are that the end of the network stream legitimately signalled the
> end of the resource.
> 
> In the destructor, the state of the network stream isn't known. So the
> destructor tries to determine whether the transaction received a legitimate
> response at all. If so it attempts to abandon the entry instead of marking it
as
> DOOMed.

Poor wording on my part. The destructor ends up looking at
  reading_ && response_.headers.get() &&
  (response_.headers->response_code() == 200 || partial_)

plus what AddTruncatedFlag looks at:
  partial_, CanResume() and done_reading_

The conditions for AddTruncatedFlag moved to AbandonCacheEntry, and from the
dtor itself reading_ && response_.headers.get() are implied because we are here.
That leaves 200 || partial_ (and partial_ is handled by AddTruncatedFlag).

So the only thing that seems missing is 200. Maybe it doesn't matter? (the 200
is a weak test to only do work for "normal" requests). It looks like we still
need it.

https://codereview.chromium.org/1230113012/diff/220001/net/http/http_cache_tr...
net/http/http_cache_transaction.cc:2680: ReleaseCacheEntry(mode_ == WRITE ?
EntryState::DOOMED
On 2015/09/17 21:59:41, asanka wrote:
> On 2015/09/11 at 23:56:18, rvargas (slow to respond) wrote:
> > wasn't the argument irrelevant for readers? In which case this can pass
doomed
> all the time.
> 
> mode_ == READ_WRITE also keeps the entry.

Acknowledged.

https://codereview.chromium.org/1230113012/diff/260001/net/http/http_cache_tr...
File net/http/http_cache_transaction.cc (right):

https://codereview.chromium.org/1230113012/diff/260001/net/http/http_cache_tr...
net/http/http_cache_transaction.cc:496: stopped_caching_ = true;
It looks like we set the flag when method != GET. I don't think this call makes
sense (atm) for any other method so it should be ignored if that's the case, no?

https://codereview.chromium.org/1230113012/diff/260001/net/http/http_cache_tr...
net/http/http_cache_transaction.cc:1967: // happen due to a connection problem.
In the latter case the resulting
tiny nit: maybe remove "the resulting" and "call"

https://codereview.chromium.org/1230113012/diff/260001/net/http/http_cache_tr...
net/http/http_cache_transaction.cc:3013: // Is the cache entry is sparse or if
the entry is complete? Then the entry
needs some rewording :). I guess you were going for "is foo or is bar?"

Powered by Google App Engine
This is Rietveld 408576698