New issue
Advanced search Search tips

Issue 643358 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

Improve ownership model in EditSearchEngineController

Project Member Reported by pkasting@chromium.org, Sep 1 2016

Issue description

EditSearchEngineController::template_url_ is sometimes owned by the class and sometimes just a raw pointer someone else owns.  (See e.g. AcceptAddOrEdit() and CleanUpCancelledAdd().)

This is a mess.  Ownership should be clear.  We shouldn't use the same variable to sometimes have different semantics.  Perhaps this shouldn't even by one class.  Someone needs to look at what would make this sane.
 
Project Member

Comment 1 by sheriffbot@chromium.org, Sep 4 2017

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available. If you change it back, also remove the "Hotlist-Recharge-Cold" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Labels: -Hotlist-Recharge-Cold
Status: Available (was: Untriaged)
Hello!

I would like to take on this bug. I was digging into the code and I wanted to propose a simple solution:

We can wrap template_url_ inside a unique_ptr on EditSearchEngineController, this way we make sure to be clear that this class currently owns the reference to the pointer. Then whenever template_url_ is passed as a parameter we just get the raw pointer and pass it to the function.

This would work except for this line of code: https://cs.chromium.org/chromium/src/chrome/browser/ui/search_engines/edit_search_engine_controller.cc?sq=package:chromium&l=108

Here we can see that the ownership of template_url_ is being transfer, so we can make use of std::move to transfer the ownership and also document that the function AcceptAddOrEdit transfers the ownership of template_url_
If my memory serves, the problem is that if the controller owns this pointer, that only works for adds, not edits.  For adds, it makes sense that we construct this, then hand it off to the template URL service.  For edits, we can't own the pointer, because the template URL service already does.  So either we can't use one variable to hold both of these, or we shouldn't use one "controller" object to deal with both adding and editing, or something.
Project Member

Comment 5 by sheriffbot@chromium.org, Nov 29

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: Available (was: Untriaged)

Sign in to add a comment