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..a87aa654d126e857900ecab0a25bebebee91c475 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 = |
|
msw
2016/11/17 21:26:15
nit: maybe comment here since this is slightly sub
sky
2016/11/17 22:25:54
I added a comment indicating why DESTROY means it
|
| + RemoveChangeByTypeAndData(ServerChangeType::DELETE, ServerChangeData()) |
| + ? 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::DELETE: |
| + // 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::DELETE, ServerChangeData()); |
| + delete window_; |
| +} |
| + |
| void WindowPortMus::AddTransientChildFromServer(WindowMus* child) { |
| ServerChangeData data; |
| data.child_id = child->server_id(); |