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

Issue 13880016: Make SimpleEntryImpl ref counted. (Closed)

Created:
7 years, 8 months ago by gavinp
Modified:
7 years, 8 months ago
CC:
chromium-reviews, cbentzel+watch_chromium.org, gavinp+disk_chromium.org
Visibility:
Public.

Description

Make SimpleEntryImpl ref counted. Upcoming work for multiple operations, CRC calculation, etc... have made the lifetime of the SimpleEntryImpl more tricky. By adding ref counting, asynchronous operations are guaranteed access to the entry after execution. R=pasko@chromium.org,felipeg@chromium.org,rvargas@chromium.org BUG=None Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=194591

Patch Set 1 #

Patch Set 2 : a little bit cleaner #

Patch Set 3 : rebase #

Patch Set 4 : rebase #

Patch Set 5 : rebase #

Total comments: 4

Patch Set 6 : fix build #

Patch Set 7 : rebase upstream remediation #

Patch Set 8 : remediation #

Total comments: 2

Patch Set 9 : rebase to upstream remediation #

Patch Set 10 : add comment per felipeg #

Patch Set 11 : rebase #

Total comments: 6

Patch Set 12 : rebase to trunk #

Patch Set 13 : remediate #

Patch Set 14 : fix comments #

Total comments: 10

Patch Set 15 : rebase onto trunk #

Patch Set 16 : remediation #

Total comments: 5

Patch Set 17 : remove last vestigal weak ptr stuff #

Total comments: 3

Patch Set 18 : pliard remediation #

Patch Set 19 : fix windows build #

Total comments: 3

Patch Set 20 : Delete right #

Patch Set 21 : remove flaky dchecks #

Total comments: 12
Unified diffs Side-by-side diffs Delta from patch set Stats (+95 lines, -111 lines) Patch
M net/disk_cache/simple/simple_backend_impl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 3 chunks +3 lines, -3 lines 1 comment Download
M net/disk_cache/simple/simple_backend_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +3 lines, -5 lines 1 comment Download
M net/disk_cache/simple/simple_entry_impl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 5 chunks +22 lines, -26 lines 0 comments Download
M net/disk_cache/simple/simple_entry_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 10 chunks +59 lines, -69 lines 7 comments Download
M net/disk_cache/simple/simple_index.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +5 lines, -4 lines 0 comments Download
M net/disk_cache/simple/simple_index.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +1 line, -2 lines 0 comments Download
M net/disk_cache/simple/simple_synchronous_entry.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +1 line, -1 line 1 comment Download
M net/disk_cache/simple/simple_synchronous_entry.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +1 line, -1 line 2 comments Download

Messages

Total messages: 30 (0 generated)
gavinp
PTAL. I think the time has come.
7 years, 8 months ago (2013-04-11 18:17:53 UTC) #1
pasko-google - do not use
Looks nice! Is it possible to add a test for counting the number of refs ...
7 years, 8 months ago (2013-04-12 14:21:43 UTC) #2
felipeg
LGTM only nits https://codereview.chromium.org/13880016/diff/8002/net/disk_cache/simple/simple_entry_impl.cc File net/disk_cache/simple/simple_entry_impl.cc (right): https://codereview.chromium.org/13880016/diff/8002/net/disk_cache/simple/simple_entry_impl.cc#newcode111 net/disk_cache/simple/simple_entry_impl.cc:111: self_ = NULL; should we DCHECK ...
7 years, 8 months ago (2013-04-12 15:52:19 UTC) #3
gavinp
https://codereview.chromium.org/13880016/diff/8002/net/disk_cache/simple/simple_entry_impl.cc File net/disk_cache/simple/simple_entry_impl.cc (right): https://codereview.chromium.org/13880016/diff/8002/net/disk_cache/simple/simple_entry_impl.cc#newcode111 net/disk_cache/simple/simple_entry_impl.cc:111: self_ = NULL; On 2013/04/12 15:52:19, felipeg1 wrote: > ...
7 years, 8 months ago (2013-04-13 08:54:35 UTC) #4
gavinp
On 2013/04/12 14:21:43, pasko wrote: > Looks nice! > Is it possible to add a ...
7 years, 8 months ago (2013-04-13 08:55:17 UTC) #5
gavinp
+rvargas. Can you please take a look?
7 years, 8 months ago (2013-04-13 09:02:57 UTC) #6
felipeg
LGTM https://codereview.chromium.org/13880016/diff/22001/net/disk_cache/simple/simple_entry_impl.cc File net/disk_cache/simple/simple_entry_impl.cc (right): https://codereview.chromium.org/13880016/diff/22001/net/disk_cache/simple/simple_entry_impl.cc#newcode115 net/disk_cache/simple/simple_entry_impl.cc:115: DCHECK(!in_use || (in_use && HasOneRef())); would it be ...
7 years, 8 months ago (2013-04-13 12:20:43 UTC) #7
gavinp
https://codereview.chromium.org/13880016/diff/22001/net/disk_cache/simple/simple_entry_impl.cc File net/disk_cache/simple/simple_entry_impl.cc (right): https://codereview.chromium.org/13880016/diff/22001/net/disk_cache/simple/simple_entry_impl.cc#newcode115 net/disk_cache/simple/simple_entry_impl.cc:115: DCHECK(!in_use || (in_use && HasOneRef())); On 2013/04/13 12:20:43, felipeg1 ...
7 years, 8 months ago (2013-04-13 12:28:09 UTC) #8
gavinp
Hi Ricardo, Can you please take a look at this CL?
7 years, 8 months ago (2013-04-15 19:44:04 UTC) #9
rvargas (doing something else)
https://codereview.chromium.org/13880016/diff/31001/net/disk_cache/simple/simple_entry_impl.cc File net/disk_cache/simple/simple_entry_impl.cc (right): https://codereview.chromium.org/13880016/diff/31001/net/disk_cache/simple/simple_entry_impl.cc#newcode47 net/disk_cache/simple/simple_entry_impl.cc:47: *entry = new_entry.get(); Although strictly not required by anything, ...
7 years, 8 months ago (2013-04-15 22:07:27 UTC) #10
rvargas (doing something else)
And remove references to future CLs from the description... just describe what this CL does.
7 years, 8 months ago (2013-04-15 22:09:44 UTC) #11
gavinp
https://codereview.chromium.org/13880016/diff/31001/net/disk_cache/simple/simple_entry_impl.cc File net/disk_cache/simple/simple_entry_impl.cc (right): https://codereview.chromium.org/13880016/diff/31001/net/disk_cache/simple/simple_entry_impl.cc#newcode47 net/disk_cache/simple/simple_entry_impl.cc:47: *entry = new_entry.get(); On 2013/04/15 22:07:27, rvargas wrote: > ...
7 years, 8 months ago (2013-04-16 08:41:55 UTC) #12
gavinp
+pliard
7 years, 8 months ago (2013-04-16 08:43:50 UTC) #13
gavinp
+digit Some context for newcomers: this CL changes the way we meet the promises of ...
7 years, 8 months ago (2013-04-16 09:37:45 UTC) #14
digit
https://codereview.chromium.org/13880016/diff/55003/net/disk_cache/simple/simple_entry_impl.cc File net/disk_cache/simple/simple_entry_impl.cc (right): https://codereview.chromium.org/13880016/diff/55003/net/disk_cache/simple/simple_entry_impl.cc#newcode51 net/disk_cache/simple/simple_entry_impl.cc:51: base::Bind(&SimpleSynchronousEntry::OpenEntry, path, This callback will be destroyed in the ...
7 years, 8 months ago (2013-04-16 10:21:32 UTC) #15
gavinp
https://codereview.chromium.org/13880016/diff/55003/net/disk_cache/simple/simple_entry_impl.cc File net/disk_cache/simple/simple_entry_impl.cc (right): https://codereview.chromium.org/13880016/diff/55003/net/disk_cache/simple/simple_entry_impl.cc#newcode51 net/disk_cache/simple/simple_entry_impl.cc:51: base::Bind(&SimpleSynchronousEntry::OpenEntry, path, On 2013/04/16 10:21:32, digit wrote: > This ...
7 years, 8 months ago (2013-04-17 09:52:46 UTC) #16
gavinp
digit, pliard: PTAL now.
7 years, 8 months ago (2013-04-17 09:52:59 UTC) #17
Philippe
Thanks Gavin! This mostly looks good to me. See my comment about scoped_refptr. https://codereview.chromium.org/13880016/diff/55003/net/disk_cache/simple/simple_entry_impl.cc File ...
7 years, 8 months ago (2013-04-17 10:19:22 UTC) #18
gavinp
https://codereview.chromium.org/13880016/diff/55003/net/disk_cache/simple/simple_entry_impl.cc File net/disk_cache/simple/simple_entry_impl.cc (right): https://codereview.chromium.org/13880016/diff/55003/net/disk_cache/simple/simple_entry_impl.cc#newcode10 net/disk_cache/simple/simple_entry_impl.cc:10: #include "base/location.h" On 2013/04/17 10:19:22, Philippe wrote: > Nit: ...
7 years, 8 months ago (2013-04-17 10:56:28 UTC) #19
gavinp
https://codereview.chromium.org/13880016/diff/2003/net/disk_cache/simple/simple_entry_impl.cc File net/disk_cache/simple/simple_entry_impl.cc (right): https://codereview.chromium.org/13880016/diff/2003/net/disk_cache/simple/simple_entry_impl.cc#newcode256 net/disk_cache/simple/simple_entry_impl.cc:256: WorkerPool::PostTask(FROM_HERE, Wait, worker pool can't post to worker pool.
7 years, 8 months ago (2013-04-17 11:02:20 UTC) #20
felipeg
https://codereview.chromium.org/13880016/diff/2003/net/disk_cache/simple/simple_entry_impl.cc File net/disk_cache/simple/simple_entry_impl.cc (right): https://codereview.chromium.org/13880016/diff/2003/net/disk_cache/simple/simple_entry_impl.cc#newcode108 net/disk_cache/simple/simple_entry_impl.cc:108: bool in_use = synchronous_entry_in_use_by_worker_; can you add a comment ...
7 years, 8 months ago (2013-04-17 11:48:25 UTC) #21
Philippe
https://codereview.chromium.org/13880016/diff/2003/net/disk_cache/simple/simple_entry_impl.cc File net/disk_cache/simple/simple_entry_impl.cc (right): https://codereview.chromium.org/13880016/diff/2003/net/disk_cache/simple/simple_entry_impl.cc#newcode256 net/disk_cache/simple/simple_entry_impl.cc:256: WorkerPool::PostTask(FROM_HERE, On 2013/04/17 11:02:21, gavinp wrote: > Wait, worker ...
7 years, 8 months ago (2013-04-17 12:04:45 UTC) #22
gavinp
pliard, felipeg: I think this addresses your concerns. What do you think?
7 years, 8 months ago (2013-04-17 13:04:59 UTC) #23
Philippe
lgtm, thanks Gavin!
7 years, 8 months ago (2013-04-17 13:30:50 UTC) #24
gavinp
Committed patchset #21 manually as r194591 (presubmit successful).
7 years, 8 months ago (2013-04-17 14:55:13 UTC) #25
rvargas (doing something else)
I don't think index_ should be refcounted. We should keep the weak pointer model there. ...
7 years, 8 months ago (2013-04-17 19:56:38 UTC) #26
gavinp
On 2013/04/17 19:56:38, rvargas wrote: > I don't think index_ should be refcounted. We should ...
7 years, 8 months ago (2013-04-18 08:26:38 UTC) #27
gavinp
See https://codereview.chromium.org/14022012/ https://codereview.chromium.org/13880016/diff/78012/net/disk_cache/simple/simple_entry_impl.cc File net/disk_cache/simple/simple_entry_impl.cc (right): https://codereview.chromium.org/13880016/diff/78012/net/disk_cache/simple/simple_entry_impl.cc#newcode272 net/disk_cache/simple/simple_entry_impl.cc:272: // Adding a reference to self will ...
7 years, 8 months ago (2013-04-18 09:12:41 UTC) #28
felipeg
https://codereview.chromium.org/13880016/diff/55003/net/disk_cache/simple/simple_entry_impl.cc File net/disk_cache/simple/simple_entry_impl.cc (right): https://codereview.chromium.org/13880016/diff/55003/net/disk_cache/simple/simple_entry_impl.cc#newcode51 net/disk_cache/simple/simple_entry_impl.cc:51: base::Bind(&SimpleSynchronousEntry::OpenEntry, path, On 2013/04/17 09:52:46, gavinp wrote: > On ...
7 years, 8 months ago (2013-04-19 18:12:08 UTC) #29
gavinp
7 years, 8 months ago (2013-04-20 07:28:33 UTC) #30
Message was sent while issue was closed.
I think the thread safety is required. Does this make sense?

I have a fix coming for this anyway that will let us go back to standard
refcounting on the SimpleEntryImpl. I'll upload it a bit later today.

https://codereview.chromium.org/13880016/diff/78012/net/disk_cache/simple/sim...
File net/disk_cache/simple/simple_entry_impl.cc (right):

https://codereview.chromium.org/13880016/diff/78012/net/disk_cache/simple/sim...
net/disk_cache/simple/simple_entry_impl.cc:106: void SimpleEntryImpl::Close() {
***THREE*** In response to the callback from ***TWO***, the client calls
SimpleEntryImpl::Close().

https://codereview.chromium.org/13880016/diff/78012/net/disk_cache/simple/sim...
net/disk_cache/simple/simple_entry_impl.cc:108: Release();  // Balanced in
CreationOperationCompleted().
***FOUR*** Close releases one ref on SimpleEntryImpl.

https://codereview.chromium.org/13880016/diff/78012/net/disk_cache/simple/sim...
net/disk_cache/simple/simple_entry_impl.cc:296: completion_callback.Run(result);
***TWO*** The IO thread runs the task posted just before ***ONE***, and control
flow reaches this callback.

https://codereview.chromium.org/13880016/diff/78012/net/disk_cache/simple/sim...
File net/disk_cache/simple/simple_synchronous_entry.cc (right):

https://codereview.chromium.org/13880016/diff/78012/net/disk_cache/simple/sim...
net/disk_cache/simple/simple_synchronous_entry.cc:123:
callback_runner_->PostTask(FROM_HERE, base::Bind(callback, result));
***ONE*** A context switch occurs precisely after running this statement,
leaving the program counter inside of SimpleSynchronousEntry::ReadData(). Note
it's called from a Closure(), and that closure has a ref to |callback|, which
has a |scoped_refptr<SimpleEntryImpl>| as part of it.

https://codereview.chromium.org/13880016/diff/78012/net/disk_cache/simple/sim...
net/disk_cache/simple/simple_synchronous_entry.cc:124: }
***FIVE*** Control flow continues at this point. The SimpleEntryImpl object is
deleted on the worker pool.

Powered by Google App Engine
This is Rietveld 408576698