|
|
Chromium Code Reviews|
Created:
4 years, 1 month ago by Gleb Lanbin Modified:
4 years, 1 month ago CC:
chromium-reviews, blink-reviews, blink-reviews-wtf_chromium.org, Mikhail Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionAdd WTF::MakeUnique to mirror C++14's std::make_unique.
This implementation is identical to base/memory/ptr_util.h.
BUG=662304
Committed: https://crrev.com/dc91022fc289e4bdfe0ca9a857775b91762d0b78
Cr-Commit-Position: refs/heads/master@{#429878}
Patch Set 1 #Patch Set 2 : reuse the implementation from base::MakeUnique #
Total comments: 1
Patch Set 3 : rename MakeUnique -> makeUnique #
Messages
Total messages: 52 (37 generated)
The CQ bit was checked by glebl@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_...)
The CQ bit was checked by glebl@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by glebl@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by glebl@chromium.org
The CQ bit was unchecked by glebl@chromium.org
The CQ bit was checked by glebl@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
glebl@chromium.org changed reviewers: + haraken@chromium.org
haraken@chromium.org changed reviewers: + yutak@chromium.org
+yutak What's our plan on MakeUnique and WrapUnique in Blink? I remember we didn't want to support MakeUnique in Blink because we cannot use MakeUnique for GarbageCollected objects and RefPtrs (i.e, prefer using WrapUnique for all object types).
I'm OK with adding MakeUnique as long as we need it. Isn't it possible to somehow alias base::MakeUnique instead of reimplementing it?
On 2016/10/31 09:34:13, Yuta Kitamura wrote: > I'm OK with adding MakeUnique as long as we need it. > > Isn't it possible to somehow alias base::MakeUnique instead > of reimplementing it? we want to use MakeUnique in LayoutNG code(http://goo.gl/1hwhfX) unfortunately base/memory/ptr_util.h cannot be used in Blink because of "-base" from third_party's include_rules. I don't know how to bypass that rule.
On 2016/10/31 14:44:55, glebl wrote: > On 2016/10/31 09:34:13, Yuta Kitamura wrote: > > I'm OK with adding MakeUnique as long as we need it. > > > > Isn't it possible to somehow alias base::MakeUnique instead > > of reimplementing it? > > we want to use MakeUnique in LayoutNG code(http://goo.gl/1hwhfX) > > unfortunately base/memory/ptr_util.h cannot be used in > Blink because of "-base" from third_party's include_rules. I don't know how to > bypass that rule. WTF can depend on base (it's core/modules that cannot depend on base). If you put a few aliases of base::MakeUnique definitions in PtrUtil.h, that would work, I guess.
On 2016/11/01 05:52:49, Yuta Kitamura wrote: > On 2016/10/31 14:44:55, glebl wrote: > > On 2016/10/31 09:34:13, Yuta Kitamura wrote: > > > I'm OK with adding MakeUnique as long as we need it. > > > > > > Isn't it possible to somehow alias base::MakeUnique instead > > > of reimplementing it? > > > > we want to use MakeUnique in LayoutNG code(http://goo.gl/1hwhfX) > > > > unfortunately base/memory/ptr_util.h cannot be used in > > Blink because of "-base" from third_party's include_rules. I don't know how to > > bypass that rule. > > WTF can depend on base (it's core/modules that cannot depend on > base). If you put a few aliases of base::MakeUnique definitions > in PtrUtil.h, that would work, I guess. Are you planning to use MakeUnique in only LayoutNG? Or are you planning to use MakeUnique for all std::unique_ptr allocations in Blink?
On 2016/11/01 06:24:16, haraken wrote:
> On 2016/11/01 05:52:49, Yuta Kitamura wrote:
> > On 2016/10/31 14:44:55, glebl wrote:
> > > On 2016/10/31 09:34:13, Yuta Kitamura wrote:
> > > > I'm OK with adding MakeUnique as long as we need it.
> > > >
> > > > Isn't it possible to somehow alias base::MakeUnique instead
> > > > of reimplementing it?
> > >
> > > we want to use MakeUnique in LayoutNG code(http://goo.gl/1hwhfX)
> > >
> > > unfortunately base/memory/ptr_util.h cannot be used in
> > > Blink because of "-base" from third_party's include_rules. I don't know
how
> to
> > > bypass that rule.
> >
> > WTF can depend on base (it's core/modules that cannot depend on
> > base). If you put a few aliases of base::MakeUnique definitions
> > in PtrUtil.h, that would work, I guess.
when I try to include base::MakeUnique in PtrUtil.h I get a presubmit error
You added one or more #includes that violate checkdeps rules.
third_party/WebKit/Source/wtf/PtrUtil.h
Illegal include: "base/memory/ptr_util.h"
Because of "-base" from third_party's include_rules.
and I guess we don't just want to have an alias for them as we want to check for
!WTF::IsGarbageCollectedType first, do we?
>
> Are you planning to use MakeUnique in only LayoutNG? Or are you planning to
use
> MakeUnique for all std::unique_ptr allocations in Blink?
I think once MakeUnique is introduced Blink developers start using it instead of
std::unique_ptr. I believe that using MakeUnique will simplify the migration to
std::make_unique later.
On 2016/11/01 18:35:41, glebl wrote: > On 2016/11/01 06:24:16, haraken wrote: > > On 2016/11/01 05:52:49, Yuta Kitamura wrote: > > > On 2016/10/31 14:44:55, glebl wrote: > > > > On 2016/10/31 09:34:13, Yuta Kitamura wrote: > > > > > I'm OK with adding MakeUnique as long as we need it. > > > > > > > > > > Isn't it possible to somehow alias base::MakeUnique instead > > > > > of reimplementing it? > > > > > > > > we want to use MakeUnique in LayoutNG code(http://goo.gl/1hwhfX) > > > > > > > > unfortunately base/memory/ptr_util.h cannot be used in > > > > Blink because of "-base" from third_party's include_rules. I don't know > how > > to > > > > bypass that rule. > > > > > > WTF can depend on base (it's core/modules that cannot depend on > > > base). If you put a few aliases of base::MakeUnique definitions > > > in PtrUtil.h, that would work, I guess. > > when I try to include base::MakeUnique in PtrUtil.h I get a presubmit error > You added one or more #includes that violate checkdeps rules. > third_party/WebKit/Source/wtf/PtrUtil.h > Illegal include: "base/memory/ptr_util.h" > Because of "-base" from third_party's include_rules. > > and I guess we don't just want to have an alias for them as we want to check for > !WTF::IsGarbageCollectedType first, do we? > > > > > Are you planning to use MakeUnique in only LayoutNG? Or are you planning to > use > > MakeUnique for all std::unique_ptr allocations in Blink? > > I think once MakeUnique is introduced Blink developers start using it instead of > std::unique_ptr. I believe that using MakeUnique will simplify the migration to > std::make_unique later. Hmm, if you have a plan to replace most of existing new(...)'s with MakeUnique()'s, I'm fine with introducing it. However, otherwise, I'm slightly negative about introducing it since we will end up with adding yet another way of creating a pointer. Note that GarbageCollected objects use new().
The CQ bit was checked by glebl@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On 2016/11/02 01:29:26, haraken wrote: > On 2016/11/01 18:35:41, glebl wrote: > > On 2016/11/01 06:24:16, haraken wrote: > > > On 2016/11/01 05:52:49, Yuta Kitamura wrote: > > > > On 2016/10/31 14:44:55, glebl wrote: > > > > > On 2016/10/31 09:34:13, Yuta Kitamura wrote: > > > > > > I'm OK with adding MakeUnique as long as we need it. > > > > > > > > > > > > Isn't it possible to somehow alias base::MakeUnique instead > > > > > > of reimplementing it? > > > > > > > > > > we want to use MakeUnique in LayoutNG code(http://goo.gl/1hwhfX) > > > > > > > > > > unfortunately base/memory/ptr_util.h cannot be used in > > > > > Blink because of "-base" from third_party's include_rules. I don't know > > how > > > to > > > > > bypass that rule. > > > > > > > > WTF can depend on base (it's core/modules that cannot depend on > > > > base). If you put a few aliases of base::MakeUnique definitions > > > > in PtrUtil.h, that would work, I guess. > > > > when I try to include base::MakeUnique in PtrUtil.h I get a presubmit error > > You added one or more #includes that violate checkdeps rules. > > third_party/WebKit/Source/wtf/PtrUtil.h > > Illegal include: "base/memory/ptr_util.h" > > Because of "-base" from third_party's include_rules. > > > > and I guess we don't just want to have an alias for them as we want to check > for > > !WTF::IsGarbageCollectedType first, do we? > > > > > > > > Are you planning to use MakeUnique in only LayoutNG? Or are you planning to > > use > > > MakeUnique for all std::unique_ptr allocations in Blink? > > > > I think once MakeUnique is introduced Blink developers start using it instead > of > > std::unique_ptr. I believe that using MakeUnique will simplify the migration > to > > std::make_unique later. > > Hmm, if you have a plan to replace most of existing new(...)'s with > MakeUnique()'s, I'm fine with introducing it. However, otherwise, I'm slightly > negative about introducing it since we will end up with adding yet another way > of creating a pointer. Note that GarbageCollected objects use new(). FYI, base/memory/ptr_util.h has MakeUnique as well as WrapUnique. According to CodeSearch we have 2 occurrences of std::unique_ptr<T>(new T) and 425 of wrapUnique(new T) https://cs.chromium.org/search/?q=pcre:yes+unique_ptr%3C.*%3E%5C(new+case:yes... https://cs.chromium.org/search/?q=%22wrapUnique(new%22+case:yes+file:WebKit&p... I can create a bug to track the migration to WTF::MakeUnique and assign it to myself. Will it work? re: Isn't it possible to somehow alias base::MakeUnique instead ... done. The latest version reuses the implementation from base::MakeUnique
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...)
The CQ bit was checked by glebl@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
LGTM w/ nit https://codereview.chromium.org/2455313003/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/wtf/PtrUtil.h (right): https://codereview.chromium.org/2455313003/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/wtf/PtrUtil.h:33: auto MakeUnique(Args&&... args) I want to name it "makeUnique" for now. Having random naming schemes isn't great.
thanks for the review
Description was changed from ========== Add WTF::MakeUnique to mirror C++14's std::make_unique. This implementation is identical to base/memory/ptr_util.h. ========== to ========== Add WTF::MakeUnique to mirror C++14's std::make_unique. This implementation is identical to base/memory/ptr_util.h. BUG=662304 ==========
LGTM assuming that you plan to replace all wrapUnique(new T)_s with MakeUnique in a reasonable timeline.
The CQ bit was checked by glebl@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by glebl@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from yutak@chromium.org Link to the patchset: https://codereview.chromium.org/2455313003/#ps40001 (title: "rename MakeUnique -> makeUnique")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== Add WTF::MakeUnique to mirror C++14's std::make_unique. This implementation is identical to base/memory/ptr_util.h. BUG=662304 ========== to ========== Add WTF::MakeUnique to mirror C++14's std::make_unique. This implementation is identical to base/memory/ptr_util.h. BUG=662304 ==========
Message was sent while issue was closed.
Committed patchset #3 (id:40001)
Message was sent while issue was closed.
Description was changed from ========== Add WTF::MakeUnique to mirror C++14's std::make_unique. This implementation is identical to base/memory/ptr_util.h. BUG=662304 ========== to ========== Add WTF::MakeUnique to mirror C++14's std::make_unique. This implementation is identical to base/memory/ptr_util.h. BUG=662304 Committed: https://crrev.com/dc91022fc289e4bdfe0ca9a857775b91762d0b78 Cr-Commit-Position: refs/heads/master@{#429878} ==========
Message was sent while issue was closed.
Patchset 3 (id:??) landed as https://crrev.com/dc91022fc289e4bdfe0ca9a857775b91762d0b78 Cr-Commit-Position: refs/heads/master@{#429878} |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
