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

Issue 2710183003: Fix WebStateListObserver::WebStateDetachedAt() parameter lifetime. (Closed)

Created:
3 years, 10 months ago by sdefresne
Modified:
3 years, 9 months ago
CC:
chromium-reviews, marq+watch_chromium.org, pkl (ping after 24h if needed), noyau+watch_chromium.org, sdefresne+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix WebStateListObserver::WebStateDetachedAt() parameter lifetime. The WebState pointer passed to WebStateListObserver::WebStateDetachedAt() was a pointer to deallocated memory if WebStateList managed the ownership of the WebState because destroying the WebStateListWrapper deallocated it. Change WebStateList::DetachWebStateAt() to release the ownership of the WebState and mark the method (and WebStateList::ReplaceWebStateAt) with WARN_UNUSED_RESULT so that compiler ensure client code uses the returned value (by passing it to a std::unique_ptr<> for example). Change how the lifetime of the WebState is managed in WebStateList to avoid making the same class of errors in the future (still not optimal as the best would be to use std::unique_ptr<> but it is not possible until Tab* and WebState* ownership is reversed). BUG=687207 Review-Url: https://codereview.chromium.org/2710183003 Cr-Commit-Position: refs/heads/master@{#453790} Committed: https://chromium.googlesource.com/chromium/src/+/977ff883dfd769b8b79bdb73ed3544b5fa971abb

Patch Set 1 #

Total comments: 2

Patch Set 2 : Mark WebStateList::WebStateWrapper constructor as explicit. #

Total comments: 4

Patch Set 3 : Fix typos. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+49 lines, -29 lines) Patch
M ios/chrome/browser/tabs/tab_model.mm View 1 2 2 chunks +15 lines, -3 lines 0 comments Download
M ios/shared/chrome/browser/tabs/web_state_list.h View 1 2 chunks +5 lines, -3 lines 0 comments Download
M ios/shared/chrome/browser/tabs/web_state_list.mm View 1 5 chunks +23 lines, -20 lines 0 comments Download
M ios/shared/chrome/browser/tabs/web_state_list_unittest.mm View 3 chunks +6 lines, -3 lines 0 comments Download

Messages

Total messages: 28 (17 generated)
sdefresne
Please take a look and send to CQ if LGTY.
3 years, 10 months ago (2017-02-23 16:46:02 UTC) #6
sdefresne
rohitrao: ping
3 years, 10 months ago (2017-02-24 10:55:23 UTC) #7
sdefresne
Peter: can you take a look too? Note that the WebStateList cannot yet always owns ...
3 years, 9 months ago (2017-02-27 18:25:10 UTC) #9
pkl (ping after 24h if needed)
LGTM https://codereview.chromium.org/2710183003/diff/1/ios/shared/chrome/browser/tabs/web_state_list.mm File ios/shared/chrome/browser/tabs/web_state_list.mm (right): https://codereview.chromium.org/2710183003/diff/1/ios/shared/chrome/browser/tabs/web_state_list.mm#newcode22 ios/shared/chrome/browser/tabs/web_state_list.mm:22: WebStateWrapper(web::WebState* web_state); I think the style guide mandates ...
3 years, 9 months ago (2017-02-27 19:32:10 UTC) #10
sdefresne
https://codereview.chromium.org/2710183003/diff/1/ios/shared/chrome/browser/tabs/web_state_list.mm File ios/shared/chrome/browser/tabs/web_state_list.mm (right): https://codereview.chromium.org/2710183003/diff/1/ios/shared/chrome/browser/tabs/web_state_list.mm#newcode22 ios/shared/chrome/browser/tabs/web_state_list.mm:22: WebStateWrapper(web::WebState* web_state); On 2017/02/27 19:32:09, pklpkl wrote: > I ...
3 years, 9 months ago (2017-02-28 05:52:52 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2710183003/20001
3 years, 9 months ago (2017-02-28 18:10:04 UTC) #18
commit-bot: I haz the power
No L-G-T-M from a valid reviewer yet. CQ run can only be started by full ...
3 years, 9 months ago (2017-02-28 18:10:09 UTC) #20
rohitrao (ping after 24h)
lgtm https://codereview.chromium.org/2710183003/diff/20001/ios/chrome/browser/tabs/tab_model.mm File ios/chrome/browser/tabs/tab_model.mm (right): https://codereview.chromium.org/2710183003/diff/20001/ios/chrome/browser/tabs/tab_model.mm#newcode631 ios/chrome/browser/tabs/tab_model.mm:631: // the result and won't cause a memory ...
3 years, 9 months ago (2017-02-28 22:35:58 UTC) #21
sdefresne
https://codereview.chromium.org/2710183003/diff/20001/ios/chrome/browser/tabs/tab_model.mm File ios/chrome/browser/tabs/tab_model.mm (right): https://codereview.chromium.org/2710183003/diff/20001/ios/chrome/browser/tabs/tab_model.mm#newcode631 ios/chrome/browser/tabs/tab_model.mm:631: // the result and won't cause a memory leak. ...
3 years, 9 months ago (2017-03-01 01:22:53 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2710183003/40001
3 years, 9 months ago (2017-03-01 01:23:36 UTC) #25
commit-bot: I haz the power
3 years, 9 months ago (2017-03-01 01:37:20 UTC) #28
Message was sent while issue was closed.
Committed patchset #3 (id:40001) as
https://chromium.googlesource.com/chromium/src/+/977ff883dfd769b8b79bdb73ed35...

Powered by Google App Engine
This is Rietveld 408576698