Chromium Code Reviews| Index: ios/chrome/browser/tabs/tab_model.mm |
| diff --git a/ios/chrome/browser/tabs/tab_model.mm b/ios/chrome/browser/tabs/tab_model.mm |
| index 310c4a190e9eabfbffdca09249af53cd9bfa5c49..14819c5b2ba77b17dd844e7d577e00640a483a45 100644 |
| --- a/ios/chrome/browser/tabs/tab_model.mm |
| +++ b/ios/chrome/browser/tabs/tab_model.mm |
| @@ -627,8 +627,14 @@ Tab* GetOpenerForTab(id<NSFastEnumeration> tabs, Tab* tab) { |
| [_tabRetainer addObject:newTab]; |
| [newTab setParentTabModel:self]; |
| - _webStateList.ReplaceWebStateAt(index, newTab.webState, |
| - GetOpenerForTab(self, newTab).webState); |
| + // The WebState is owned by the associated Tab, so it is safe to ignore |
| + // the result and won't cause a memory leak. Once the ownershipd is moved |
|
rohitrao (ping after 24h)
2017/02/28 22:35:58
Typo: ownership.
sdefresne
2017/03/01 01:22:53
Done.
|
| + // to WebStateList, this function will return a std::unique_ptr<> and the |
| + // object destroyed as expected, so it will fine to ignore the result then |
| + // too. See http://crbug.com/546222 for progress of changing the ownership |
| + // of the WebStates. |
| + ignore_result(_webStateList.ReplaceWebStateAt( |
| + index, newTab.webState, GetOpenerForTab(self, newTab).webState)); |
| if (self.currentTab == oldTab) |
| [self changeSelectedTabFrom:nil to:newTab persistState:NO]; |
| @@ -792,7 +798,13 @@ Tab* GetOpenerForTab(id<NSFastEnumeration> tabs, Tab* tab) { |
| DCHECK([_tabRetainer containsObject:closedTab]); |
| [_tabRetainer removeObject:closedTab]; |
| - _webStateList.DetachWebStateAt(closedTabIndex); |
| + // The WebState is owned by the associated Tab, so it is safe to ignore |
| + // the result and won't cause a memory leak. Once the ownershipd is moved |
|
rohitrao (ping after 24h)
2017/02/28 22:35:58
Typo: ownership.
sdefresne
2017/03/01 01:22:53
Done.
|
| + // to WebStateList, this function will return a std::unique_ptr<> and the |
| + // object destroyed as expected, so it will fine to ignore the result then |
| + // too. See http://crbug.com/546222 for progress of changing the ownership |
| + // of the WebStates. |
| + ignore_result(_webStateList.DetachWebStateAt(closedTabIndex)); |
| // Current tab has closed, update the selected tab and swap in its |
| // contents. There is nothing to do if a non-selected tab is closed as |