Chromium Code Reviews| Index: ui/aura/mus/window_port_mus.cc |
| diff --git a/ui/aura/mus/window_port_mus.cc b/ui/aura/mus/window_port_mus.cc |
| index f9be96b4993e306a1c3279e09516fa76bafe0070..f5c51db77e02ff8209e645795dfa303113a37f80 100644 |
| --- a/ui/aura/mus/window_port_mus.cc |
| +++ b/ui/aura/mus/window_port_mus.cc |
| @@ -34,7 +34,11 @@ WindowPortMus::~WindowPortMus() { |
| if (surface_info_) |
| SetSurfaceIdFromServer(nullptr); |
| - window_tree_client_->OnWindowMusDestroyed(this); |
| + const WindowTreeClient::Origin origin = |
| + RemoveChangeByTypeAndData(ServerChangeType::DESTROY, ServerChangeData()) |
|
msw
2016/11/17 21:26:15
aside: too bad we have two change type enums with
|
| + ? WindowTreeClient::Origin::SERVER |
| + : WindowTreeClient::Origin::CLIENT; |
| + window_tree_client_->OnWindowMusDestroyed(this, origin); |
| } |
| // static |
| @@ -123,6 +127,9 @@ bool WindowPortMus::RemoveChangeByTypeAndData(const ServerChangeType type, |
| if (iter->data.bounds == data.bounds) |
| break; |
| continue; |
| + case ServerChangeType::DESTROY: |
| + // No extra data for delete. |
| + break; |
| case ServerChangeType::PROPERTY: |
| if (iter->data.property_name == data.property_name) |
| break; |
| @@ -234,6 +241,22 @@ void WindowPortMus::SetSurfaceIdFromServer( |
| surface_info_ = std::move(surface_info); |
| } |
| +void WindowPortMus::DestroyFromServer() { |
| + std::unique_ptr<ScopedServerChange> remove_from_parent_change; |
| + if (window_->parent()) { |
| + ServerChangeData data; |
| + data.child_id = server_id(); |
| + WindowPortMus* parent = Get(window_->parent()); |
| + remove_from_parent_change = base::MakeUnique<ScopedServerChange>( |
| + parent, ServerChangeType::REMOVE, data); |
| + } |
| + // NOTE: this can't use ScopedServerChange as |this| is destroyed before the |
| + // function returns (ScopedServerChange would attempt to access |this| after |
| + // destruction). |
| + ScheduleChange(ServerChangeType::DESTROY, ServerChangeData()); |
| + delete window_; |
| +} |
| + |
| void WindowPortMus::AddTransientChildFromServer(WindowMus* child) { |
| ServerChangeData data; |
| data.child_id = child->server_id(); |