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

Issue 2839433002: [translate] Fix shutdown race for translate ranker model loader. (Closed)

Created:
3 years, 8 months ago by Roger McFarlane (Chromium)
Modified:
3 years, 8 months ago
CC:
chromium-reviews
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

[translate] Fix shutdown race for translate ranker model loader. The RankerModelLoader was using a background thread to coordinate its efforts to load the model first from a file, then from a URL. In some circumstances, browser shutdown could begin while the model file is being read from disk. If the loader further proceeds to download the model file from its URL on the background thread, it performs a racy attempt to grab a scoped_refptr to the Translate Download Manager's URL Request Context Getter. This access should not have been made on that thread. This CL refactors the coordination of the ranker model loader to be performed on the main browser thread, with I/O operations performed on the background and I/O threads. The TranslateURLFetcher now access the TranslateDownloadManager from the correct thread. It further validates that is was able obtain a valid URL request context getter before attempting to use it. BUG=709905 Review-Url: https://codereview.chromium.org/2839433002 Cr-Commit-Position: refs/heads/master@{#467373} Committed: https://chromium.googlesource.com/chromium/src/+/691c75601912d7b1dad012265a72bfaaea79bd4c

Patch Set 1 #

Patch Set 2 : Initial CL #

Patch Set 3 : fix unit_tests #

Patch Set 4 : rebase #

Patch Set 5 : minor cleanups #

Patch Set 6 : experiment: delay model load to first translate activity #

Total comments: 8

Patch Set 7 : groby comments #

Patch Set 8 : re-enable load on start (no difference observed compared to load on first use) #

Total comments: 16

Patch Set 9 : comments from fdoray #

Total comments: 10

Patch Set 10 : fdoray part deux #

Unified diffs Side-by-side diffs Delta from patch set Stats (+354 lines, -356 lines) Patch
M chrome/browser/translate/translate_manager_render_view_host_unittest.cc View 1 2 3 4 5 6 2 chunks +9 lines, -3 lines 0 comments Download
M components/translate/core/browser/ranker_model_loader.h View 1 2 3 4 5 6 7 8 9 5 chunks +102 lines, -46 lines 0 comments Download
M components/translate/core/browser/ranker_model_loader.cc View 1 2 3 4 5 6 7 8 9 6 chunks +189 lines, -298 lines 0 comments Download
M components/translate/core/browser/ranker_model_loader_unittest.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M components/translate/core/browser/translate_download_manager.h View 1 2 3 3 chunks +21 lines, -4 lines 0 comments Download
M components/translate/core/browser/translate_download_manager.cc View 1 2 3 2 chunks +3 lines, -0 lines 0 comments Download
M components/translate/core/browser/translate_ranker_impl.cc View 6 7 1 chunk +2 lines, -1 line 0 comments Download
M components/translate/core/browser/translate_script_unittest.cc View 1 2 3 4 5 6 4 chunks +12 lines, -0 lines 0 comments Download
M components/translate/core/browser/translate_url_fetcher.cc View 1 2 3 4 5 6 2 chunks +12 lines, -2 lines 0 comments Download
M tools/metrics/histograms/histograms.xml View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 54 (38 generated)
Roger McFarlane (Chromium)
This CL restructures the loader code such that the coordination is performed on the main ...
3 years, 8 months ago (2017-04-24 17:02:07 UTC) #13
groby-ooo-7-16
On 2017/04/24 17:02:07, Roger McFarlane (Chromium) wrote: > This CL restructures the loader code such ...
3 years, 8 months ago (2017-04-24 19:05:46 UTC) #16
groby-ooo-7-16
FWIW - the changes outside of the ModelLoader L-G-T-M. And they look like they possibly ...
3 years, 8 months ago (2017-04-24 19:12:46 UTC) #17
Roger McFarlane (Chromium)
re: Why remove backend. Backend only existed to mark the scope of stateful operations performed ...
3 years, 8 months ago (2017-04-24 20:31:34 UTC) #19
fdoray
https://codereview.chromium.org/2839433002/diff/180001/components/translate/core/browser/ranker_model_loader.cc File components/translate/core/browser/ranker_model_loader.cc (right): https://codereview.chromium.org/2839433002/diff/180001/components/translate/core/browser/ranker_model_loader.cc#newcode48 components/translate/core/browser/ranker_model_loader.cc:48: if (counter) DCHECK(counter); base::Histogram::FactoryTimeGet should always return an histogram ...
3 years, 8 months ago (2017-04-25 14:50:44 UTC) #24
Roger McFarlane (Chromium)
Thanks. Another look https://codereview.chromium.org/2839433002/diff/180001/components/translate/core/browser/ranker_model_loader.cc File components/translate/core/browser/ranker_model_loader.cc (right): https://codereview.chromium.org/2839433002/diff/180001/components/translate/core/browser/ranker_model_loader.cc#newcode48 components/translate/core/browser/ranker_model_loader.cc:48: if (counter) On 2017/04/25 14:50:43, fdoray ...
3 years, 8 months ago (2017-04-25 21:50:40 UTC) #31
fdoray
lgtm https://codereview.chromium.org/2839433002/diff/200001/components/translate/core/browser/ranker_model_loader.cc File components/translate/core/browser/ranker_model_loader.cc (right): https://codereview.chromium.org/2839433002/diff/200001/components/translate/core/browser/ranker_model_loader.cc#newcode95 components/translate/core/browser/ranker_model_loader.cc:95: const ValidateModelCallback& validate_model_cb, It is more efficient to ...
3 years, 8 months ago (2017-04-25 22:09:09 UTC) #32
Roger McFarlane (Chromium)
Thanks. groby@, jwd@? https://codereview.chromium.org/2839433002/diff/200001/components/translate/core/browser/ranker_model_loader.cc File components/translate/core/browser/ranker_model_loader.cc (right): https://codereview.chromium.org/2839433002/diff/200001/components/translate/core/browser/ranker_model_loader.cc#newcode95 components/translate/core/browser/ranker_model_loader.cc:95: const ValidateModelCallback& validate_model_cb, On 2017/04/25 22:09:08, ...
3 years, 8 months ago (2017-04-26 02:18:50 UTC) #36
hamelphi
lgtm
3 years, 8 months ago (2017-04-26 15:56:30 UTC) #41
groby-ooo-7-16
On 2017/04/26 15:56:30, hamelphi wrote: > lgtm lgtm
3 years, 8 months ago (2017-04-26 16:33:13 UTC) #42
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2839433002/240001
3 years, 8 months ago (2017-04-26 17:03:35 UTC) #45
commit-bot: I haz the power
Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presubmit/builds/420970)
3 years, 8 months ago (2017-04-26 17:13:39 UTC) #47
Roger McFarlane (Chromium)
jwd@: ping?
3 years, 8 months ago (2017-04-26 17:15:29 UTC) #48
jwd
lgtm
3 years, 8 months ago (2017-04-26 17:26:47 UTC) #49
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2839433002/240001
3 years, 8 months ago (2017-04-26 17:38:33 UTC) #51
commit-bot: I haz the power
3 years, 8 months ago (2017-04-26 17:51:41 UTC) #54
Message was sent while issue was closed.
Committed patchset #10 (id:240001) as
https://chromium.googlesource.com/chromium/src/+/691c75601912d7b1dad012265a72...

Powered by Google App Engine
This is Rietveld 408576698