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

Unified Diff: ui/aura/mus/window_port_mus.cc

Issue 2500973002: Converts test_wm to use aura (Closed)
Patch Set: feedback Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..7797d107e40479042958345d1e8870b8e61342b1 100644
--- a/ui/aura/mus/window_port_mus.cc
+++ b/ui/aura/mus/window_port_mus.cc
@@ -34,7 +34,13 @@ WindowPortMus::~WindowPortMus() {
if (surface_info_)
SetSurfaceIdFromServer(nullptr);
- window_tree_client_->OnWindowMusDestroyed(this);
+ // DESTROY is only scheduled from DestroyFromServer(), meaning if DESTROY is
+ // present then the server originated the change.
+ const WindowTreeClient::Origin origin =
+ RemoveChangeByTypeAndData(ServerChangeType::DESTROY, ServerChangeData())
+ ? WindowTreeClient::Origin::SERVER
+ : WindowTreeClient::Origin::CLIENT;
+ window_tree_client_->OnWindowMusDestroyed(this, origin);
}
// static
@@ -123,6 +129,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 +243,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();

Powered by Google App Engine
This is Rietveld 408576698