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

Issue 2846333004: Switch SupportsUserData uses to use unique_ptr. (Closed)

Created:
3 years, 7 months ago by Avi (use Gerrit)
Modified:
3 years, 7 months ago
Reviewers:
Nico
CC:
chromium-reviews, dominickn+watch_chromium.org, skanuj+watch_chromium.org, msramek+watch_chromium.org, noyau+watch_chromium.org, markusheintz_, jdonnelly+watch_chromium.org, cbentzel+watch_chromium.org, melevin+watch_chromium.org, net-reviews_chromium.org, sync-reviews_chromium.org, loading-reviews_chromium.org, pkotwicz+watch_chromium.org, vabr+watchlistpasswordmanager_chromium.org, ntp-dev+reviews_chromium.org, speed-metrics-reviews_chromium.org, Randy Smith (Not in Mondays), csharrison+watch_chromium.org, jfweitz+watch_chromium.org, pam+watch_chromium.org, asvitkine+watch_chromium.org, gcasto+watchlist_chromium.org, Jered, donnd+watch_chromium.org, loading-reviews+metrics_chromium.org, David Black, samarth+watch_chromium.org, kmadhusu+watch_chromium.org, zpeng+watch_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Switch SupportsUserData uses to use unique_ptr. The interface taking a raw pointer is deprecated and being removed. BUG=690937 Review-Url: https://codereview.chromium.org/2846333004 Cr-Commit-Position: refs/heads/master@{#468862} Committed: https://chromium.googlesource.com/chromium/src/+/284ec61c76d48490010b2f1c80628306d4d75a7f

Patch Set 1 #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+72 lines, -47 lines) Patch
M chrome/browser/autocomplete/shortcuts_backend_factory.cc View 1 chunk +4 lines, -3 lines 0 comments Download
M chrome/browser/banners/app_banner_manager_desktop.h View 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/chrome_content_browser_client.cc View 2 chunks +5 lines, -4 lines 0 comments Download
M chrome/browser/data_usage/tab_id_annotator.cc View 1 chunk +1 line, -2 lines 0 comments Download
M chrome/browser/data_use_measurement/chrome_data_use_ascriber.cc View 3 chunks +9 lines, -6 lines 0 comments Download
M chrome/browser/data_use_measurement/data_use_web_contents_observer.cc View 2 chunks +3 lines, -1 line 1 comment Download
M chrome/browser/font_family_cache.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/infobars/infobar_service.h View 2 chunks +2 lines, -1 line 0 comments Download
M chrome/browser/loader/chrome_navigation_data.cc View 2 chunks +3 lines, -1 line 0 comments Download
M chrome/browser/metrics/desktop_session_duration/desktop_session_duration_observer.cc View 2 chunks +2 lines, -1 line 0 comments Download
M chrome/browser/metrics/renderer_uptime_web_contents_observer.cc View 2 chunks +2 lines, -1 line 0 comments Download
M chrome/browser/net/nss_context_chromeos.cc View 2 chunks +2 lines, -1 line 0 comments Download
M chrome/browser/ntp_snippets/bookmark_last_visit_updater.cc View 2 chunks +4 lines, -2 lines 1 comment Download
M chrome/browser/page_load_metrics/metrics_web_contents_observer.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/page_load_metrics/observers/delay_navigation_page_load_metrics_observer_unittest.cc View 1 chunk +1 line, -1 line 1 comment Download
M chrome/browser/password_manager/chrome_password_manager_client.cc View 2 chunks +4 lines, -3 lines 1 comment Download
M chrome/browser/password_manager/password_manager_test_base.cc View 2 chunks +2 lines, -1 line 0 comments Download
M chrome/browser/profiles/profile_android.cc View 2 chunks +2 lines, -1 line 0 comments Download
M chrome/browser/search/instant_io_context.cc View 2 chunks +3 lines, -1 line 0 comments Download
M chrome/browser/ssl/ssl_error_handler.h View 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/ssl/ssl_error_handler.cc View 3 chunks +5 lines, -4 lines 0 comments Download
M chrome/browser/supervised_user/supervised_user_interstitial.h View 2 chunks +2 lines, -1 line 0 comments Download
M chrome/browser/supervised_user/supervised_user_interstitial.cc View 2 chunks +2 lines, -1 line 0 comments Download
M chrome/browser/sync/sessions/sync_sessions_router_tab_helper.cc View 2 chunks +4 lines, -2 lines 0 comments Download
M chrome/browser/tracing/navigation_tracing.h View 2 chunks +2 lines, -2 lines 0 comments Download

Dependent Patchsets:

Messages

Total messages: 25 (13 generated)
Avi (use Gerrit)
3 years, 7 months ago (2017-04-29 03:08:30 UTC) #4
Avi (use Gerrit)
ping
3 years, 7 months ago (2017-05-02 01:31:52 UTC) #11
Nico
lgtm, very sorry about the delay. https://codereview.chromium.org/2846333004/diff/1/chrome/browser/data_use_measurement/data_use_web_contents_observer.cc File chrome/browser/data_use_measurement/data_use_web_contents_observer.cc (right): https://codereview.chromium.org/2846333004/diff/1/chrome/browser/data_use_measurement/data_use_web_contents_observer.cc#newcode39 chrome/browser/data_use_measurement/data_use_web_contents_observer.cc:39: base::WrapUnique(new DataUseWebContentsObserver(web_contents, service))); ...
3 years, 7 months ago (2017-05-02 20:54:10 UTC) #12
Avi (use Gerrit)
To be clear, every time I used WrapUnique, it was deliberate. MakeUnique doesn't work when ...
3 years, 7 months ago (2017-05-03 00:04:45 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/2846333004/1
3 years, 7 months ago (2017-05-03 00:06:29 UTC) #15
commit-bot: I haz the power
Committed patchset #1 (id:1) as https://chromium.googlesource.com/chromium/src/+/284ec61c76d48490010b2f1c80628306d4d75a7f
3 years, 7 months ago (2017-05-03 01:52:41 UTC) #18
Nico
On Tue, May 2, 2017 at 8:04 PM, <avi@chromium.org> wrote: > To be clear, every ...
3 years, 7 months ago (2017-05-03 15:28:20 UTC) #19
Avi (use Gerrit)
No, I changed the access of destructors. I believe I was making them conform to ...
3 years, 7 months ago (2017-05-03 15:31:32 UTC) #20
Nico
On Wed, May 3, 2017 at 11:31 AM, Avi Drissman <avi@chromium.org> wrote: > No, I ...
3 years, 7 months ago (2017-05-03 15:37:50 UTC) #21
Avi (use Gerrit)
I didn't do it needlessly. The API for SupportsUserData is being changed to use unique_ptr ...
3 years, 7 months ago (2017-05-03 15:43:08 UTC) #23
Nico
Ok, so you're saying you're fine with changing dtor visibility if the base class already ...
3 years, 7 months ago (2017-05-03 15:49:23 UTC) #24
Avi (use Gerrit)
3 years, 7 months ago (2017-05-03 16:01:10 UTC) #25
Message was sent while issue was closed.
If the base class already has a _public_ dtor, I'm fine with changing a
derived class to have a public dtor as well, as it gains us better
ownership correctness with scoped_ptr. Existing code already had the
ability to destroy the object by casting to the base class first, so
nothing is lost.

I would _never_ change the visibility of the ctor in maintenance work. I'm
not going to second-guess the author of the code.

I hope this is not controversial. If it is then I ask that we have a
discussion about it on a larger forum and come to a conclusion there rather
than on a CL.

--

The real issue here is that we prefer unique_ptr. It has _huge_ gains in
ownership semantic clarity, and the switch to it has fixed real bugs. The
problems are that 1) it requires public destructors at the level of the
class to which the pointer is made, and 2) make_unique (or our MakeUnique)
doesn't work when the constructor is private, even if the code calling
make_unique has the privilege of calling the constructor. IMO, the
inability of a caller to delegate the privilege of construction of the
object to the helper function make_unique is a flaw that makes make_unique
much less useful than it ought to be.

Avi

On Wed, May 3, 2017 at 11:49 AM, Nico Weber <thakis@chromium.org> wrote:

> Ok, so you're saying you're fine with changing dtor visibility if the base
> class already has a private dtor, but you're not fine with changing ctor
> visibility? (That'd make sense to me.)
>
> Sorry about being slow.
>
> On Wed, May 3, 2017 at 11:42 AM, Avi Drissman <avi@chromium.org> wrote:
>
>> I didn't do it needlessly. The API for SupportsUserData is being changed
>> to use unique_ptr for ownership semantics, and unique_ptr needs access to
>> the destructor..
>>
>> On Wed, May 3, 2017 at 11:37 AM, Nico Weber <thakis@chromium.org> wrote:
>>
>>> On Wed, May 3, 2017 at 11:31 AM, Avi Drissman <avi@chromium.org> wrote:
>>>
>>>> No, I changed the access of destructors.
>>>>
>>>> I believe I was making them conform to the style guide. The classes
>>>> publicly inherited from a base class that had a public destructor, so I
>>>> made the overriding destructor public too. I don't see a problem with
that.
>>>>
>>>
>>> Wait, you changed them needlessly? If so,
>>>
>>> a) please do changes like this in separate changes next time
>>> b) restricting method visibility in subclasses isn't uncommon, see this
>>> thread: https://groups.google.com/a/chromium.org/forum/#!top
>>> ic/chromium-dev/XdsXTHy9lis
>>>
>>>
>>>>
>>>> On Wed, May 3, 2017 at 11:28 AM, Nico Weber <thakis@chromium.org>
>>>> wrote:
>>>>
>>>>> On Tue, May 2, 2017 at 8:04 PM, <avi@chromium.org> wrote:
>>>>>
>>>>>> To be clear, every time I used WrapUnique, it was deliberate.
>>>>>> MakeUnique doesn't
>>>>>> work when the constructor is private, and I'm not going to start
>>>>>> changing the
>>>>>> member access of constructors of code I don't own.
>>>>>>
>>>>>
>>>>> You changed the access from some constructors. I feel we should have
>>>>> some global guideline for this, "which files are owned by Avi" maybe
isn't
>>>>> the best guideline :-)
>>>>>
>>>>>
>>>>>>
>>>>>> This is a huge issue with MakeUnique and std::make_unique, but it's a
>>>>>> fundamental design issue that we can't address here.
>>>>>>
>>>>>> https://codereview.chromium.org/2846333004/
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups
"Chromium-reviews" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to chromium-reviews+unsubscribe@chromium.org.

Powered by Google App Engine
This is Rietveld 408576698