Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "services/ui/demo/mus_demo.h" | 5 #include "services/ui/demo/mus_demo.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "services/service_manager/public/cpp/connector.h" | 8 #include "services/service_manager/public/cpp/connector.h" |
| 9 #include "services/ui/demo/window_tree_data.h" | 9 #include "services/ui/demo/window_tree_data.h" |
| 10 #include "services/ui/public/cpp/gpu/gpu.h" | 10 #include "services/ui/public/cpp/gpu/gpu.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 | 24 |
| 25 MusDemo::~MusDemo() { | 25 MusDemo::~MusDemo() { |
| 26 display::Screen::SetScreenInstance(nullptr); | 26 display::Screen::SetScreenInstance(nullptr); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void MusDemo::AddPrimaryDisplay(const display::Display& display) { | 29 void MusDemo::AddPrimaryDisplay(const display::Display& display) { |
| 30 screen_->display_list().AddDisplay(display, | 30 screen_->display_list().AddDisplay(display, |
| 31 display::DisplayList::Type::PRIMARY); | 31 display::DisplayList::Type::PRIMARY); |
| 32 } | 32 } |
| 33 | 33 |
| 34 bool MusDemo::HasPendingWindowTreeData() const { | |
| 35 return !window_tree_data_list_.empty() && | |
| 36 !window_tree_data_list_.back()->IsInitialized(); | |
| 37 } | |
| 38 | |
| 39 void MusDemo::AppendWindowTreeData( | |
| 40 std::unique_ptr<WindowTreeData> window_tree_data) { | |
| 41 DCHECK(!HasPendingWindowTreeData()); | |
| 42 window_tree_data_list_.push_back(std::move(window_tree_data)); | |
| 43 } | |
| 44 | |
| 34 void MusDemo::InitWindowTreeData( | 45 void MusDemo::InitWindowTreeData( |
| 35 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { | 46 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { |
| 36 DCHECK(window_tree_data_); | 47 DCHECK(HasPendingWindowTreeData()); |
| 37 DCHECK(!window_tree_data_->IsInitialized()); | 48 window_tree_data_list_.back()->Init(std::move(window_tree_host)); |
| 38 window_tree_data_->Init(std::move(window_tree_host)); | |
| 39 } | 49 } |
| 40 | 50 |
| 41 void MusDemo::CleanupWindowTreeData() { | 51 void MusDemo::RemoveWindowTreeDataFor( |
| 42 window_tree_data_.reset(); | 52 aura::WindowTreeHostMus* window_tree_host) { |
| 53 DCHECK(window_tree_host); | |
| 54 auto it = | |
| 55 std::find_if(window_tree_data_list_.begin(), window_tree_data_list_.end(), | |
| 56 [window_tree_host](std::unique_ptr<WindowTreeData>& data) { | |
| 57 return data->WindowTreeHost() == window_tree_host; | |
| 58 }); | |
| 59 DCHECK(it != window_tree_data_list_.end()); | |
| 60 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.
| |
| 43 } | 61 } |
| 44 | 62 |
| 45 void MusDemo::OnStart() { | 63 void MusDemo::OnStart() { |
| 46 screen_ = base::MakeUnique<display::ScreenBase>(); | 64 screen_ = base::MakeUnique<display::ScreenBase>(); |
| 47 display::Screen::SetScreenInstance(screen_.get()); | 65 display::Screen::SetScreenInstance(screen_.get()); |
| 48 | 66 |
| 49 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); | 67 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); |
| 50 capture_client_ = base::MakeUnique<aura::client::DefaultCaptureClient>(); | 68 capture_client_ = base::MakeUnique<aura::client::DefaultCaptureClient>(); |
| 51 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); | 69 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); |
| 52 wm_state_ = base::MakeUnique<::wm::WMState>(); | 70 wm_state_ = base::MakeUnique<::wm::WMState>(); |
| 53 | 71 |
| 54 OnStartImpl(&window_tree_client_, &window_tree_data_); | 72 window_tree_client_ = CreateWindowTreeClient(); |
| 73 OnStartImpl(); | |
| 55 | 74 |
| 56 env_->SetWindowTreeClient(window_tree_client_.get()); | 75 env_->SetWindowTreeClient(window_tree_client_.get()); |
| 57 } | 76 } |
| 58 | 77 |
| 59 bool MusDemo::OnConnect(const service_manager::ServiceInfo& remote_info, | 78 bool MusDemo::OnConnect(const service_manager::ServiceInfo& remote_info, |
| 60 service_manager::InterfaceRegistry* registry) { | 79 service_manager::InterfaceRegistry* registry) { |
| 61 return true; | 80 return true; |
| 62 } | 81 } |
| 63 | 82 |
| 64 void MusDemo::OnEmbed( | 83 void MusDemo::OnEmbed( |
| 65 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { | 84 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { |
| 66 NOTREACHED(); | 85 NOTREACHED(); |
| 67 } | 86 } |
| 68 | 87 |
| 69 void MusDemo::OnUnembed(aura::Window* root) { | 88 void MusDemo::OnUnembed(aura::Window* root) { |
| 70 NOTREACHED(); | 89 NOTREACHED(); |
| 71 } | 90 } |
| 72 | 91 |
| 73 void MusDemo::OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) { | 92 void MusDemo::OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) { |
| 74 NOTREACHED(); | 93 NOTREACHED(); |
| 75 } | 94 } |
| 76 | 95 |
| 77 void MusDemo::OnLostConnection(aura::WindowTreeClient* client) { | 96 void MusDemo::OnLostConnection(aura::WindowTreeClient* client) { |
| 78 window_tree_client_.reset(); | 97 window_tree_client_.reset(); |
| 79 CleanupWindowTreeData(); | 98 window_tree_data_list_.clear(); |
| 80 } | 99 } |
| 81 | 100 |
| 82 void MusDemo::OnPointerEventObserved(const PointerEvent& event, | 101 void MusDemo::OnPointerEventObserved(const PointerEvent& event, |
| 83 aura::Window* target) {} | 102 aura::Window* target) {} |
| 84 | 103 |
| 85 aura::PropertyConverter* MusDemo::GetPropertyConverter() { | 104 aura::PropertyConverter* MusDemo::GetPropertyConverter() { |
| 86 return property_converter_.get(); | 105 return property_converter_.get(); |
| 87 } | 106 } |
| 88 | 107 |
| 89 } // namespace demo | 108 } // namespace demo |
| 90 } // namespace ui | 109 } // namespace ui |
| OLD | NEW |