Chromium Code Reviews| 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..5404c74cde7a0bbfd66c8e0feb6beb1315444921 100644 |
| --- a/services/ui/demo/mus_demo.cc |
| +++ b/services/ui/demo/mus_demo.cc |
| @@ -31,15 +31,33 @@ 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::RemoveWindowTreeDataFor( |
| + 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, it + 1); |
|
kylechar
2017/02/23 22:45:30
You can just do: erase(it).
fwang
2017/02/24 10:08:50
Acknowledged.
fwang
2017/02/24 10:40:10
Done.
|
| } |
| void MusDemo::OnStart() { |
| @@ -51,7 +69,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 +95,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, |