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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::RemoveWindowTreeData(aura::WindowTreeHostMus* window_tree_host) {
42 window_tree_data_.reset(); 52 DCHECK(window_tree_host);
53 auto it =
54 std::find_if(window_tree_data_list_.begin(), window_tree_data_list_.end(),
55 [window_tree_host](std::unique_ptr<WindowTreeData>& data) {
56 return data->WindowTreeHost() == window_tree_host;
57 });
58 DCHECK(it != window_tree_data_list_.end());
59 window_tree_data_list_.erase(it);
43 } 60 }
44 61
45 void MusDemo::OnStart() { 62 void MusDemo::OnStart() {
46 screen_ = base::MakeUnique<display::ScreenBase>(); 63 screen_ = base::MakeUnique<display::ScreenBase>();
47 display::Screen::SetScreenInstance(screen_.get()); 64 display::Screen::SetScreenInstance(screen_.get());
48 65
49 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); 66 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS);
50 capture_client_ = base::MakeUnique<aura::client::DefaultCaptureClient>(); 67 capture_client_ = base::MakeUnique<aura::client::DefaultCaptureClient>();
51 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); 68 property_converter_ = base::MakeUnique<aura::PropertyConverter>();
52 wm_state_ = base::MakeUnique<::wm::WMState>(); 69 wm_state_ = base::MakeUnique<::wm::WMState>();
53 70
54 OnStartImpl(&window_tree_client_, &window_tree_data_); 71 window_tree_client_ = CreateWindowTreeClient();
72 OnStartImpl();
55 73
56 env_->SetWindowTreeClient(window_tree_client_.get()); 74 env_->SetWindowTreeClient(window_tree_client_.get());
57 } 75 }
58 76
59 bool MusDemo::OnConnect(const service_manager::ServiceInfo& remote_info, 77 bool MusDemo::OnConnect(const service_manager::ServiceInfo& remote_info,
60 service_manager::InterfaceRegistry* registry) { 78 service_manager::InterfaceRegistry* registry) {
61 return true; 79 return true;
62 } 80 }
63 81
64 void MusDemo::OnEmbed( 82 void MusDemo::OnEmbed(
65 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { 83 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
66 NOTREACHED(); 84 NOTREACHED();
67 } 85 }
68 86
69 void MusDemo::OnUnembed(aura::Window* root) { 87 void MusDemo::OnUnembed(aura::Window* root) {
70 NOTREACHED(); 88 NOTREACHED();
71 } 89 }
72 90
73 void MusDemo::OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) { 91 void MusDemo::OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) {
74 NOTREACHED(); 92 NOTREACHED();
75 } 93 }
76 94
77 void MusDemo::OnLostConnection(aura::WindowTreeClient* client) { 95 void MusDemo::OnLostConnection(aura::WindowTreeClient* client) {
78 window_tree_client_.reset(); 96 window_tree_client_.reset();
79 CleanupWindowTreeData(); 97 window_tree_data_list_.clear();
80 } 98 }
81 99
82 void MusDemo::OnPointerEventObserved(const PointerEvent& event, 100 void MusDemo::OnPointerEventObserved(const PointerEvent& event,
83 aura::Window* target) {} 101 aura::Window* target) {}
84 102
85 aura::PropertyConverter* MusDemo::GetPropertyConverter() { 103 aura::PropertyConverter* MusDemo::GetPropertyConverter() {
86 return property_converter_.get(); 104 return property_converter_.get();
87 } 105 }
88 106
89 } // namespace demo 107 } // namespace demo
90 } // namespace ui 108 } // namespace ui
OLDNEW
« 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