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 #ifndef SERVICES_UI_DEMO_MUS_DEMO_H_ | 5 #ifndef SERVICES_UI_DEMO_MUS_DEMO_H_ |
6 #define SERVICES_UI_DEMO_MUS_DEMO_H_ | 6 #define SERVICES_UI_DEMO_MUS_DEMO_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 class MusDemo : public service_manager::Service, | 39 class MusDemo : public service_manager::Service, |
40 public aura::WindowTreeClientDelegate { | 40 public aura::WindowTreeClientDelegate { |
41 public: | 41 public: |
42 MusDemo(); | 42 MusDemo(); |
43 ~MusDemo() override; | 43 ~MusDemo() override; |
44 | 44 |
45 protected: | 45 protected: |
46 void AddPrimaryDisplay(const display::Display& display); | 46 void AddPrimaryDisplay(const display::Display& display); |
47 | 47 |
48 // These functions help to manage the list of WindowTreeData structures. | 48 // These functions help to manage the list of WindowTreeData structures. |
49 // AppendWindowTreeData is used to add an uninitialized structure at the end | 49 // AppendWindowTreeData is used to add (uninitialized in case of external |
50 // of the list. When a new WindowTreeHostMus is created and is sent to | 50 // windows) WindowTreeData structures at the end of the list. When a new |
51 // MusDemo (via OnWmNewDisplay or OnEmbed), the WindowTreeData is initialized | 51 // WindowTreeHostMus is created and is sent to MusDemo via OnWmNewDisplay, the |
52 // by a call to InitWindowTreeData and the demo starts. When the destruction | 52 // WindowTreeData is initialized by a call to WindowTreeData::Init and the |
53 // of the WindowTreeHostMus is announced to MusDemo (via OnWmDisplayRemoved | 53 // demo starts. In case if OnEmbedRootReady is called, corresponding |
54 // or OnEmbedRootDestroyed), the corresponding WindowTreeData is removed by | 54 // WindowTreeData is found by looking associated WindowTreeHostMus with it and |
55 // a call to RemoveWindowTreeData. | 55 // then WindowTreeData::Init is called. When the destruction of the |
| 56 // WindowTreeHostMus is announced to MusDemo (via OnWmDisplayRemoved or |
| 57 // OnEmbedRootDestroyed), the corresponding WindowTreeData is removed by a |
| 58 // call to RemoveWindowTreeData. |
56 void AppendWindowTreeData(std::unique_ptr<WindowTreeData> window_tree_data); | 59 void AppendWindowTreeData(std::unique_ptr<WindowTreeData> window_tree_data); |
57 void InitWindowTreeData( | |
58 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host); | |
59 void RemoveWindowTreeData(aura::WindowTreeHostMus* window_tree_host); | 60 void RemoveWindowTreeData(aura::WindowTreeHostMus* window_tree_host); |
| 61 std::vector<std::unique_ptr<WindowTreeData>>::iterator FindWindowTreeData( |
| 62 aura::WindowTreeHostMus* window_tree_host); |
60 | 63 |
61 aura::WindowTreeClient* window_tree_client() { | 64 aura::WindowTreeClient* window_tree_client() { |
62 return window_tree_client_.get(); | 65 return window_tree_client_.get(); |
63 } | 66 } |
64 | 67 |
65 private: | 68 private: |
66 virtual void OnStartImpl() = 0; | 69 virtual void OnStartImpl() = 0; |
67 virtual std::unique_ptr<aura::WindowTreeClient> CreateWindowTreeClient() = 0; | 70 virtual std::unique_ptr<aura::WindowTreeClient> CreateWindowTreeClient() = 0; |
68 bool HasPendingWindowTreeData() const; | |
69 | 71 |
70 // service_manager::Service: | 72 // service_manager::Service: |
71 void OnStart() override; | 73 void OnStart() override; |
72 bool OnConnect(const service_manager::ServiceInfo& remote_info, | 74 bool OnConnect(const service_manager::ServiceInfo& remote_info, |
73 service_manager::InterfaceRegistry* registry) override; | 75 service_manager::InterfaceRegistry* registry) override; |
74 | 76 |
75 // aura::WindowTreeClientDelegate: | 77 // aura::WindowTreeClientDelegate: |
76 void OnEmbed( | 78 void OnEmbed( |
77 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override; | 79 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override; |
78 void OnUnembed(aura::Window* root) override; | 80 void OnUnembed(aura::Window* root) override; |
(...skipping 16 matching lines...) Expand all Loading... |
95 // next call to InitWindowTreeData. | 97 // next call to InitWindowTreeData. |
96 std::vector<std::unique_ptr<WindowTreeData>> window_tree_data_list_; | 98 std::vector<std::unique_ptr<WindowTreeData>> window_tree_data_list_; |
97 | 99 |
98 DISALLOW_COPY_AND_ASSIGN(MusDemo); | 100 DISALLOW_COPY_AND_ASSIGN(MusDemo); |
99 }; | 101 }; |
100 | 102 |
101 } // namespace demo | 103 } // namespace demo |
102 } // namespace ui | 104 } // namespace ui |
103 | 105 |
104 #endif // SERVICES_UI_DEMO_MUS_DEMO_H_ | 106 #endif // SERVICES_UI_DEMO_MUS_DEMO_H_ |
OLD | NEW |