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

Issue 1619733003: ui/base/models: rewrite TreeNode without using ScopedVector (Closed)

Created:
4 years, 11 months ago by tfarina
Modified:
4 years, 11 months ago
Reviewers:
vabr (Chromium), sky
CC:
chromium-reviews, danakj
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

ui/base/models: rewrite TreeNode without using ScopedVector Now that we are using C++11, moveable types inside containers are supported and ScopedVector will be removed. So we should migrate to a solution that does not use ScopedVector. Unfortunately children() accessor complicates the things and does not allow us to easily use std::vector<scoped_ptr<NodeType>>, so another solution with STLDeleteElements was choosen. BUG=554289 TEST=ui_base_unittests --gtest_filter=*Tree* R=sky@chromium.org Committed: https://crrev.com/62a03a94d25bfa7407b088120da89a4cbcbb2cb9 Cr-Commit-Position: refs/heads/master@{#370769}

Patch Set 1 #

Total comments: 5

Patch Set 2 : content_settings fix #

Unified diffs Side-by-side diffs Delta from patch set Stats (+9 lines, -7 lines) Patch
M chrome/browser/ui/content_settings/content_setting_image_model.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M ui/base/models/tree_node_model.h View 6 chunks +8 lines, -7 lines 0 comments Download

Messages

Total messages: 14 (4 generated)
tfarina
Is this OK? PTAL! https://codereview.chromium.org/1619733003/diff/1/ui/base/models/tree_node_model.h File ui/base/models/tree_node_model.h (right): https://codereview.chromium.org/1619733003/diff/1/ui/base/models/tree_node_model.h#newcode173 ui/base/models/tree_node_model.h:173: std::vector<NodeType*>& children() { return children_; ...
4 years, 11 months ago (2016-01-21 14:24:45 UTC) #1
sky
LGTM https://codereview.chromium.org/1619733003/diff/1/ui/base/models/tree_node_model.h File ui/base/models/tree_node_model.h (right): https://codereview.chromium.org/1619733003/diff/1/ui/base/models/tree_node_model.h#newcode173 ui/base/models/tree_node_model.h:173: std::vector<NodeType*>& children() { return children_; } On 2016/01/21 ...
4 years, 11 months ago (2016-01-21 18:53:55 UTC) #2
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1619733003/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1619733003/20001
4 years, 11 months ago (2016-01-21 19:10:12 UTC) #5
commit-bot: I haz the power
Committed patchset #2 (id:20001)
4 years, 11 months ago (2016-01-21 20:19:27 UTC) #6
commit-bot: I haz the power
Patchset 2 (id:??) landed as https://crrev.com/62a03a94d25bfa7407b088120da89a4cbcbb2cb9 Cr-Commit-Position: refs/heads/master@{#370769}
4 years, 11 months ago (2016-01-21 20:20:36 UTC) #8
vabr (Chromium)
Drive-by question for sky@. Cheers, Vaclav https://codereview.chromium.org/1619733003/diff/1/ui/base/models/tree_node_model.h File ui/base/models/tree_node_model.h (right): https://codereview.chromium.org/1619733003/diff/1/ui/base/models/tree_node_model.h#newcode173 ui/base/models/tree_node_model.h:173: std::vector<NodeType*>& children() { ...
4 years, 11 months ago (2016-01-22 13:57:51 UTC) #10
sky
https://codereview.chromium.org/1619733003/diff/1/ui/base/models/tree_node_model.h File ui/base/models/tree_node_model.h (right): https://codereview.chromium.org/1619733003/diff/1/ui/base/models/tree_node_model.h#newcode173 ui/base/models/tree_node_model.h:173: std::vector<NodeType*>& children() { return children_; } On 2016/01/22 13:57:51, ...
4 years, 11 months ago (2016-01-22 16:42:09 UTC) #11
vabr (Chromium)
https://codereview.chromium.org/1619733003/diff/1/ui/base/models/tree_node_model.h File ui/base/models/tree_node_model.h (right): https://codereview.chromium.org/1619733003/diff/1/ui/base/models/tree_node_model.h#newcode173 ui/base/models/tree_node_model.h:173: std::vector<NodeType*>& children() { return children_; } On 2016/01/22 16:42:09, ...
4 years, 11 months ago (2016-01-22 16:44:49 UTC) #12
sky
On 2016/01/22 16:44:49, vabr (Chromium) wrote: > https://codereview.chromium.org/1619733003/diff/1/ui/base/models/tree_node_model.h > File ui/base/models/tree_node_model.h (right): > > https://codereview.chromium.org/1619733003/diff/1/ui/base/models/tree_node_model.h#newcode173 ...
4 years, 11 months ago (2016-01-22 16:49:25 UTC) #13
vabr (Chromium)
4 years, 11 months ago (2016-01-22 16:52:14 UTC) #14
Message was sent while issue was closed.
On 2016/01/22 16:49:25, sky wrote:
> On 2016/01/22 16:44:49, vabr (Chromium) wrote:
> >
>
https://codereview.chromium.org/1619733003/diff/1/ui/base/models/tree_node_mo...
> > File ui/base/models/tree_node_model.h (right):
> > 
> >
>
https://codereview.chromium.org/1619733003/diff/1/ui/base/models/tree_node_mo...
> > ui/base/models/tree_node_model.h:173: std::vector<NodeType*>& children() {
> > return children_; }
> > On 2016/01/22 16:42:09, sky wrote:
> > > On 2016/01/22 13:57:51, vabr (Chromium) wrote:
> > > > On 2016/01/21 18:53:54, sky wrote:
> > > > > On 2016/01/21 14:24:45, tfarina wrote:
> > > > > > I had to use std::vector<NodeType*> because of this accessor. I wish
> we
> > > > didn't
> > > > > > have it all!
> > > > > 
> > > > > I disagree. It's an implementation detail as to how this class stores
> the
> > > > > underlying children and this accessor is meant to return the children.
> It
> > > > > doesn't make sense to return a vector<scoped_ptr<NodeType>>& here.
> > > > 
> > > > Does that mean that the accessor is meant to abstract the way the
children
> > are
> > > > stored? It gives full access exactly to the storage, which does not seem
> > like
> > > an
> > > > abstraction.
> > > > 
> > > > It's not clear to me how the caller is supposed to use the accessor.
> Because
> > > it
> > > > has no const in the return type, and no comment about permitted usage,
it
> > > seems
> > > > like it is meant to modify the storage of children. But then I don't
> > > understand
> > > > why it would not make sense to expose the storage as a vector of
> > scoped_ptrs.
> > > 
> > > Good point. I missed that it isn't const. Callers are allowed to mutate to
> > their
> > > hearts content.
> > 
> > Right, in which case it seems like exposing the scoped_ptrs in the vector
> would
> > make it easier for the callers not to mess up ownership accidentally. Would
> you
> > agree with that?
> 
> I briefly looked at the usage. It's a mixture of find and sorting. Exposing
> vector<scoped_ptr> would make that usage more painful.

Fair enough, thanks for checking!
Cheers,
Vaclav

Powered by Google App Engine
This is Rietveld 408576698