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

Issue 2721793002: Extensions: Make ExtensionWebRequestEventRouter leaky. (Closed)

Created:
3 years, 9 months ago by karandeepb
Modified:
3 years, 9 months ago
Reviewers:
Devlin, Wez
CC:
chromium-reviews, chromium-apps-reviews_chromium.org, extensions-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Extensions: Make ExtensionWebRequestEventRouter leaky. ExtensionWebRequestEventRouter is a Singleton primarily used on the IO thread. However, being a Singleton it is destroyed on the main/UI thread. This is potentially not thread-safe. To fix, make ExtensionWebRequestEventRouter a leaky singleton. This also removes the need for ExtensionWebRequestEventRouter to support weak pointers (which didn't add any safety in the first place, since invalidating weak pointers on one thread while accessing them on another is not thread-safe). BUG=695198 Review-Url: https://codereview.chromium.org/2721793002 Cr-Commit-Position: refs/heads/master@{#453806} Committed: https://chromium.googlesource.com/chromium/src/+/c75f6f0f5286abfacf96b9ef7ac088a9692ed897

Patch Set 1 #

Patch Set 2 : Remove WeakPtr support. #

Patch Set 3 : -- #

Patch Set 4 : Delete default destructor #

Total comments: 4

Patch Set 5 : Address review. #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+18 lines, -15 lines) Patch
M extensions/browser/api/web_request/web_request_api.h View 1 2 3 4 chunks +4 lines, -7 lines 0 comments Download
M extensions/browser/api/web_request/web_request_api.cc View 1 2 3 4 5 chunks +14 lines, -8 lines 4 comments Download

Messages

Total messages: 31 (17 generated)
karandeepb
PTAL Devlin. Please also check the CL description.
3 years, 9 months ago (2017-02-28 20:11:05 UTC) #9
Devlin
lgtm https://codereview.chromium.org/2721793002/diff/60001/extensions/browser/api/web_request/web_request_api.cc File extensions/browser/api/web_request/web_request_api.cc (right): https://codereview.chromium.org/2721793002/diff/60001/extensions/browser/api/web_request/web_request_api.cc#newcode566 extensions/browser/api/web_request/web_request_api.cc:566: static ExtensionWebRequestEventRouter* instance = nit: Let's use CR_DEFINE_STATIC_LOCAL() ...
3 years, 9 months ago (2017-02-28 22:10:04 UTC) #12
karandeepb
https://codereview.chromium.org/2721793002/diff/60001/extensions/browser/api/web_request/web_request_api.cc File extensions/browser/api/web_request/web_request_api.cc (right): https://codereview.chromium.org/2721793002/diff/60001/extensions/browser/api/web_request/web_request_api.cc#newcode566 extensions/browser/api/web_request/web_request_api.cc:566: static ExtensionWebRequestEventRouter* instance = On 2017/02/28 22:10:04, Devlin wrote: ...
3 years, 9 months ago (2017-02-28 23:01:14 UTC) #13
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/2721793002/80001
3 years, 9 months ago (2017-02-28 23:02:59 UTC) #16
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_asan_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_asan_rel_ng/builds/320113)
3 years, 9 months ago (2017-03-01 01:49:56 UTC) #18
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/2721793002/80001
3 years, 9 months ago (2017-03-01 01:53:08 UTC) #20
commit-bot: I haz the power
Committed patchset #5 (id:80001) as https://chromium.googlesource.com/chromium/src/+/c75f6f0f5286abfacf96b9ef7ac088a9692ed897
3 years, 9 months ago (2017-03-01 03:01:56 UTC) #23
Wez
https://codereview.chromium.org/2721793002/diff/80001/extensions/browser/api/web_request/web_request_api.cc File extensions/browser/api/web_request/web_request_api.cc (right): https://codereview.chromium.org/2721793002/diff/80001/extensions/browser/api/web_request/web_request_api.cc#newcode569 extensions/browser/api/web_request/web_request_api.cc:569: CR_DEFINE_STATIC_LOCAL(ExtensionWebRequestEventRouter, instance, ()); Will this have the correct behaviour ...
3 years, 9 months ago (2017-03-01 17:28:16 UTC) #25
Wez
On 2017/03/01 17:28:16, Wez wrote: > https://codereview.chromium.org/2721793002/diff/80001/extensions/browser/api/web_request/web_request_api.cc > File extensions/browser/api/web_request/web_request_api.cc (right): > > https://codereview.chromium.org/2721793002/diff/80001/extensions/browser/api/web_request/web_request_api.cc#newcode569 > ...
3 years, 9 months ago (2017-03-01 17:29:18 UTC) #26
Devlin
On 2017/03/01 17:29:18, Wez wrote: > On 2017/03/01 17:28:16, Wez wrote: > > > https://codereview.chromium.org/2721793002/diff/80001/extensions/browser/api/web_request/web_request_api.cc ...
3 years, 9 months ago (2017-03-01 17:35:07 UTC) #27
karandeepb
https://codereview.chromium.org/2721793002/diff/80001/extensions/browser/api/web_request/web_request_api.cc File extensions/browser/api/web_request/web_request_api.cc (right): https://codereview.chromium.org/2721793002/diff/80001/extensions/browser/api/web_request/web_request_api.cc#newcode569 extensions/browser/api/web_request/web_request_api.cc:569: CR_DEFINE_STATIC_LOCAL(ExtensionWebRequestEventRouter, instance, ()); On 2017/03/01 17:28:16, Wez wrote: > ...
3 years, 9 months ago (2017-03-01 18:07:21 UTC) #28
karandeepb
On 2017/03/01 17:29:18, Wez wrote: > On 2017/03/01 17:28:16, Wez wrote: > > > https://codereview.chromium.org/2721793002/diff/80001/extensions/browser/api/web_request/web_request_api.cc ...
3 years, 9 months ago (2017-03-01 18:08:50 UTC) #29
Wez
https://codereview.chromium.org/2721793002/diff/80001/extensions/browser/api/web_request/web_request_api.cc File extensions/browser/api/web_request/web_request_api.cc (right): https://codereview.chromium.org/2721793002/diff/80001/extensions/browser/api/web_request/web_request_api.cc#newcode569 extensions/browser/api/web_request/web_request_api.cc:569: CR_DEFINE_STATIC_LOCAL(ExtensionWebRequestEventRouter, instance, ()); On 2017/03/01 18:07:21, karandeepb wrote: > ...
3 years, 9 months ago (2017-03-01 18:09:47 UTC) #30
karandeepb
3 years, 9 months ago (2017-03-01 19:17:52 UTC) #31
Message was sent while issue was closed.
https://codereview.chromium.org/2721793002/diff/80001/extensions/browser/api/...
File extensions/browser/api/web_request/web_request_api.cc (right):

https://codereview.chromium.org/2721793002/diff/80001/extensions/browser/api/...
extensions/browser/api/web_request/web_request_api.cc:569:
CR_DEFINE_STATIC_LOCAL(ExtensionWebRequestEventRouter, instance, ());
On 2017/03/01 18:09:47, Wez wrote:
> On 2017/03/01 18:07:21, karandeepb wrote:
> > On 2017/03/01 17:28:16, Wez wrote:
> > > Will this have the correct behaviour with respect to instance state across
> > > tests?
> > 
> > Yeah state will be carried over for unit tests run in the same process.
Isn't
> it
> > the same for base::Singleton though? 
> 
> My recollection was that Singleton and LazyInstance *will* be torn-down by the
> test-specific AtExitManager (maybe ShadowAtExitManager, but I may be thinking
of
> something else)?

Yeah so there's the ShadowingAtExitManager which you can add to your tests/test
suite, which will call the registered AtExit callbacks whenever it is itself
destroyed, hence destroying any Singletons. At least for the tests in
web_request_api_unittest.cc, this wasn't the case. (There was no
ShadowingAtExitManager). 

Also, even if I were to use a leaky base::Singleton, I think the problem will
still be there since it won't register an AtExit callback for its destruction.
(Maybe it should when running tests?) I guess this is a problem for most/all
leaky singletons and requires explicit handling in tests itself. In case we do
start seeing some flakes, this can probably be revisited.

Powered by Google App Engine
This is Rietveld 408576698