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

Issue 5710002: Create base::WorkerPoolJob. Use it for HostResolverImpl and DirectoryLister. (Closed)

Created:
10 years ago by willchan no longer on Chromium
Modified:
9 years, 2 months ago
CC:
chromium-reviews, cbentzel+watch_chromium.org, ben+cc_chromium.org, brettw-cc_chromium.org, darin-cc_chromium.org, jshin+watch_chromium.org, wtc, Paweł Hajdan Jr.
Visibility:
Public.

Description

Create base::WorkerPoolJob. Use it for HostResolverImpl and DirectoryLister. This notably changes DirectoryLister to use the worker pool rather than its own joinable thread. This allows us to avoid joining the thread which would block the IO thread. It requires leaking ICU locale data on shutdown, so I've switched that to using LeakySingletonTraits. BUG=65331 TEST=existing

Patch Set 1 #

Patch Set 2 : Add comments. #

Patch Set 3 : Fixes and ScopedHandle. #

Patch Set 4 : Minimize the header dependency. #

Total comments: 25

Patch Set 5 : Merge and address most comments. #

Patch Set 6 : Fix a minor build error. #

Patch Set 7 : Address cancellation. #

Total comments: 26

Patch Set 8 : Address comments. #

Total comments: 8
Unified diffs Side-by-side diffs Delta from patch set Stats (+494 lines, -435 lines) Patch
base/base.gyp View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
base/base.gypi View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
base/i18n/file_util_icu.cc View 1 chunk +2 lines, -1 line 0 comments Download
base/worker_pool_job.h View 1 2 3 4 5 6 7 1 chunk +118 lines, -0 lines 1 comment Download
base/worker_pool_job.cc View 1 2 3 4 5 6 7 1 chunk +72 lines, -0 lines 5 comments Download
base/worker_pool_job_unittest.cc View 1 2 3 4 5 6 7 1 chunk +100 lines, -0 lines 2 comments Download
chrome/browser/dom_ui/filebrowse_ui.cc View 1 2 3 4 8 chunks +11 lines, -23 lines 0 comments Download
chrome/browser/dom_ui/slideshow_ui.cc View 6 chunks +9 lines, -21 lines 0 comments Download
chrome/browser/file_select_helper.h View 3 chunks +4 lines, -5 lines 0 comments Download
chrome/browser/file_select_helper.cc View 1 2 3 4 4 chunks +10 lines, -16 lines 0 comments Download
net/base/directory_lister.h View 1 2 3 4 5 6 2 chunks +18 lines, -51 lines 0 comments Download
net/base/directory_lister.cc View 1 2 3 4 5 6 7 5 chunks +82 lines, -117 lines 0 comments Download
net/base/directory_lister_unittest.cc View 1 2 3 4 5 6 4 chunks +17 lines, -22 lines 0 comments Download
net/base/host_resolver_impl.cc View 1 2 3 4 5 6 7 15 chunks +27 lines, -126 lines 0 comments Download
net/url_request/url_request_file_dir_job.h View 1 2 3 4 3 chunks +4 lines, -5 lines 0 comments Download
net/url_request/url_request_file_dir_job.cc View 1 2 3 4 6 chunks +17 lines, -48 lines 0 comments Download

Messages

Total messages: 13 (0 generated)
willchan no longer on Chromium
I haven't commented anything yet. I'll be doing that today. I also need some chromeos ...
10 years ago (2010-12-10 22:14:28 UTC) #1
Paweł Hajdan Jr.
Drive-by with a test comment. No need to wait for another review by me. http://codereview.chromium.org/5710002/diff/7001/base/worker_pool_job_unittest.cc ...
10 years ago (2010-12-11 10:40:18 UTC) #2
willchan no longer on Chromium
http://codereview.chromium.org/5710002/diff/7001/base/worker_pool_job_unittest.cc File base/worker_pool_job_unittest.cc (right): http://codereview.chromium.org/5710002/diff/7001/base/worker_pool_job_unittest.cc#newcode24 base/worker_pool_job_unittest.cc:24: DCHECK(!waiting_for_run_); On 2010/12/11 10:40:19, Paweł Hajdan Jr. wrote: > ...
10 years ago (2010-12-11 22:44:26 UTC) #3
willchan no longer on Chromium
[ +johnnyg for DirectoryLister uses in chrome/browser ]
10 years ago (2010-12-12 03:00:53 UTC) #4
Paweł Hajdan Jr.
On Sat, Dec 11, 2010 at 23:44, <willchan@chromium.org> wrote: > > http://codereview.chromium.org/5710002/diff/7001/base/worker_pool_job_unittest.cc > File base/worker_pool_job_unittest.cc ...
10 years ago (2010-12-13 12:59:41 UTC) #5
eroman
http://codereview.chromium.org/5710002/diff/7001/base/i18n/file_util_icu.cc File base/i18n/file_util_icu.cc (right): http://codereview.chromium.org/5710002/diff/7001/base/i18n/file_util_icu.cc#newcode85 base/i18n/file_util_icu.cc:85: LeakySingletonTraits<LocaleAwareComparator> >::get(); What is this change for? http://codereview.chromium.org/5710002/diff/7001/base/worker_pool_job.cc File ...
10 years ago (2010-12-22 00:51:46 UTC) #6
willchan no longer on Chromium
I've addressed most comments other than the cancellation one which requires me to rethink the ...
10 years ago (2010-12-22 02:04:00 UTC) #7
willchan no longer on Chromium
Ok, I've updated it to remove cancellation. It weakened the unit tests a bit, but ...
10 years ago (2010-12-22 02:50:38 UTC) #8
eroman
http://codereview.chromium.org/5710002/diff/7001/base/worker_pool_job.cc File base/worker_pool_job.cc (right): http://codereview.chromium.org/5710002/diff/7001/base/worker_pool_job.cc#newcode111 base/worker_pool_job.cc:111: origin_loop_->PostTask( On 2010/12/22 02:04:01, willchan wrote: > On 2010/12/22 ...
10 years ago (2010-12-22 04:58:48 UTC) #9
eroman
http://codereview.chromium.org/5710002/diff/23001/base/worker_pool_job.cc File base/worker_pool_job.cc (right): http://codereview.chromium.org/5710002/diff/23001/base/worker_pool_job.cc#newcode33 base/worker_pool_job.cc:33: { nit: extra scope isn't really necessary. http://codereview.chromium.org/5710002/diff/23001/base/worker_pool_job.cc#newcode84 base/worker_pool_job.cc:84: ...
10 years ago (2010-12-22 23:25:07 UTC) #10
willchan no longer on Chromium
http://codereview.chromium.org/5710002/diff/23001/base/worker_pool_job.cc File base/worker_pool_job.cc (right): http://codereview.chromium.org/5710002/diff/23001/base/worker_pool_job.cc#newcode33 base/worker_pool_job.cc:33: { On 2010/12/22 23:25:08, eroman wrote: > nit: extra ...
10 years ago (2010-12-24 00:47:34 UTC) #11
eroman
http://codereview.chromium.org/5710002/diff/23001/base/worker_pool_job_unittest.cc File base/worker_pool_job_unittest.cc (right): http://codereview.chromium.org/5710002/diff/23001/base/worker_pool_job_unittest.cc#newcode88 base/worker_pool_job_unittest.cc:88: TEST(WorkerPoolJobTest, CancelOnWorker) { On 2010/12/24 00:47:34, willchan wrote: > ...
10 years ago (2010-12-24 00:54:42 UTC) #12
eroman
9 years, 11 months ago (2011-01-05 01:24:52 UTC) #13
Can you re-upload, since some of the files are not readable (have rietevield
errors).

The newly added files LGTM.

(I would like to do a review of the others though, ping me when they are
uploaded).

http://codereview.chromium.org/5710002/diff/23001/base/worker_pool_job.h
File base/worker_pool_job.h (right):

http://codereview.chromium.org/5710002/diff/23001/base/worker_pool_job.h#newc...
base/worker_pool_job.h:38: ~ScopedHandle() {
On 2010/12/24 00:47:34, willchan wrote:
> On 2010/12/22 23:25:08, eroman wrote:
> > Can't this simply be job_->CancelJob() ?
> 
> No.  I am a bit anal about cancellation.  I want people only to call
CancelJob()
> when they have something to cancel.  ScopedHandle reads into the private state
> to see if it needs to cancel or not.  I'm fine with ScopedHandle doing that
> since people usually aren't canceling themselves if they're using the handle. 
> But if they are doing things manually, then I want them to cancel only once. 
> Multiple invocations is usually a sign of a bug or arguably bad design.

FWIW we use the pattern of calling Cancel() on already cancelled objects in
other places. Especially in destructors which blanket cancel stuff without
checking if they have already been cancelled.

I am ok with this though.

http://codereview.chromium.org/5710002/diff/22017/base/worker_pool_job.cc
File base/worker_pool_job.cc (right):

http://codereview.chromium.org/5710002/diff/22017/base/worker_pool_job.cc#new...
base/worker_pool_job.cc:22: DCHECK_EQ(state_, NONE);
Can the state DCHECK be more restrictive?

i.e, I don't think we want to transition from RUNNING --> RUNNING.

Also it isn't clear that it would be valid to call StartJob() more than once.

(For example if we wanted to allow calling StartJob() after cancellation, it
should reset canceled_).

http://codereview.chromium.org/5710002/diff/22017/base/worker_pool_job.cc#new...
base/worker_pool_job.cc:34: DCHECK_NE(state_, DONE);
Can these two checks be combined into:
DCHECK_EQ(RUNNING, state_)

http://codereview.chromium.org/5710002/diff/22017/base/worker_pool_job.cc#new...
base/worker_pool_job.cc:41: // been canceled so they can bail out early.
I don't think this comment is true anymore.

http://codereview.chromium.org/5710002/diff/22017/base/worker_pool_job.cc#new...
base/worker_pool_job.cc:58: DCHECK_NE(state_, NONE);
Can these two statnments be combined into:

DCHECK_EQ(RUNNING, state_)

http://codereview.chromium.org/5710002/diff/22017/base/worker_pool_job.cc#new...
base/worker_pool_job.cc:69: state_ = DONE;
nit: I wander if you want to set state_ to DONE before calling OnJobCompleted(),
to catch if we try to cancel/start the job again inside that handler.

http://codereview.chromium.org/5710002/diff/22017/base/worker_pool_job.h
File base/worker_pool_job.h (right):

http://codereview.chromium.org/5710002/diff/22017/base/worker_pool_job.h#newc...
base/worker_pool_job.h:101: // it may never be invoked.
This wording can be stronger. If CancelJob() was called, then OnJobCompleted()
will definitely not be called (since both run on the origin thread).

http://codereview.chromium.org/5710002/diff/22017/base/worker_pool_job_unitte...
File base/worker_pool_job_unittest.cc (right):

http://codereview.chromium.org/5710002/diff/22017/base/worker_pool_job_unitte...
base/worker_pool_job_unittest.cc:1: // Copyright (c) 2010 The Chromium Authors.
All rights reserved.
nit: might consider changing these to 2011

http://codereview.chromium.org/5710002/diff/22017/base/worker_pool_job_unitte...
base/worker_pool_job_unittest.cc:18: explicit TestJob()
is explicit needed?

Powered by Google App Engine
This is Rietveld 408576698