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

Issue 1967693003: Avoid object slicing in WebCredential::create (Closed)

Created:
4 years, 7 months ago by vabr (Chromium)
Modified:
4 years, 7 months ago
CC:
blink-reviews, blink-reviews-api_chromium.org, chromium-reviews, dglazkov+blink, kinuko+watch
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Avoid object slicing in WebCredential::create WebCredential::create currently returns a WebCredential. It tries to create one of its subclasses, WebPasswordCredential or WebFederatedCredential, respectively, but those object get sliced to their common base upon returning, because a function returning A cannot return B even if B is a subclass of A. To fix that, this CL changes create() to return a pointer to a WebCredential. This allows creating subclasses of it while keeping the return type as declared. R=mkwst@chromium.org BUG=610646 Committed: https://crrev.com/9818ab57e995473e2d41d5bb40b6a9abd2682151 Cr-Commit-Position: refs/heads/master@{#392959}

Patch Set 1 #

Total comments: 3

Patch Set 2 : base::WrapUnique -> WTF::wrapUnique #

Patch Set 3 : Adding the hilarious namespace :) #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+10 lines, -8 lines) Patch
M third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp View 1 chunk +2 lines, -1 line 1 comment Download
M third_party/WebKit/Source/platform/exported/WebCredential.cpp View 1 2 1 chunk +5 lines, -6 lines 1 comment Download
M third_party/WebKit/public/platform/WebCredential.h View 2 chunks +3 lines, -1 line 0 comments Download

Messages

Total messages: 23 (5 generated)
vabr (Chromium)
Hi Mike, Could you PTAL? Thanks! Vaclav
4 years, 7 months ago (2016-05-11 13:38:33 UTC) #1
haraken
https://codereview.chromium.org/1967693003/diff/1/third_party/WebKit/Source/platform/exported/WebCredential.cpp File third_party/WebKit/Source/platform/exported/WebCredential.cpp (right): https://codereview.chromium.org/1967693003/diff/1/third_party/WebKit/Source/platform/exported/WebCredential.cpp#newcode18 third_party/WebKit/Source/platform/exported/WebCredential.cpp:18: return base::WrapUnique(new WebPasswordCredential(credential)); yutak@: We don't want to use ...
4 years, 7 months ago (2016-05-11 14:16:11 UTC) #3
haraken
4 years, 7 months ago (2016-05-11 14:16:34 UTC) #5
vabr (Chromium)
https://codereview.chromium.org/1967693003/diff/1/third_party/WebKit/Source/platform/exported/WebCredential.cpp File third_party/WebKit/Source/platform/exported/WebCredential.cpp (right): https://codereview.chromium.org/1967693003/diff/1/third_party/WebKit/Source/platform/exported/WebCredential.cpp#newcode18 third_party/WebKit/Source/platform/exported/WebCredential.cpp:18: return base::WrapUnique(new WebPasswordCredential(credential)); On 2016/05/11 14:16:11, haraken wrote: > ...
4 years, 7 months ago (2016-05-11 14:42:59 UTC) #6
vabr (Chromium)
base::WrapUnique -> WTF::wrapUnique
4 years, 7 months ago (2016-05-11 15:09:31 UTC) #7
vabr (Chromium)
I changed the CL to use WTF's wrapUnique instead. haraken & mkwst: PTAL Thanks! Vaclav
4 years, 7 months ago (2016-05-11 15:10:43 UTC) #8
Mike West
Using WTF::wrapUnique LGTM. Thanks for fixing this, Vaclav.
4 years, 7 months ago (2016-05-11 15:20:45 UTC) #9
vabr (Chromium)
Adding the hilarious namespace :)
4 years, 7 months ago (2016-05-11 15:46:32 UTC) #10
vabr (Chromium)
On 2016/05/11 15:20:45, Mike West wrote: > Using WTF::wrapUnique LGTM. Thanks for fixing this, Vaclav. ...
4 years, 7 months ago (2016-05-11 15:48:44 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1967693003/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1967693003/40001
4 years, 7 months ago (2016-05-11 15:49:17 UTC) #14
haraken
I'll defer the review to yutak@. As far as I read the document (https://chromium.googlesource.com/chromium/src/+/master/third_party/WebKit/Source/wtf/UniquePtrTransitionGuide.md), it ...
4 years, 7 months ago (2016-05-11 15:54:19 UTC) #15
commit-bot: I haz the power
Committed patchset #3 (id:40001)
4 years, 7 months ago (2016-05-11 17:01:40 UTC) #16
commit-bot: I haz the power
Patchset 3 (id:??) landed as https://crrev.com/9818ab57e995473e2d41d5bb40b6a9abd2682151 Cr-Commit-Position: refs/heads/master@{#392959}
4 years, 7 months ago (2016-05-11 17:03:33 UTC) #18
Yuta Kitamura
After-the-fact LGTM. (With nits.) https://codereview.chromium.org/1967693003/diff/40001/third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp File third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp (right): https://codereview.chromium.org/1967693003/diff/40001/third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp#newcode174 third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp:174: auto web_credential = WebCredential::create(credential->getPlatformCredential()); This ...
4 years, 7 months ago (2016-05-12 03:58:55 UTC) #19
haraken
On 2016/05/12 03:58:55, Yuta Kitamura wrote: > After-the-fact LGTM. (With nits.) > > https://codereview.chromium.org/1967693003/diff/40001/third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp > ...
4 years, 7 months ago (2016-05-12 04:05:35 UTC) #20
Yuta Kitamura
On 2016/05/12 04:05:35, haraken wrote: > > Shall we update the document > (https://chromium.googlesource.com/chromium/src/+/master/third_party/WebKit/Source/wtf/UniquePtrTransitionGuide.md) Yeah, ...
4 years, 7 months ago (2016-05-12 05:51:43 UTC) #21
vabr (Chromium)
On 2016/05/12 05:51:43, Yuta Kitamura wrote: > On 2016/05/12 04:05:35, haraken wrote: > > > ...
4 years, 7 months ago (2016-05-12 08:42:45 UTC) #22
dcheng
4 years, 7 months ago (2016-05-12 16:47:50 UTC) #23
Message was sent while issue was closed.
On 2016/05/12 at 05:51:43, yutak wrote:
> On 2016/05/12 04:05:35, haraken wrote:
> > 
> > Shall we update the document
> >
(https://chromium.googlesource.com/chromium/src/+/master/third_party/WebKit/So...)
> 
> Yeah, I will.
> 
> > 
> > Your previous email
> >
(https://groups.google.com/a/chromium.org/d/topic/platform-architecture-dev/2U...)
> > is also implying that you may want to avoid using wrapUnique().
> 
> Given that base::MakeUnique isn't progressing (AFAIK) and
> wrapUnique() is added in WTF, I'm leaning towards just using
> it where appropriate.

Actually, base::MakeUnique has already landed. But I haven't announced it
publicly yet because I'm waiting for codesearch to pick up a CL I landed to help
it trace constructor calls through base::MakeUnique.

Powered by Google App Engine
This is Rietveld 408576698