| Index: services/ui/view_manager/view_registry.h
|
| diff --git a/services/ui/view_manager/view_registry.h b/services/ui/view_manager/view_registry.h
|
| index e4585d642f1398b4ce84546fbd9ca23e3096d36e..c0562093b4cda5a11c15539da5b31406a0dbbc8d 100644
|
| --- a/services/ui/view_manager/view_registry.h
|
| +++ b/services/ui/view_manager/view_registry.h
|
| @@ -6,40 +6,58 @@
|
| #define SERVICES_UI_VIEW_MANAGER_VIEW_REGISTRY_H_
|
|
|
| #include <unordered_map>
|
| -#include <vector>
|
|
|
| #include "base/macros.h"
|
| +#include "mojo/services/gfx/composition/interfaces/compositor.mojom.h"
|
| +#include "mojo/services/ui/views/interfaces/view_associates.mojom.h"
|
| #include "mojo/services/ui/views/interfaces/view_trees.mojom.h"
|
| #include "mojo/services/ui/views/interfaces/views.mojom.h"
|
| +#include "services/ui/view_manager/view_associate_table.h"
|
| #include "services/ui/view_manager/view_layout_request.h"
|
| #include "services/ui/view_manager/view_state.h"
|
| #include "services/ui/view_manager/view_tree_state.h"
|
|
|
| namespace view_manager {
|
|
|
| -class SurfaceManager;
|
| -
|
| // Maintains a registry of the state of all views.
|
| // All ViewState objects are owned by the registry.
|
| -class ViewRegistry {
|
| +class ViewRegistry : public mojo::ui::ViewInspector {
|
| public:
|
| - explicit ViewRegistry(SurfaceManager* surface_manager);
|
| - ~ViewRegistry();
|
| + using AssociateConnectionErrorCallback =
|
| + ViewAssociateTable::AssociateConnectionErrorCallback;
|
| +
|
| + explicit ViewRegistry(mojo::gfx::composition::CompositorPtr compositor);
|
| + ~ViewRegistry() override;
|
| +
|
| + // Begins connecting to the view associates.
|
| + // Invokes |connection_error_callback| if an associate connection fails
|
| + // and provides the associate's url.
|
| + void ConnectAssociates(
|
| + mojo::ApplicationImpl* app_impl,
|
| + const std::vector<std::string>& urls,
|
| + const AssociateConnectionErrorCallback& connection_error_callback);
|
|
|
| // VIEW MANAGER REQUESTS
|
|
|
| // Registers a view and returns its ViewToken.
|
| mojo::ui::ViewTokenPtr RegisterView(
|
| mojo::ui::ViewPtr view,
|
| - mojo::InterfaceRequest<mojo::ui::ViewHost> view_host_request);
|
| + mojo::InterfaceRequest<mojo::ui::ViewHost> view_host_request,
|
| + const mojo::String& label);
|
|
|
| // Registers a view tree.
|
| - void RegisterViewTree(
|
| + mojo::ui::ViewTreeTokenPtr RegisterViewTree(
|
| mojo::ui::ViewTreePtr view_tree,
|
| - mojo::InterfaceRequest<mojo::ui::ViewTreeHost> view_tree_host_request);
|
| + mojo::InterfaceRequest<mojo::ui::ViewTreeHost> view_tree_host_request,
|
| + const mojo::String& label);
|
|
|
| // VIEW HOST REQUESTS
|
|
|
| + // Creates a scene for the view, replacing its current scene.
|
| + // Destroys |view_state| if an error occurs.
|
| + void CreateScene(ViewState* view_state,
|
| + mojo::InterfaceRequest<mojo::gfx::composition::Scene> scene);
|
| +
|
| // Requests layout.
|
| // Destroys |view_state| if an error occurs.
|
| void RequestLayout(ViewState* view_state);
|
| @@ -61,6 +79,12 @@ class ViewRegistry {
|
| mojo::ui::ViewLayoutParamsPtr child_layout_params,
|
| const ViewLayoutCallback& callback);
|
|
|
| + // Connects to a view service.
|
| + // Destroys |view_state| if an error occurs.
|
| + void ConnectToViewService(ViewState* view_state,
|
| + const mojo::String& service_name,
|
| + mojo::ScopedMessagePipeHandle client_handle);
|
| +
|
| // VIEW TREE HOST REQUESTS
|
|
|
| // Requests layout.
|
| @@ -83,6 +107,12 @@ class ViewRegistry {
|
| mojo::ui::ViewLayoutParamsPtr root_layout_params,
|
| const ViewLayoutCallback& callback);
|
|
|
| + // Connects to a view service.
|
| + // Destroys |view_state| if an error occurs.
|
| + void ConnectToViewTreeService(ViewTreeState* tree_state,
|
| + const mojo::String& service_name,
|
| + mojo::ScopedMessagePipeHandle client_handle);
|
| +
|
| private:
|
| // LIFETIME
|
|
|
| @@ -93,7 +123,7 @@ class ViewRegistry {
|
|
|
| // TREE MANIPULATION
|
|
|
| - ViewState* FindView(uint32_t view_token);
|
| + ViewState* FindView(uint32_t view_token_value);
|
| void LinkChild(ViewState* parent_state,
|
| uint32_t child_key,
|
| ViewState* child_state);
|
| @@ -101,6 +131,8 @@ class ViewRegistry {
|
| void MarkChildAsUnavailable(ViewState* parent_state, uint32_t child_key);
|
| void UnlinkChild(ViewState* parent_state,
|
| ViewState::ChildrenMap::iterator child_it);
|
| +
|
| + ViewTreeState* FindViewTree(uint32_t view_tree_token_value);
|
| void LinkRoot(ViewTreeState* tree_state,
|
| ViewState* root_state,
|
| uint32_t root_key);
|
| @@ -124,6 +156,11 @@ class ViewRegistry {
|
| void IssueNextViewLayoutRequest(ViewState* view_state);
|
| void IssueNextViewTreeLayoutRequest(ViewTreeState* tree_state);
|
|
|
| + // SCENE MANAGEMENT
|
| +
|
| + void OnSceneCreated(base::WeakPtr<ViewState> view_state_weak,
|
| + mojo::gfx::composition::SceneTokenPtr scene_token);
|
| +
|
| // SIGNALING
|
|
|
| void SendChildUnavailable(ViewState* parent_state, uint32_t child_key);
|
| @@ -131,25 +168,24 @@ class ViewRegistry {
|
| void SendViewLayoutRequest(ViewState* view_state);
|
| void SendViewTreeLayoutRequest(ViewTreeState* tree_state);
|
| void OnViewLayoutResult(base::WeakPtr<ViewState> view_state_weak,
|
| - mojo::ui::ViewLayoutInfoPtr info);
|
| + mojo::ui::ViewLayoutResultPtr result);
|
| void OnViewTreeLayoutResult(base::WeakPtr<ViewTreeState> tree_state_weak);
|
|
|
| bool IsViewStateRegisteredDebug(ViewState* view_state) {
|
| - return view_state && FindView(view_state->view_token_value());
|
| + return view_state && FindView(view_state->view_token()->value);
|
| }
|
|
|
| bool IsViewTreeStateRegisteredDebug(ViewTreeState* tree_state) {
|
| - return tree_state && std::any_of(view_trees_.begin(), view_trees_.end(),
|
| - [tree_state](ViewTreeState* other) {
|
| - return tree_state == other;
|
| - });
|
| + return tree_state && FindViewTree(tree_state->view_tree_token()->value);
|
| }
|
|
|
| - SurfaceManager* surface_manager_;
|
| + mojo::gfx::composition::CompositorPtr compositor_;
|
| + ViewAssociateTable associate_table_;
|
|
|
| - uint32_t next_view_token_value_;
|
| + uint32_t next_view_token_value_ = 1u;
|
| + uint32_t next_view_tree_token_value_ = 1u;
|
| std::unordered_map<uint32_t, ViewState*> views_by_token_;
|
| - std::vector<ViewTreeState*> view_trees_;
|
| + std::unordered_map<uint32_t, ViewTreeState*> view_trees_by_token_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ViewRegistry);
|
| };
|
|
|