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

Issue 795773002: Un-refcount SSLClientAuthHandler. (Closed)

Created:
6 years ago by davidben
Modified:
5 years, 11 months ago
CC:
chromium-reviews, darin-cc_chromium.org, jam
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Un-refcount SSLClientAuthHandler. That class doesn't really need to be ref-counted externally. There is one catch: the caller is responsible for ensuring ClientCertStore is alive for the duration of its async operation. Resolve this by detaching it into a ref-counted Core internal to SSLClientAuthHandler. Add a test to test this case. Also make ContentBrowserClient's default client auth hook always select no certificate so content_shell doesn't hang. This relands the rest of https://codereview.chromium.org/596873002 BUG=439134 Committed: https://crrev.com/6cd57dd5cbca53c416f099b985444225d676362a Cr-Commit-Position: refs/heads/master@{#308142}

Patch Set 1 #

Total comments: 10

Patch Set 2 : mmenke comments #

Total comments: 20
Unified diffs Side-by-side diffs Delta from patch set Stats (+177 lines, -125 lines) Patch
M chrome/browser/chrome_content_browser_client.cc View 1 1 chunk +2 lines, -1 line 0 comments Download
M content/browser/loader/resource_loader.h View 2 chunks +2 lines, -1 line 0 comments Download
M content/browser/loader/resource_loader.cc View 1 4 chunks +8 lines, -14 lines 2 comments Download
M content/browser/loader/resource_loader_unittest.cc View 3 chunks +43 lines, -3 lines 2 comments Download
M content/browser/ssl/ssl_client_auth_handler.h View 3 chunks +17 lines, -37 lines 2 comments Download
M content/browser/ssl/ssl_client_auth_handler.cc View 1 1 chunk +96 lines, -68 lines 12 comments Download
M content/public/browser/content_browser_client.h View 1 1 chunk +1 line, -1 line 2 comments Download
M content/public/browser/content_browser_client.cc View 1 1 chunk +8 lines, -0 lines 0 comments Download

Messages

Total messages: 21 (5 generated)
davidben
Here's the rest of the reverted CL, now with the crash fixed. pneubeck: FYI
6 years ago (2014-12-10 22:43:46 UTC) #2
mmenke
https://codereview.chromium.org/795773002/diff/1/content/browser/loader/resource_loader_unittest.cc File content/browser/loader/resource_loader_unittest.cc (right): https://codereview.chromium.org/795773002/diff/1/content/browser/loader/resource_loader_unittest.cc#newcode454 content/browser/loader/resource_loader_unittest.cc:454: // Ownership of the |test_store| is about to be ...
6 years ago (2014-12-11 21:02:20 UTC) #3
davidben
https://codereview.chromium.org/795773002/diff/1/content/browser/loader/resource_loader_unittest.cc File content/browser/loader/resource_loader_unittest.cc (right): https://codereview.chromium.org/795773002/diff/1/content/browser/loader/resource_loader_unittest.cc#newcode454 content/browser/loader/resource_loader_unittest.cc:454: // Ownership of the |test_store| is about to be ...
6 years ago (2014-12-11 22:08:10 UTC) #4
mmenke
LGTM
6 years ago (2014-12-11 22:50:34 UTC) #5
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/795773002/20001
6 years ago (2014-12-11 23:10:56 UTC) #7
commit-bot: I haz the power
Try jobs failed on following builders: android_dbg_tests_recipe on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/android_dbg_tests_recipe/builds/36828)
6 years ago (2014-12-12 01:11:26 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/795773002/20001
6 years ago (2014-12-12 18:21:24 UTC) #11
commit-bot: I haz the power
Committed patchset #2 (id:20001)
6 years ago (2014-12-12 19:24:09 UTC) #12
commit-bot: I haz the power
Patchset 2 (id:??) landed as https://crrev.com/6cd57dd5cbca53c416f099b985444225d676362a Cr-Commit-Position: refs/heads/master@{#308142}
6 years ago (2014-12-12 19:24:57 UTC) #13
pneubeck (no reviews)
sorry, already to late for this CL. Please consider my comments nonetheless. https://codereview.chromium.org/795773002/diff/20001/content/browser/loader/resource_loader.cc File content/browser/loader/resource_loader.cc ...
6 years ago (2014-12-14 16:45:13 UTC) #15
mmenke
https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_client_auth_handler.cc File content/browser/ssl/ssl_client_auth_handler.cc (right): https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_client_auth_handler.cc#newcode144 content/browser/ssl/ssl_client_auth_handler.cc:144: callback_.Run(cert); Think this should use reset and return on ...
6 years ago (2014-12-14 21:04:52 UTC) #16
pneubeck (no reviews)
https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_client_auth_handler.cc File content/browser/ssl/ssl_client_auth_handler.cc (right): https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_client_auth_handler.cc#newcode145 content/browser/ssl/ssl_client_auth_handler.cc:145: // |this| may be deleted at this point. On ...
6 years ago (2014-12-15 21:11:44 UTC) #17
mmenke
On 2014/12/15 21:11:44, pneubeck wrote: > https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_client_auth_handler.cc > File content/browser/ssl/ssl_client_auth_handler.cc (right): > > https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_client_auth_handler.cc#newcode145 > ...
6 years ago (2014-12-15 21:27:37 UTC) #18
pneubeck (no reviews)
On 2014/12/15 21:27:37, mmenke wrote: > On 2014/12/15 21:11:44, pneubeck wrote: > > > https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_client_auth_handler.cc ...
6 years ago (2014-12-16 10:07:26 UTC) #19
davidben
(I'm OOO until after the holidays, so don't take my silence as ignoring this thread. ...
6 years ago (2014-12-16 10:52:22 UTC) #20
davidben
5 years, 11 months ago (2015-01-23 21:05:35 UTC) #21
Message was sent while issue was closed.
Apologies that took a while. Follow-up here.

https://codereview.chromium.org/873723003/

https://codereview.chromium.org/795773002/diff/20001/content/browser/loader/r...
File content/browser/loader/resource_loader.cc (right):

https://codereview.chromium.org/795773002/diff/20001/content/browser/loader/r...
content/browser/loader/resource_loader.cc:854: ssl_client_auth_handler_.reset();
On 2014/12/14 16:45:12, pneubeck wrote:
> please don't do this in a call stack containing ssl_client_auth_handler_ as a
> this ptr.
> you could probably reuse the existing weak_ptr_factory_ to delay the deletion.

Made it a DeleteSoon.

https://codereview.chromium.org/795773002/diff/20001/content/browser/loader/r...
File content/browser/loader/resource_loader_unittest.cc (right):

https://codereview.chromium.org/795773002/diff/20001/content/browser/loader/r...
content/browser/loader/resource_loader_unittest.cc:470: EXPECT_EQ(1,
raw_ptr_to_store->request_count());
On 2014/12/14 16:45:12, pneubeck wrote:
> how do you ensure that the raw_ptr_to_store is still valid (same for all
similar
> tests)? wouldn't it be more reliable if the ClientCertStoreStub would write
its
> results to some variables that outlive the previous calls for sure?

Yeah, that does seem better. There's a lot of other raw_ptr_to_*s in this file,
but let's resolve that one to start with. Done.

https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_...
File content/browser/ssl/ssl_client_auth_handler.cc (right):

https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_...
content/browser/ssl/ssl_client_auth_handler.cc:61:
base::Bind(&SSLClientAuthHandler::Core::DidGetClientCerts, this));
On 2014/12/14 16:45:12, pneubeck wrote:
> this seems still to be a rather weird ownership:
>  Core lives as long client_cert_store_ keeps this callback that owns the Core
> object.
>  Core object owns client_cert_store_.
> 
> By the definition of 'Ownership = Trigger of destruction', this is a cyclic
> dependency and we should fix this.
> 
> I looked into this a while ago and could take care of it. It's not a tiny
change
> however.

Agreed. It's still the same issue that we had before, but pushed behind the
SSLClientAuthHandler interface. So some progress, but the problem hasn't gone
away.

The fix you're thinking of, I assume, is to make it safe to kill
client_cert_store_ while GetClientCerts is in flight? And then we'd have to sort
out the craziness around cert_request_info_ and
cert_request_info_->client_certs. Then we won't need this silly Core at all.

I've added a TODO for now.

https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_...
content/browser/ssl/ssl_client_auth_handler.cc:88: : core_(nullptr),
On 2014/12/14 16:45:12, pneubeck wrote:
> not required?

Done.

https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_...
content/browser/ssl/ssl_client_auth_handler.cc:99:
SSLClientAuthHandler::~SSLClientAuthHandler() {
On 2014/12/14 16:45:12, pneubeck wrote:
> this should still somehow trigger a "shutdown" of the Core object. Currently,
> core_ might continue with an arbitrary number of steps.

I think this is also blocking on sorting out GetClientCerts' requirements,
otherwise there's nothing to shut down.

https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_...
content/browser/ssl/ssl_client_auth_handler.cc:144: callback_.Run(cert);
On 2014/12/14 21:04:51, mmenke wrote:
> Think this should use reset and return on the callback, for it to be cleaned
up
> correctly.

Hrm. Does it need to be? SelectCertificate should only get used once and such.

https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_...
content/browser/ssl/ssl_client_auth_handler.cc:145: // |this| may be deleted at
this point.
On 2014/12/15 21:11:44, pneubeck wrote:
>  scoped_ptr<Foo, BrowserThread::DeleteOnIOThread>

That actually doesn't do the same thing. If you're currently on the IO thread,
it'll delete it immediately rather than post a task. But I've done a DeleteSoon.

https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_...
File content/browser/ssl/ssl_client_auth_handler.h (right):

https://codereview.chromium.org/795773002/diff/20001/content/browser/ssl/ssl_...
content/browser/ssl/ssl_client_auth_handler.h:46: // Called when the user has
selected a cert.
On 2014/12/14 16:45:13, pneubeck wrote:
> wouldn't |cert| be null if the selection was aborted?

We actually don't ever plumb through aborting a selection (a bug I need to fix
crbug.com/417092). Pressing cancel explicitly selects no certificate, which is a
different operation. Added a note in the comment.

https://codereview.chromium.org/795773002/diff/20001/content/public/browser/c...
File content/public/browser/content_browser_client.h (right):

https://codereview.chromium.org/795773002/diff/20001/content/public/browser/c...
content/public/browser/content_browser_client.h:396: // Selects a SSL client
certificate and returns it to the |callback|. If no
On 2014/12/14 16:45:13, pneubeck wrote:
> might be worth documenting that callback can happen to be called both
> synchronously and asynchronously.

Done.

Powered by Google App Engine
This is Rietveld 408576698