|
|
Created:
3 years, 8 months ago by lpromero Modified:
3 years, 8 months ago CC:
chromium-reviews, marq+scrutinize_chromium.org, jdonnelly+watch_chromium.org, ios-reviews+chrome_chromium.org, ios-reviews_chromium.org, pkl (ping after 24h if needed), noyau+watch_chromium.org, ios-reviews+clean_chromium.org, asvitkine+watch_chromium.org, marq+watch_chromium.org, lpromero+watch_chromium.org, sdefresne+watch_chromium.org Target Ref:
refs/heads/master Project:
chromium Visibility:
Public. |
DescriptionUse a scoped WebStateListObserverBridge.
BUG=none
R=rohitrao@chromium.org
CC=sdefresne@chromium.org
Review-Url: https://codereview.chromium.org/2820493002
Cr-Commit-Position: refs/heads/master@{#466321}
Committed: https://chromium.googlesource.com/chromium/src/+/8041d6145bbd1f92ff8d5dea5264be9e59d8fc3e
Patch Set 1 #Patch Set 2 : Use ScopedObserver #
Total comments: 8
Patch Set 3 : Feedback #
Messages
Total messages: 27 (17 generated)
The CQ bit was checked by lpromero@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.
sdefresne@chromium.org changed reviewers: + sdefresne@chromium.org
I don't think we should go this way as Observers are implementing a M:N relationship (except for WebStateObserver that has a weird API). For serialisation in the new architecture, I have a class that requires this M:N relationship (as it needs to observe event from all WebStateLists corresponding to a single BrowserList).
Description was changed from ========== Migrate to the RAII API of WebStateListObserver. BUG=none R=rohitrao@chromium.org CC=sdefresne@chromium.org ========== to ========== Use a scoped WebStateListObserverBridge. BUG=none R=rohitrao@chromium.org CC=sdefresne@chromium.org ==========
The CQ bit was checked by lpromero@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...
Updated.
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...)
https://codereview.chromium.org/2820493002/diff/20001/ios/chrome/browser/web_... File ios/chrome/browser/web_state_list/web_state_list_fast_enumeration_helper.mm (left): https://codereview.chromium.org/2820493002/diff/20001/ios/chrome/browser/web_... ios/chrome/browser/web_state_list/web_state_list_fast_enumeration_helper.mm:59: _webStateList->RemoveObserver(_observerBridge.get()); This is incorrect, the registration needs to happens when the -shutdown method is called. The correct solution with a ScopedObserver would be to delete the ScopedObserver at that point, but I think it does not bring enough value since this class need to explicitly control when registration/unregistration happen anyway. I would suggest reverting this file and leaving it to use manual AddObserver/RemoveObserver calls. BTW, this is because of this that all tests are failing. https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... File ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm (right): https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm:40: _scopedWebStateListObserver.reset(); You can use RemoveAll/Add to avoid destroying the observer and ScopedObserver everytime. - (instancetype)init { self = [super init]; if (self) { _webStateListObserver = base::MakeUnique<WebStateListObserverBridge>(self); _scopedWebStateListObserver = base::MakeUnique< ScopedObserver<WebStateList, WebStateListObserverBridge>>( _webStateListObserver.get()); } } - (void)setWebStateList:(WebStateList*)webStateList { _scopedWebStateListObserver->RemoveAll(); _webStateList = webStateList; if (!_webStateList) return; _scopedWebStateListObserver->Add(_webStateList); } https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... File ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm (right): https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm:50: _scopedWebStateListObserver.reset(); ditto, use RemoveAll/Add to avoid creating destroying the observer and ScopedObserver everytime https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm:51: _webStateListObserver.reset(); Why don't we call "[self disableWebUsage:self.webStateList->GetActiveWebState()];" here?
The CQ bit was checked by lpromero@chromium.org to run a CQ dry run
https://codereview.chromium.org/2820493002/diff/20001/ios/chrome/browser/web_... File ios/chrome/browser/web_state_list/web_state_list_fast_enumeration_helper.mm (left): https://codereview.chromium.org/2820493002/diff/20001/ios/chrome/browser/web_... ios/chrome/browser/web_state_list/web_state_list_fast_enumeration_helper.mm:59: _webStateList->RemoveObserver(_observerBridge.get()); On 2017/04/20 10:02:07, sdefresne wrote: > This is incorrect, the registration needs to happens when the -shutdown method > is called. The correct solution with a ScopedObserver would be to delete the > ScopedObserver at that point, but I think it does not bring enough value since > this class need to explicitly control when registration/unregistration happen > anyway. > > I would suggest reverting this file and leaving it to use manual > AddObserver/RemoveObserver calls. > > BTW, this is because of this that all tests are failing. Done. https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... File ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm (right): https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm:40: _scopedWebStateListObserver.reset(); On 2017/04/20 10:02:07, sdefresne wrote: > You can use RemoveAll/Add to avoid destroying the observer and ScopedObserver > everytime. > > - (instancetype)init { > self = [super init]; > if (self) { > _webStateListObserver = base::MakeUnique<WebStateListObserverBridge>(self); > _scopedWebStateListObserver = base::MakeUnique< > ScopedObserver<WebStateList, WebStateListObserverBridge>>( > _webStateListObserver.get()); > } > } > > - (void)setWebStateList:(WebStateList*)webStateList { > _scopedWebStateListObserver->RemoveAll(); > _webStateList = webStateList; > if (!_webStateList) > return; > _scopedWebStateListObserver->Add(_webStateList); > } Done, although could we imagine a time when RemoveAll removes too much? https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... File ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm (right): https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm:50: _scopedWebStateListObserver.reset(); On 2017/04/20 10:02:07, sdefresne wrote: > ditto, use RemoveAll/Add to avoid creating destroying the observer and > ScopedObserver everytime Done. https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm:51: _webStateListObserver.reset(); On 2017/04/20 10:02:07, sdefresne wrote: > Why don't we call "[self > disableWebUsage:self.webStateList->GetActiveWebState()];" here? No idea. I filed http://crbug.com/713757.
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.
PTAL. Thanks!
On 2017/04/20 16:25:14, lpromero wrote: > https://codereview.chromium.org/2820493002/diff/20001/ios/chrome/browser/web_... > File ios/chrome/browser/web_state_list/web_state_list_fast_enumeration_helper.mm > (left): > > https://codereview.chromium.org/2820493002/diff/20001/ios/chrome/browser/web_... > ios/chrome/browser/web_state_list/web_state_list_fast_enumeration_helper.mm:59: > _webStateList->RemoveObserver(_observerBridge.get()); > On 2017/04/20 10:02:07, sdefresne wrote: > > This is incorrect, the registration needs to happens when the -shutdown method > > is called. The correct solution with a ScopedObserver would be to delete the > > ScopedObserver at that point, but I think it does not bring enough value since > > this class need to explicitly control when registration/unregistration happen > > anyway. > > > > I would suggest reverting this file and leaving it to use manual > > AddObserver/RemoveObserver calls. > > > > BTW, this is because of this that all tests are failing. > > Done. > > https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... > File ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm > (right): > > https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... > ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm:40: > _scopedWebStateListObserver.reset(); > On 2017/04/20 10:02:07, sdefresne wrote: > > You can use RemoveAll/Add to avoid destroying the observer and ScopedObserver > > everytime. > > > > - (instancetype)init { > > self = [super init]; > > if (self) { > > _webStateListObserver = > base::MakeUnique<WebStateListObserverBridge>(self); > > _scopedWebStateListObserver = base::MakeUnique< > > ScopedObserver<WebStateList, WebStateListObserverBridge>>( > > _webStateListObserver.get()); > > } > > } > > > > - (void)setWebStateList:(WebStateList*)webStateList { > > _scopedWebStateListObserver->RemoveAll(); > > _webStateList = webStateList; > > if (!_webStateList) > > return; > > _scopedWebStateListObserver->Add(_webStateList); > > } > > Done, although could we imagine a time when RemoveAll removes too much? RemoveAll calls RemoveObserver for all observed Source. So I can't think of a time it would do too much work. It may do unnecessary work if you do the following: TabCollectionMediator* t = ...; t.webStateList = ...; // some non null WebStateList t.webStateList = t.webStateList; This can be fixed by adding a check at the beginning of -setWebStateList: - (void)setWebStateList:(WebStateList*)webStateList { if (_webStateList == webStateList) return; ... > https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... > File ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm (right): > > https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... > ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm:50: > _scopedWebStateListObserver.reset(); > On 2017/04/20 10:02:07, sdefresne wrote: > > ditto, use RemoveAll/Add to avoid creating destroying the observer and > > ScopedObserver everytime > > Done. > > https://codereview.chromium.org/2820493002/diff/20001/ios/clean/chrome/browse... > ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm:51: > _webStateListObserver.reset(); > On 2017/04/20 10:02:07, sdefresne wrote: > > Why don't we call "[self > > disableWebUsage:self.webStateList->GetActiveWebState()];" here? > > No idea. I filed http://crbug.com/713757.
lgtm
The CQ bit was checked by lpromero@chromium.org
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": 40001, "attempt_start_ts": 1492781751862980, "parent_rev": "a7629595cadb7b48331e9ae449d715693ac8e385", "commit_rev": "8041d6145bbd1f92ff8d5dea5264be9e59d8fc3e"}
Message was sent while issue was closed.
Description was changed from ========== Use a scoped WebStateListObserverBridge. BUG=none R=rohitrao@chromium.org CC=sdefresne@chromium.org ========== to ========== Use a scoped WebStateListObserverBridge. BUG=none R=rohitrao@chromium.org CC=sdefresne@chromium.org Review-Url: https://codereview.chromium.org/2820493002 Cr-Commit-Position: refs/heads/master@{#466321} Committed: https://chromium.googlesource.com/chromium/src/+/8041d6145bbd1f92ff8d5dea5264... ==========
Message was sent while issue was closed.
Committed patchset #3 (id:40001) as https://chromium.googlesource.com/chromium/src/+/8041d6145bbd1f92ff8d5dea5264... |