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

Issue 2921833002: [iOS Clean] Created OverlayService.

Created:
3 years, 6 months ago by kkhorimoto
Modified:
3 years, 5 months ago
CC:
chromium-reviews, marq+scrutinize_chromium.org, ios-reviews+clean_chromium.org, ios-reviews_chromium.org, sczs
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

[iOS Clean] Created OverlayService. This CL introduces OverlayService, a BrowerStateKeyedService that manages enqueueing overlay coordinators and scheduling the overlays to be displayed. Classes of note: - OverlayService: Interface to the overlay system. - OverlayServiceFactory: Factory interface that generates OverlayServices. - OverlayQueue: FIFO queue of overlays that have been added to the service. - BrowserOverlayQueue: OverlayQueue for overlays that need to be displayed over a particular Browser. - WebStateOverlayQueue: OverlayQueue for overlays that need to be displayed over a particular WebState's content area. - OverlayScheduler: Manages creating OverlayQueues and scheduling when their queued overlays can be displayed. Also switches foreground tabs to display a WebState's content for WebStateOverlayQueues. BUG=none

Patch Set 1 #

Patch Set 2 : self review #

Total comments: 12

Patch Set 3 : WebOverlays => Overlays #

Patch Set 4 : rebase, add ReplaceVisibleOverlay() #

Patch Set 5 : rebase + gn deps fix #

Patch Set 6 : Cancel overlays on queue deallocation #

Total comments: 26

Patch Set 7 : Observer pattern, generalized overlay queue #

Patch Set 8 : Use service pattern #

Total comments: 32

Patch Set 9 : rebase & Mark's comments #

Total comments: 5
Unified diffs Side-by-side diffs Delta from patch set Stats (+1323 lines, -23 lines) Patch
A ios/clean/chrome/browser/ui/overlay_service/BUILD.gn View 1 2 3 4 5 6 7 8 1 chunk +36 lines, -0 lines 1 comment Download
A ios/clean/chrome/browser/ui/overlay_service/DEPS View 1 2 3 4 5 6 7 8 1 chunk +4 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/browser_coordinator+overlay_support.h View 1 2 3 4 5 6 7 8 1 chunk +50 lines, -0 lines 2 comments Download
A + ios/clean/chrome/browser/ui/overlay_service/internal/BUILD.gn View 1 2 3 4 5 6 7 8 1 chunk +24 lines, -23 lines 1 comment Download
A ios/clean/chrome/browser/ui/overlay_service/internal/browser_coordinator+overlay_support.mm View 1 2 3 4 5 6 7 8 1 chunk +45 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/internal/browser_overlay_queue.h View 1 2 3 4 5 6 7 8 1 chunk +41 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/internal/browser_overlay_queue.mm View 1 2 3 4 5 6 7 8 1 chunk +52 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/internal/overlay_queue.h View 1 2 3 4 5 6 7 8 1 chunk +74 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/internal/overlay_queue.mm View 1 2 3 4 5 6 7 8 1 chunk +105 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/internal/overlay_queue_observer.h View 1 2 3 4 5 6 7 8 1 chunk +34 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/internal/overlay_queue_unittest.mm View 1 2 3 4 5 6 7 8 1 chunk +169 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/internal/overlay_scheduler.h View 1 2 3 4 5 6 7 8 1 chunk +88 lines, -0 lines 1 comment Download
A ios/clean/chrome/browser/ui/overlay_service/internal/overlay_scheduler.mm View 1 2 3 4 5 6 7 8 1 chunk +180 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/internal/overlay_service_factory.mm View 1 2 3 4 5 6 7 8 1 chunk +50 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/internal/overlay_service_impl.h View 1 2 3 4 5 6 7 8 1 chunk +53 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/internal/overlay_service_impl.mm View 1 2 3 4 5 6 7 8 1 chunk +102 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/internal/web_state_overlay_queue.h View 1 2 3 4 5 6 7 8 1 chunk +42 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/internal/web_state_overlay_queue.mm View 1 2 3 4 5 6 7 8 1 chunk +41 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/overlay_service.h View 1 2 3 4 5 6 7 8 1 chunk +74 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/overlay_service/overlay_service_factory.h View 1 2 3 4 5 6 7 8 1 chunk +44 lines, -0 lines 0 comments Download
M ios/clean/chrome/browser/ui/web_contents/BUILD.gn View 1 2 3 4 5 6 7 8 1 chunk +1 line, -0 lines 0 comments Download
M ios/clean/chrome/browser/ui/web_contents/web_coordinator.mm View 1 2 3 4 5 6 7 8 3 chunks +13 lines, -0 lines 0 comments Download
M ios/clean/chrome/test/BUILD.gn View 1 2 3 4 5 6 7 8 1 chunk +1 line, -0 lines 0 comments Download

Depends on Patchset:

Dependent Patchsets:

Messages

Total messages: 19 (4 generated)
kkhorimoto
This is the implementation of the overlay queue and scheduler described in go/chrome-ios-new-arch-dialogs
3 years, 6 months ago (2017-06-02 02:15:19 UTC) #2
kkhorimoto
self review
3 years, 6 months ago (2017-06-02 02:23:06 UTC) #3
marq (ping after 24h)
Here are some initial comments, but I need to think through the design some more. ...
3 years, 6 months ago (2017-06-02 16:14:11 UTC) #4
kkhorimoto
https://codereview.chromium.org/2921833002/diff/20001/ios/clean/chrome/browser/ui/commands/web_overlay_commands.h File ios/clean/chrome/browser/ui/commands/web_overlay_commands.h (right): https://codereview.chromium.org/2921833002/diff/20001/ios/clean/chrome/browser/ui/commands/web_overlay_commands.h#newcode14 ios/clean/chrome/browser/ui/commands/web_overlay_commands.h:14: @class WebOverlayCoordinator; On 2017/06/02 16:14:11, marq (ping after 24h) ...
3 years, 6 months ago (2017-06-03 00:37:33 UTC) #5
kkhorimoto
PTAL!
3 years, 6 months ago (2017-06-07 08:02:11 UTC) #7
kkhorimoto
rebase + gn deps fix
3 years, 6 months ago (2017-06-07 18:43:11 UTC) #8
kkhorimoto
Cancel overlays on queue deallocation
3 years, 6 months ago (2017-06-09 21:02:15 UTC) #10
marq (ping after 24h)
Kurt, I'm way overdue on the the review for this and the subsequent CLs. I'll ...
3 years, 6 months ago (2017-06-12 17:36:32 UTC) #11
marq (ping after 24h)
Overall this is moving in the right direction; nice work. Moving url_protection_space should probably have ...
3 years, 6 months ago (2017-06-14 10:02:33 UTC) #12
kkhorimoto
I've updated the approach here so that A) OverlayScheduler uses OverlayQueueObservation to update the schedule, ...
3 years, 6 months ago (2017-06-15 08:26:29 UTC) #13
kkhorimoto
3 years, 6 months ago (2017-06-15 08:26:46 UTC) #14
marq (ping after 24h)
https://codereview.chromium.org/2921833002/diff/140001/ios/clean/chrome/browser/ui/overlays/browser_coordinator+overlay_support.h File ios/clean/chrome/browser/ui/overlays/browser_coordinator+overlay_support.h (right): https://codereview.chromium.org/2921833002/diff/140001/ios/clean/chrome/browser/ui/overlays/browser_coordinator+overlay_support.h#newcode31 ios/clean/chrome/browser/ui/overlays/browser_coordinator+overlay_support.h:31: // Called when the overay is stopped so that ...
3 years, 6 months ago (2017-06-21 09:41:54 UTC) #15
kkhorimoto
rebase & Mark's comments
3 years, 6 months ago (2017-06-23 06:10:35 UTC) #16
kkhorimoto
https://codereview.chromium.org/2921833002/diff/140001/ios/clean/chrome/browser/ui/overlays/browser_coordinator+overlay_support.h File ios/clean/chrome/browser/ui/overlays/browser_coordinator+overlay_support.h (right): https://codereview.chromium.org/2921833002/diff/140001/ios/clean/chrome/browser/ui/overlays/browser_coordinator+overlay_support.h#newcode23 ios/clean/chrome/browser/ui/overlays/browser_coordinator+overlay_support.h:23: @property(nonatomic, readonly) BOOL supportsOverlaying; Not sure if this is ...
3 years, 6 months ago (2017-06-23 06:11:17 UTC) #17
marq (ping after 24h)
3 years, 6 months ago (2017-06-23 10:42:01 UTC) #19
I think we're getting closer.

Generally I think it's better to start with a smaller system that might have
some awkward interactions, and then refine those in future CLs; the overlay
service seems like a preemptive optimization.

https://codereview.chromium.org/2921833002/diff/140001/ios/clean/chrome/brows...
File ios/clean/chrome/browser/ui/overlays/overlay_scheduler.mm (right):

https://codereview.chromium.org/2921833002/diff/140001/ios/clean/chrome/brows...
ios/clean/chrome/browser/ui/overlays/overlay_scheduler.mm:140: WebStateList&
web_state_list = browser_->web_state_list();
On 2017/06/23 06:11:16, kkhorimoto_ wrote:
> On 2017/06/21 09:41:54, marq (ping after 24h) wrote:
> > Rather than passing the whole browser into the scheduler, I'd prefer to
> > individually assign the WSL and the dispatcher (which will move out of the
> > browser soon).
> 
> This object is a BrowserUserData, so I don't think there's a lot of harm in
> referencing the Browser object it's attached to.  That being said, I can
update
> this to only store the WSL & dispatcher if you feel strongly about it. 

Dispatcher is moving out of browser once I have time to land that change, and
while it makes sense for this class to be BrowserData (that is, owned by a
Browser), I don't think that necessarily means that it internally should depend
on the browser. I'd also like to generally keep dependencies as specific as
possible, and restrict how much "service container" classes (like BrowserState
and Browser) are passed around, instead of passing around the specific services
from them.

As a further litmus test, I wouldn't want this class to pass a Browser instance
to anything else.

https://codereview.chromium.org/2921833002/diff/140001/ios/clean/chrome/brows...
ios/clean/chrome/browser/ui/overlays/overlay_scheduler.mm:143:
web_state_list.ActivateWebStateAt(new_active_index);
On 2017/06/23 06:11:16, kkhorimoto_ wrote:
> On 2017/06/21 09:41:53, marq (ping after 24h) wrote:
> > We should arrive at some consensus about how activating webstates (in the
> model
> > layer) interacts with displaying tabs. Some options:
> > 
> > - Activating a tab in the WSL is expected to be observed by (for example)
the
> > tab grid mediator, which will take care of changing the active tab.
> > 
> > - Activating a tab in the WSL is *never* expected to directly trigger
> > coordinator-layer changes, and must be followed with something like a
> > -showActiveTab command.
> > 
> > - Showing a tab at a particular index via a command is expected to change
the
> > active tab in the WSL.
> > 
> > We should also consider synchrony issues in this, since changing the active
> tab
> > may require animation.
> 
> As I mentioned in the meeting this morning, I think that updating the model
> layer first is the way to go.  I'm split on whether the UI should update
through
> observers or if it should be triggered manually via commands.  I'm tempted to
> say that it should happen automatically through observers, as that would allow
> for the loosest coupling between this model-layer BrowserUserData code and the
> UI consumer layer.  That being said, it might be useful to manually dispatch
the
> commands, for example if we wanted to change multiple model objects at once
and
> then dispatch a command that performs an animation based on the batch changes.

> I think adding a |-broadcastVisibleWebState:| should be enough for
> synchronization, regardless of whether it occurs automatically or via
commands.

OK. I think I would like to start with pure model-driven propagation and then
see where the pain points are. So start with having this method just
ActivateWebStateAt().

(we might consider adding a WebStateList::ActivateWebState() convenience method
that wraps the GetIndexOf/ActivateWebStateAt sequence).

https://codereview.chromium.org/2921833002/diff/140001/ios/clean/chrome/brows...
File ios/clean/chrome/browser/ui/overlays/overlay_service.h (right):

https://codereview.chromium.org/2921833002/diff/140001/ios/clean/chrome/brows...
ios/clean/chrome/browser/ui/overlays/overlay_service.h:18: // OverlayService
allows for the easy presentation and dismissal of overlay
On 2017/06/23 06:11:16, kkhorimoto_ wrote:
> On 2017/06/21 09:41:54, marq (ping after 24h) wrote:
> > The division of responsibilities between the OverlayService and the
> > OverlayScheduler isn't clear to me. 
> 
> The main entry point to this overlay system is adding overlays to an
> OverlayQueue.  I thought that it wasn't as clear, so defining a single service
> interface helps expose a more understandable API for overlaying.  Also, since
> this exists at a ChromeBrowserState-level, it can handle adding/removing
> observers for browsers, and is easily accessible from any BrowserCoordinator. 
> I've moved the implementation files into an internal/ directory to make it
> clearer that clients of this system should include the service-level target.

I don't agree that adding this service makes the necessary interactions clearer.
For example, I think it's fine for the web container coordinator to grab the
webstate overlay queue directly.

Also, remember that we don't want to assume a 1:1 correspondence between
BrowserState and browsers -- in the future we may have multiple browsers for the
same BrowserState.

I also don't like that we need to add six files (factory, service, service_impl,
.h and .mm) to do this.

https://codereview.chromium.org/2921833002/diff/160001/ios/clean/chrome/brows...
File ios/clean/chrome/browser/ui/overlay_service/BUILD.gn (right):

https://codereview.chromium.org/2921833002/diff/160001/ios/clean/chrome/brows...
ios/clean/chrome/browser/ui/overlay_service/BUILD.gn:5:
source_set("overlay_service") {
Nit: I preferred just calling this directory 'overlays', since we already have
'commands', 'animators', etc.

https://codereview.chromium.org/2921833002/diff/160001/ios/clean/chrome/brows...
File
ios/clean/chrome/browser/ui/overlay_service/browser_coordinator+overlay_support.h
(right):

https://codereview.chromium.org/2921833002/diff/160001/ios/clean/chrome/brows...
ios/clean/chrome/browser/ui/overlay_service/browser_coordinator+overlay_support.h:25:
// - call |-overlayWasStopped| from its |-stop| so that the OverlayService can
It seems like these things could be guaranteed in either BrowserCoordinator
itself or in an OverlayCoordinator subclass. There's been enough changes in this
design that I've lost track of what the arguments against a subclass were.

https://codereview.chromium.org/2921833002/diff/160001/ios/clean/chrome/brows...
ios/clean/chrome/browser/ui/overlay_service/browser_coordinator+overlay_support.h:40:
- (void)overlayWasStopped;
yeah, I'd rather have an OverlayCoordinator class whose -stop handles notifying
the service and (separately) unparenting.

https://codereview.chromium.org/2921833002/diff/160001/ios/clean/chrome/brows...
File ios/clean/chrome/browser/ui/overlay_service/internal/BUILD.gn (right):

https://codereview.chromium.org/2921833002/diff/160001/ios/clean/chrome/brows...
ios/clean/chrome/browser/ui/overlay_service/internal/BUILD.gn:5:
source_set("internal") {
I'm not sure that the internal/ subdirectory is useful here, unless we start
enforcing dependencies. But overall I don't think we're at the point where we're
defining hard API boundaries like this yet.

(And wouldn't overlay_queue.h also need to be a public header?)

https://codereview.chromium.org/2921833002/diff/160001/ios/clean/chrome/brows...
File ios/clean/chrome/browser/ui/overlay_service/internal/overlay_scheduler.h
(right):

https://codereview.chromium.org/2921833002/diff/160001/ios/clean/chrome/brows...
ios/clean/chrome/browser/ui/overlay_service/internal/overlay_scheduler.h:26:
class OverlayScheduler : public BrowserUserData<OverlayScheduler>,
Unit tests for this class?

Powered by Google App Engine
This is Rietveld 408576698