|
|
Chromium Code Reviews
DescriptionRemove ScopedVector usage from components/history
This CL replaces ScopedVector with std::vector<std::unique_ptr>
in components/history.
ScopedVector is deprecated, see bug.
BUG=554289
Review-Url: https://codereview.chromium.org/2906953003
Cr-Commit-Position: refs/heads/master@{#478547}
Committed: https://chromium.googlesource.com/chromium/src/+/370a037ae7d0cd617c45942610c5866aff44a35c
Patch Set 1 #Patch Set 2 : Remove ScopedVector usage from components/history #
Total comments: 6
Patch Set 3 : Remove ScopedVector usage from components/history #Patch Set 4 : Remove ScopedVector usage from components/history #Messages
Total messages: 60 (39 generated)
The CQ bit was checked by leon.han@intel.com 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: ios-simulator on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator/bui...) ios-simulator-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator-xco...)
donna.wu@intel.com changed reviewers: + rockot@google.com, sky@chromium.org
Hi, sky, rocket and leon, would you please take a look at it? As a beginner, I appreciate your help. This CL replaced the deprecated ScopedVector usage under components/history folder and modified a relevant file under chrome/browser/extensions.
donna.wu@intel.com changed reviewers: + rockot@chromium.org - rockot@google.com
The CQ bit was checked by leon.han@intel.com 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: ios-simulator on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator/bui...)
sky@chromium.org changed reviewers: + brettw@chromium.org
+brettw to see if he can think of a reason not to do as I suggest here. https://codereview.chromium.org/2906953003/diff/20001/components/history/core... File components/history/core/browser/history_types.h (right): https://codereview.chromium.org/2906953003/diff/20001/components/history/core... components/history/core/browser/history_types.h:138: typedef std::vector<std::unique_ptr<URLResult>> URLResultVector; I would be inclined to make this a vector<URLResult>.
https://codereview.chromium.org/2906953003/diff/20001/components/history/core... File components/history/core/browser/history_types.h (right): https://codereview.chromium.org/2906953003/diff/20001/components/history/core... components/history/core/browser/history_types.h:138: typedef std::vector<std::unique_ptr<URLResult>> URLResultVector; On 2017/05/30 16:12:04, sky wrote: > I would be inclined to make this a vector<URLResult>. Sounds good to me! This was originally this way because there were no move semantics and copying this structure is expensive. Currently, there are move constructors for URLResult, and we already do vectors of URLResults. In fact, in HistoryBackend::QueryHistoryText I see it create a vector<URLResult>, and then do some complex dance with AppendURLBySwapping to get a heap-allocated copy of that in the URLResult. We should be able to delete AppendURLBySwapping and add a SetURLResults(std::vector<URLResult>&& results) which moves a vector. This will be much more efficient than the current code (moving a vector is almost free) and save a bunch of heap allocations. and indirections.
https://codereview.chromium.org/2906953003/diff/20001/components/history/core... File components/history/core/browser/history_types.h (right): https://codereview.chromium.org/2906953003/diff/20001/components/history/core... components/history/core/browser/history_types.h:138: typedef std::vector<std::unique_ptr<URLResult>> URLResultVector; On 2017/06/02 23:17:52, brettw wrote: > On 2017/05/30 16:12:04, sky wrote: > > I would be inclined to make this a vector<URLResult>. > > Sounds good to me! This was originally this way because there were no move > semantics and copying this structure is expensive. Currently, there are move > constructors for URLResult, and we already do vectors of URLResults. > > In fact, in HistoryBackend::QueryHistoryText I see it create a > vector<URLResult>, and then do some complex dance with AppendURLBySwapping to > get a heap-allocated copy of that in the URLResult. > > We should be able to delete AppendURLBySwapping and add a > SetURLResults(std::vector<URLResult>&& results) which moves a vector. This will > be much more efficient than the current code (moving a vector is almost free) > and save a bunch of heap allocations. and indirections. @brettw, it seems the appending method is still needed, we can not sure if the user use the same QueryResults object to receive the results of multiple QueryHistory callings or not. I saw a use case at Line 96(TestPaging function) in components/history/core/browser/history_querying_unittest.cc. There are two calling to AppendURLBySwapping in history_backend.cpp file, and the first calling also need an appending operation. SetURLResults() means replacing results, we will lost the previous result if the result object reused. https://codereview.chromium.org/2906953003/diff/20001/components/history/core... components/history/core/browser/history_types.h:138: typedef std::vector<std::unique_ptr<URLResult>> URLResultVector; On 2017/05/30 16:12:04, sky wrote: > I would be inclined to make this a vector<URLResult>. @sky, @brettw, how about using vector<URLResult*>? In this way, we can make minimal changes, because it was perceived as this compliant type before, for URLResult, the SwapResult method is actually more efficient than move constructor, it can be used while appending new result to the vector and we can keep the actual objects in heap.
The CQ bit was checked by donna.wu@intel.com 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: No L-G-T-M from a valid reviewer yet. CQ run can only be started once the patch has received an L-G-T-M from a full committer. Even if an L-G-T-M may have been provided, it was from a non-committer,_not_ a full super star committer. Committers are members of the group "project-chromium-committers". Note that this has nothing to do with OWNERS files.
On 2017/06/05 08:43:18, donna.wu wrote: > https://codereview.chromium.org/2906953003/diff/20001/components/history/core... > File components/history/core/browser/history_types.h (right): > > https://codereview.chromium.org/2906953003/diff/20001/components/history/core... > components/history/core/browser/history_types.h:138: typedef > std::vector<std::unique_ptr<URLResult>> URLResultVector; > On 2017/06/02 23:17:52, brettw wrote: > > On 2017/05/30 16:12:04, sky wrote: > > > I would be inclined to make this a vector<URLResult>. > > > > Sounds good to me! This was originally this way because there were no move > > semantics and copying this structure is expensive. Currently, there are move > > constructors for URLResult, and we already do vectors of URLResults. > > > > In fact, in HistoryBackend::QueryHistoryText I see it create a > > vector<URLResult>, and then do some complex dance with AppendURLBySwapping to > > get a heap-allocated copy of that in the URLResult. > > > > We should be able to delete AppendURLBySwapping and add a > > SetURLResults(std::vector<URLResult>&& results) which moves a vector. This > will > > be much more efficient than the current code (moving a vector is almost free) > > and save a bunch of heap allocations. and indirections. > > @brettw, it seems the appending method is still needed, we can not sure if the > user use the same QueryResults object to receive the results of multiple > QueryHistory callings or not. I saw a use case at Line 96(TestPaging function) > in components/history/core/browser/history_querying_unittest.cc. > There are two calling to AppendURLBySwapping in history_backend.cpp file, and > the first calling also need an appending operation. > SetURLResults() means replacing results, we will lost the previous result if the > result object reused. > > https://codereview.chromium.org/2906953003/diff/20001/components/history/core... > components/history/core/browser/history_types.h:138: typedef > std::vector<std::unique_ptr<URLResult>> URLResultVector; > On 2017/05/30 16:12:04, sky wrote: > > I would be inclined to make this a vector<URLResult>. > > @sky, @brettw, how about using vector<URLResult*>? In this way, we can make > minimal changes, because it was perceived as this compliant type before, for > URLResult, the SwapResult method is actually more efficient than move > constructor, it can be used while appending new result to the vector and we can > keep the actual objects in heap. The path has been updated by using vector<URLResult>. Would you please help to trigger the trybot?
The CQ bit was checked by rockot@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.
https://codereview.chromium.org/2906953003/diff/20001/components/history/core... File components/history/core/browser/history_types.h (right): https://codereview.chromium.org/2906953003/diff/20001/components/history/core... components/history/core/browser/history_types.h:138: typedef std::vector<std::unique_ptr<URLResult>> URLResultVector; We don't want to do that, who will free the pointers then? The whole point of the unique_ptr is to get the ownership semantics correct. There is also no desire to keep things on the heap. The test you mentioned that relies on the append behavior should just be updated. I think that test should not have been written that way. The normal history APIs all give a new QueryResults object to the callback, so there is no way for real code to depend on appending-to-an-existing-object behavior.
https://codereview.chromium.org/2906953003/diff/20001/components/history/core... File components/history/core/browser/history_types.h (right): https://codereview.chromium.org/2906953003/diff/20001/components/history/core... components/history/core/browser/history_types.h:138: typedef std::vector<std::unique_ptr<URLResult>> URLResultVector; On 2017/06/05 22:39:27, brettw wrote: > We don't want to do that, who will free the pointers then? The whole point of > the unique_ptr is to get the ownership semantics correct. There is also no > desire to keep things on the heap. > > The test you mentioned that relies on the append behavior should just be > updated. I think that test should not have been written that way. The normal > history APIs all give a new QueryResults object to the callback, so there is no > way for real code to depend on appending-to-an-existing-object behavior. Got it! I'm working on the solution and have a question about some other members in Class QueryResults. If SetURLResults() replaced the result_ vector , the URL to index map "url_to_results_" will need to be cleared before re-constructing the entries accordingly and the "reached_beginning_" flag will always been set to true after that. Right? How about first_time_searched_, does it need to be reset? You mentioned "bug 1203054" about this member, but I can't find it. Is this bug still active? This member(first_time_searched_) and its setter, getter have only been defined and never been used. Is it OK to delete it?
On 2017/06/06 14:48:15, donna.wu wrote: > https://codereview.chromium.org/2906953003/diff/20001/components/history/core... > File components/history/core/browser/history_types.h (right): > > https://codereview.chromium.org/2906953003/diff/20001/components/history/core... > components/history/core/browser/history_types.h:138: typedef > std::vector<std::unique_ptr<URLResult>> URLResultVector; > On 2017/06/05 22:39:27, brettw wrote: > > We don't want to do that, who will free the pointers then? The whole point of > > the unique_ptr is to get the ownership semantics correct. There is also no > > desire to keep things on the heap. > > > > The test you mentioned that relies on the append behavior should just be > > updated. I think that test should not have been written that way. The normal > > history APIs all give a new QueryResults object to the callback, so there is > no > > way for real code to depend on appending-to-an-existing-object behavior. > > > Got it! I'm working on the solution and have a question about some other members > in Class QueryResults. If SetURLResults() replaced the result_ vector , the URL > to index map "url_to_results_" will need to be cleared before re-constructing > the entries accordingly and the "reached_beginning_" flag will always been set > to true after that. Right? I didn't notice that, but you're right, you will need to recreate the url_to_results_ map when the set function is called. > How about first_time_searched_, does it need to be reset? You mentioned "bug > 1203054" about this member, but I can't find it. Is this bug still active? This > member(first_time_searched_) and its setter, getter have only been defined and > never been used. Is it OK to delete it? It sure looks like first_time_searched_ and associated stuff can be deleted.
On 2017/06/06 16:00:42, brettw wrote: > On 2017/06/06 14:48:15, donna.wu wrote: > > > https://codereview.chromium.org/2906953003/diff/20001/components/history/core... > > File components/history/core/browser/history_types.h (right): > > > > > https://codereview.chromium.org/2906953003/diff/20001/components/history/core... > > components/history/core/browser/history_types.h:138: typedef > > std::vector<std::unique_ptr<URLResult>> URLResultVector; > > On 2017/06/05 22:39:27, brettw wrote: > > > We don't want to do that, who will free the pointers then? The whole point > of > > > the unique_ptr is to get the ownership semantics correct. There is also no > > > desire to keep things on the heap. > > > > > > The test you mentioned that relies on the append behavior should just be > > > updated. I think that test should not have been written that way. The normal > > > history APIs all give a new QueryResults object to the callback, so there is > > no > > > way for real code to depend on appending-to-an-existing-object behavior. > > > > > > Got it! I'm working on the solution and have a question about some other > members > > in Class QueryResults. If SetURLResults() replaced the result_ vector , the > URL > > to index map "url_to_results_" will need to be cleared before re-constructing > > the entries accordingly and the "reached_beginning_" flag will always been set > > to true after that. Right? > > I didn't notice that, but you're right, you will need to recreate the > url_to_results_ map when the set function is called. > > > How about first_time_searched_, does it need to be reset? You mentioned "bug > > 1203054" about this member, but I can't find it. Is this bug still active? > This > > member(first_time_searched_) and its setter, getter have only been defined and > > never been used. Is it OK to delete it? > > It sure looks like first_time_searched_ and associated stuff can be deleted. @brettw @sky the CL has been updated according to the comments.
lgtm
On 2017/06/07 21:06:03, brettw wrote: > lgtm Thank you!
The CQ bit was checked by donna.wu@intel.com 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 unchecked by donna.wu@intel.com
The CQ bit was checked by donna.wu@intel.com
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
Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
The CQ bit was checked by donna.wu@intel.com 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...
donna.wu@intel.com changed reviewers: + rohitrao@chromium.org, tsergeant@chromium.org - rockot@chromium.org
tsergeant@chromium.org: Please review changes in rohitrao@chromium.org: Please review changes in
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 donna.wu@intel.com
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
Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
The CQ bit was checked by donna.wu@intel.com 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 donna.wu@intel.com
rs lgtm for browsing_history_handler_unittest.cc
ios/ lgtm
The CQ bit was checked by donna.wu@intel.com
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 60001, "attempt_start_ts": 1497236313546040,
"parent_rev": "8f61c09fb2b62a73f36eac10eb873690b00810b9", "commit_rev":
"370a037ae7d0cd617c45942610c5866aff44a35c"}
Message was sent while issue was closed.
Description was changed from ========== Remove ScopedVector usage from components/history This CL replaces ScopedVector with std::vector<std::unique_ptr> in components/history. ScopedVector is deprecated, see bug. BUG=554289 ========== to ========== Remove ScopedVector usage from components/history This CL replaces ScopedVector with std::vector<std::unique_ptr> in components/history. ScopedVector is deprecated, see bug. BUG=554289 Review-Url: https://codereview.chromium.org/2906953003 Cr-Commit-Position: refs/heads/master@{#478547} Committed: https://chromium.googlesource.com/chromium/src/+/370a037ae7d0cd617c45942610c5... ==========
Message was sent while issue was closed.
Committed patchset #4 (id:60001) as https://chromium.googlesource.com/chromium/src/+/370a037ae7d0cd617c45942610c5... |
