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

Side by Side Diff: mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h

Issue 338093008: Client side name cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_SYNCHRONIZER_H_ 5 #ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_
6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_SYNCHRONIZER_H_ 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" 12 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
13 #include "mojo/services/public/cpp/view_manager/node.h"
14 #include "mojo/services/public/cpp/view_manager/types.h"
13 #include "mojo/services/public/cpp/view_manager/view_manager.h" 15 #include "mojo/services/public/cpp/view_manager/view_manager.h"
14 #include "mojo/services/public/cpp/view_manager/view_manager_types.h"
15 #include "mojo/services/public/cpp/view_manager/view_tree_node.h"
16 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" 16 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
17 17
18 class SkBitmap; 18 class SkBitmap;
19 19
20 namespace mojo { 20 namespace mojo {
21 namespace view_manager { 21 namespace view_manager {
22 22
23 class ViewManager; 23 class ViewManager;
24 class ViewManagerTransaction; 24 class ViewManagerTransaction;
25 25
26 // Manages the connection with the View Manager service. 26 // Manages the connection with the View Manager service.
27 class ViewManagerSynchronizer : public ViewManager, 27 class ViewManagerClientImpl : public ViewManager,
28 public InterfaceImpl<ViewManagerClient> { 28 public InterfaceImpl<ViewManagerClient> {
29 public: 29 public:
30 explicit ViewManagerSynchronizer(ViewManagerDelegate* delegate); 30 explicit ViewManagerClientImpl(ViewManagerDelegate* delegate);
31 virtual ~ViewManagerSynchronizer(); 31 virtual ~ViewManagerClientImpl();
32 32
33 bool connected() const { return connected_; } 33 bool connected() const { return connected_; }
34 ConnectionSpecificId connection_id() const { return connection_id_; } 34 ConnectionSpecificId connection_id() const { return connection_id_; }
35 35
36 // API exposed to the node/view implementations that pushes local changes to 36 // API exposed to the node/view implementations that pushes local changes to
37 // the service. 37 // the service.
38 Id CreateViewTreeNode(); 38 Id CreateNode();
39 void DestroyViewTreeNode(Id node_id); 39 void DestroyNode(Id node_id);
40 40
41 Id CreateView(); 41 Id CreateView();
42 void DestroyView(Id view_id); 42 void DestroyView(Id view_id);
43 43
44 // These methods take TransportIds. For views owned by the current connection, 44 // These methods take TransportIds. For views owned by the current connection,
45 // the connection id high word can be zero. In all cases, the TransportId 0x1 45 // the connection id high word can be zero. In all cases, the TransportId 0x1
46 // refers to the root node. 46 // refers to the root node.
47 void AddChild(Id child_id, Id parent_id); 47 void AddChild(Id child_id, Id parent_id);
48 void RemoveChild(Id child_id, Id parent_id); 48 void RemoveChild(Id child_id, Id parent_id);
49 49
(...skipping 12 matching lines...) Expand all
62 62
63 void set_changes_acked_callback(const base::Callback<void(void)>& callback) { 63 void set_changes_acked_callback(const base::Callback<void(void)>& callback) {
64 changes_acked_callback_ = callback; 64 changes_acked_callback_ = callback;
65 } 65 }
66 void ClearChangesAckedCallback() { 66 void ClearChangesAckedCallback() {
67 changes_acked_callback_ = base::Callback<void(void)>(); 67 changes_acked_callback_ = base::Callback<void(void)>();
68 } 68 }
69 69
70 // Start/stop tracking nodes & views. While tracked, they can be retrieved via 70 // Start/stop tracking nodes & views. While tracked, they can be retrieved via
71 // ViewManager::GetNode/ViewById. 71 // ViewManager::GetNode/ViewById.
72 void AddNode(ViewTreeNode* node); 72 void AddNode(Node* node);
73 void RemoveNode(Id node_id); 73 void RemoveNode(Id node_id);
74 74
75 void AddView(View* view); 75 void AddView(View* view);
76 void RemoveView(Id view_id); 76 void RemoveView(Id view_id);
77 77
78 private: 78 private:
79 friend class RootObserver; 79 friend class RootObserver;
80 friend class ViewManagerTransaction; 80 friend class ViewManagerTransaction;
81 81
82 typedef ScopedVector<ViewManagerTransaction> Transactions; 82 typedef ScopedVector<ViewManagerTransaction> Transactions;
83 typedef std::map<Id, ViewTreeNode*> IdToNodeMap; 83 typedef std::map<Id, Node*> IdToNodeMap;
84 typedef std::map<Id, View*> IdToViewMap; 84 typedef std::map<Id, View*> IdToViewMap;
85 typedef std::map<ConnectionSpecificId,
86 ViewManagerSynchronizer*> SynchronizerMap;
87 85
88 // Overridden from ViewManager: 86 // Overridden from ViewManager:
89 virtual const std::string& GetEmbedderURL() const OVERRIDE; 87 virtual const std::string& GetEmbedderURL() const OVERRIDE;
90 virtual const std::vector<ViewTreeNode*>& GetRoots() const OVERRIDE; 88 virtual const std::vector<Node*>& GetRoots() const OVERRIDE;
91 virtual ViewTreeNode* GetNodeById(Id id) OVERRIDE; 89 virtual Node* GetNodeById(Id id) OVERRIDE;
92 virtual View* GetViewById(Id id) OVERRIDE; 90 virtual View* GetViewById(Id id) OVERRIDE;
93 91
94 // Overridden from InterfaceImpl: 92 // Overridden from InterfaceImpl:
95 virtual void OnConnectionEstablished() OVERRIDE; 93 virtual void OnConnectionEstablished() OVERRIDE;
96 94
97 // Overridden from ViewManagerClient: 95 // Overridden from ViewManagerClient:
98 virtual void OnViewManagerConnectionEstablished( 96 virtual void OnViewManagerConnectionEstablished(
99 ConnectionSpecificId connection_id, 97 ConnectionSpecificId connection_id,
100 const String& creator_url, 98 const String& creator_url,
101 Id next_server_change_id, 99 Id next_server_change_id,
(...skipping 22 matching lines...) Expand all
124 const Callback<void()>& callback) OVERRIDE; 122 const Callback<void()>& callback) OVERRIDE;
125 123
126 // Sync the client model with the service by enumerating the pending 124 // Sync the client model with the service by enumerating the pending
127 // transaction queue and applying them in order. 125 // transaction queue and applying them in order.
128 void Sync(); 126 void Sync();
129 127
130 // Removes |transaction| from the pending queue. |transaction| must be at the 128 // Removes |transaction| from the pending queue. |transaction| must be at the
131 // front of the queue. 129 // front of the queue.
132 void RemoveFromPendingQueue(ViewManagerTransaction* transaction); 130 void RemoveFromPendingQueue(ViewManagerTransaction* transaction);
133 131
134 void AddRoot(ViewTreeNode* root); 132 void AddRoot(Node* root);
135 void RemoveRoot(ViewTreeNode* root); 133 void RemoveRoot(Node* root);
136 134
137 bool connected_; 135 bool connected_;
138 ConnectionSpecificId connection_id_; 136 ConnectionSpecificId connection_id_;
139 ConnectionSpecificId next_id_; 137 ConnectionSpecificId next_id_;
140 Id next_server_change_id_; 138 Id next_server_change_id_;
141 139
142 std::string creator_url_; 140 std::string creator_url_;
143 141
144 Transactions pending_transactions_; 142 Transactions pending_transactions_;
145 143
146 base::Callback<void(void)> changes_acked_callback_; 144 base::Callback<void(void)> changes_acked_callback_;
147 145
148 ViewManagerDelegate* delegate_; 146 ViewManagerDelegate* delegate_;
149 147
150 std::vector<ViewTreeNode*> roots_; 148 std::vector<Node*> roots_;
151 149
152 IdToNodeMap nodes_; 150 IdToNodeMap nodes_;
153 IdToViewMap views_; 151 IdToViewMap views_;
154 152
155 ViewManagerService* service_; 153 ViewManagerService* service_;
156 154
157 DISALLOW_COPY_AND_ASSIGN(ViewManagerSynchronizer); 155 DISALLOW_COPY_AND_ASSIGN(ViewManagerClientImpl);
158 }; 156 };
159 157
160 } // namespace view_manager 158 } // namespace view_manager
161 } // namespace mojo 159 } // namespace mojo
162 160
163 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_SYNCHRONIZER_H _ 161 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698