OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_VIEW_MANAGER_VIEW_ASSOCIATE_TABLE_H_ | 5 #ifndef SERVICES_UI_VIEW_MANAGER_VIEW_ASSOCIATE_TABLE_H_ |
6 #define SERVICES_UI_VIEW_MANAGER_VIEW_ASSOCIATE_TABLE_H_ | 6 #define SERVICES_UI_VIEW_MANAGER_VIEW_ASSOCIATE_TABLE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "mojo/common/binding_set.h" | 14 #include "mojo/common/binding_set.h" |
15 #include "mojo/public/cpp/application/application_impl.h" | 15 #include "mojo/public/cpp/application/application_impl.h" |
16 #include "mojo/services/ui/views/interfaces/view_associates.mojom.h" | 16 #include "mojo/services/ui/views/interfaces/view_associates.mojom.h" |
17 #include "mojo/services/ui/views/interfaces/view_manager.mojom.h" | |
17 | 18 |
18 namespace view_manager { | 19 namespace view_manager { |
19 | 20 |
20 // Maintains a table of all connected view associates. | 21 // Maintains a table of all connected view associates. |
21 class ViewAssociateTable { | 22 class ViewAssociateTable { |
22 public: | 23 public: |
23 using AssociateConnectionErrorCallback = | 24 using AssociateConnectionErrorCallback = |
24 base::Callback<void(const std::string&)>; | 25 base::Callback<void(const std::string&)>; |
25 | 26 |
26 ViewAssociateTable(); | 27 ViewAssociateTable(); |
27 ~ViewAssociateTable(); | 28 ~ViewAssociateTable(); |
28 | 29 |
29 // Begins connecting to the view associates. | 30 void RegisterViewAssociate( |
30 // Invokes |connection_error_callback| if an associate connection fails | |
31 // and provides the associate's url. | |
32 void ConnectAssociates( | |
33 mojo::ApplicationImpl* app_impl, | |
34 mojo::ui::ViewInspector* inspector, | 31 mojo::ui::ViewInspector* inspector, |
35 const std::vector<std::string>& urls, | 32 mojo::ui::ViewAssociatePtr associate, |
36 const AssociateConnectionErrorCallback& connection_error_callback); | 33 const AssociateConnectionErrorCallback& connection_error_callback, |
jeffbrown
2016/05/17 00:44:49
I think you can remove this callback now given you
mikejurka
2016/05/18 01:14:28
Done.
| |
34 const mojo::String& label); | |
35 | |
36 void RegisterViewAssociateWatcher( | |
37 mojo::ui::ViewAssociateWatcherPtr view_associate_watcher); | |
37 | 38 |
38 // Connects to services offered by the view associates. | 39 // Connects to services offered by the view associates. |
39 void ConnectToViewService(mojo::ui::ViewTokenPtr view_token, | 40 void ConnectToViewService(mojo::ui::ViewTokenPtr view_token, |
40 const mojo::String& service_name, | 41 const mojo::String& service_name, |
41 mojo::ScopedMessagePipeHandle client_handle); | 42 mojo::ScopedMessagePipeHandle client_handle); |
42 void ConnectToViewTreeService(mojo::ui::ViewTreeTokenPtr view_tree_token, | 43 void ConnectToViewTreeService(mojo::ui::ViewTreeTokenPtr view_tree_token, |
43 const mojo::String& service_name, | 44 const mojo::String& service_name, |
44 mojo::ScopedMessagePipeHandle client_handle); | 45 mojo::ScopedMessagePipeHandle client_handle); |
45 | 46 |
46 void OnConnected(uint32_t index, mojo::ui::ViewAssociateInfoPtr info); | 47 void OnConnected(uint32_t index, mojo::ui::ViewAssociateInfoPtr info); |
47 | 48 |
48 void CompleteDeferredWork(); | 49 void CompleteDeferredWork(); |
49 | 50 |
51 size_t associate_count(); | |
52 | |
50 private: | 53 private: |
51 struct AssociateData { | 54 struct AssociateData { |
52 AssociateData(const std::string& url, mojo::ui::ViewInspector* inspector); | 55 AssociateData(const std::string& label, |
56 mojo::ui::ViewAssociatePtr associate, | |
57 mojo::ui::ViewInspector* inspector); | |
53 ~AssociateData(); | 58 ~AssociateData(); |
54 | 59 |
55 const std::string url; | 60 const std::string label; |
56 mojo::ui::ViewAssociatePtr associate; | 61 mojo::ui::ViewAssociatePtr associate; |
57 mojo::ui::ViewAssociateInfoPtr info; | 62 mojo::ui::ViewAssociateInfoPtr info; |
58 mojo::Binding<mojo::ui::ViewInspector> inspector_binding; | 63 mojo::Binding<mojo::ui::ViewInspector> inspector_binding; |
59 }; | 64 }; |
60 | 65 |
66 void OnAssociateConnectionError(AssociateData* associate_data); | |
67 | |
61 std::vector<std::unique_ptr<AssociateData>> associates_; | 68 std::vector<std::unique_ptr<AssociateData>> associates_; |
69 std::vector<mojo::ui::ViewAssociateWatcherPtr> associate_watchers_; | |
62 | 70 |
63 uint32_t pending_connection_count_ = 0u; | 71 uint32_t pending_connection_count_ = 0u; |
64 std::vector<base::Closure> deferred_work_; | 72 std::vector<base::Closure> deferred_work_; |
65 | 73 |
66 DISALLOW_COPY_AND_ASSIGN(ViewAssociateTable); | 74 DISALLOW_COPY_AND_ASSIGN(ViewAssociateTable); |
67 }; | 75 }; |
68 | 76 |
69 } // namespace view_manager | 77 } // namespace view_manager |
70 | 78 |
71 #endif // SERVICES_UI_VIEW_MANAGER_VIEW_ASSOCIATE_TABLE_H_ | 79 #endif // SERVICES_UI_VIEW_MANAGER_VIEW_ASSOCIATE_TABLE_H_ |
OLD | NEW |