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

Unified Diff: services/ui/demo/mus_demo.cc

Issue 2700493005: Mus Demo: Refactor code to prepare multiple windows in external mode (Closed)
Patch Set: Rename MusExternal::tree_client_ & describes the helper functions for WindowTreeData. Created 3 years, 10 months 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
« no previous file with comments | « services/ui/demo/mus_demo.h ('k') | services/ui/demo/mus_demo_external.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/demo/mus_demo.cc
diff --git a/services/ui/demo/mus_demo.cc b/services/ui/demo/mus_demo.cc
index 565c058eaf22f84d4d6a6c435575bb12c0f76b91..7afba5693af4cae100e7e13c0f09af916494b989 100644
--- a/services/ui/demo/mus_demo.cc
+++ b/services/ui/demo/mus_demo.cc
@@ -31,15 +31,32 @@ void MusDemo::AddPrimaryDisplay(const display::Display& display) {
display::DisplayList::Type::PRIMARY);
}
+bool MusDemo::HasPendingWindowTreeData() const {
+ return !window_tree_data_list_.empty() &&
+ !window_tree_data_list_.back()->IsInitialized();
+}
+
+void MusDemo::AppendWindowTreeData(
+ std::unique_ptr<WindowTreeData> window_tree_data) {
+ DCHECK(!HasPendingWindowTreeData());
+ window_tree_data_list_.push_back(std::move(window_tree_data));
+}
+
void MusDemo::InitWindowTreeData(
std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
- DCHECK(window_tree_data_);
- DCHECK(!window_tree_data_->IsInitialized());
- window_tree_data_->Init(std::move(window_tree_host));
+ DCHECK(HasPendingWindowTreeData());
+ window_tree_data_list_.back()->Init(std::move(window_tree_host));
}
-void MusDemo::CleanupWindowTreeData() {
- window_tree_data_.reset();
+void MusDemo::RemoveWindowTreeData(aura::WindowTreeHostMus* window_tree_host) {
+ DCHECK(window_tree_host);
+ auto it =
+ std::find_if(window_tree_data_list_.begin(), window_tree_data_list_.end(),
+ [window_tree_host](std::unique_ptr<WindowTreeData>& data) {
+ return data->WindowTreeHost() == window_tree_host;
+ });
+ DCHECK(it != window_tree_data_list_.end());
+ window_tree_data_list_.erase(it);
}
void MusDemo::OnStart() {
@@ -51,7 +68,8 @@ void MusDemo::OnStart() {
property_converter_ = base::MakeUnique<aura::PropertyConverter>();
wm_state_ = base::MakeUnique<::wm::WMState>();
- OnStartImpl(&window_tree_client_, &window_tree_data_);
+ window_tree_client_ = CreateWindowTreeClient();
+ OnStartImpl();
env_->SetWindowTreeClient(window_tree_client_.get());
}
@@ -76,7 +94,7 @@ void MusDemo::OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) {
void MusDemo::OnLostConnection(aura::WindowTreeClient* client) {
window_tree_client_.reset();
- CleanupWindowTreeData();
+ window_tree_data_list_.clear();
}
void MusDemo::OnPointerEventObserved(const PointerEvent& event,
« no previous file with comments | « services/ui/demo/mus_demo.h ('k') | services/ui/demo/mus_demo_external.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698