| OLD | NEW |
| 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 #include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h" | 5 #include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "mojo/public/cpp/bindings/allocation_scope.h" | 10 #include "mojo/public/cpp/shell/service.h" |
| 11 #include "mojo/public/interfaces/shell/shell.mojom.h" | 11 #include "mojo/public/interfaces/shell/shell.mojom.h" |
| 12 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h" | 12 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h" |
| 13 #include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h" | 13 #include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h" |
| 14 #include "mojo/services/public/cpp/view_manager/util.h" | 14 #include "mojo/services/public/cpp/view_manager/util.h" |
| 15 | 15 |
| 16 namespace mojo { | 16 namespace mojo { |
| 17 namespace services { | 17 namespace services { |
| 18 namespace view_manager { | 18 namespace view_manager { |
| 19 | 19 |
| 20 TransportNodeId MakeTransportNodeId(uint16_t connection_id, | 20 TransportNodeId MakeTransportNodeId(uint16_t connection_id, |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 DISALLOW_COPY_AND_ASSIGN(HierarchyTransaction); | 179 DISALLOW_COPY_AND_ASSIGN(HierarchyTransaction); |
| 180 }; | 180 }; |
| 181 | 181 |
| 182 ViewManagerSynchronizer::ViewManagerSynchronizer(ViewManager* view_manager) | 182 ViewManagerSynchronizer::ViewManagerSynchronizer(ViewManager* view_manager) |
| 183 : view_manager_(view_manager), | 183 : view_manager_(view_manager), |
| 184 connected_(false), | 184 connected_(false), |
| 185 connection_id_(0), | 185 connection_id_(0), |
| 186 next_id_(1), | 186 next_id_(1), |
| 187 next_change_id_(0), | 187 next_change_id_(0), |
| 188 init_loop_(NULL) { | 188 init_loop_(NULL) { |
| 189 InterfacePipe<services::view_manager::IViewManager, AnyInterface> | 189 ConnectTo(ViewManagerPrivate(view_manager_).shell(), "mojo:mojo_view_manager", |
| 190 view_manager_pipe; | 190 &service_); |
| 191 service_->SetClient(this); |
| 192 |
| 191 AllocationScope scope; | 193 AllocationScope scope; |
| 192 MessagePipeHandle client_handle = view_manager_pipe.handle_to_peer.get(); | |
| 193 ViewManagerPrivate(view_manager_).shell()->Connect( | |
| 194 "mojo:mojo_view_manager", view_manager_pipe.handle_to_peer.Pass()); | |
| 195 service_.reset(view_manager_pipe.handle_to_self.Pass(), this); | |
| 196 service_->GetNodeTree( | 194 service_->GetNodeTree( |
| 197 1, | 195 1, |
| 198 base::Bind(&ViewManagerSynchronizer::OnRootTreeReceived, | 196 base::Bind(&ViewManagerSynchronizer::OnRootTreeReceived, |
| 199 base::Unretained(this))); | 197 base::Unretained(this))); |
| 198 |
| 200 base::RunLoop loop; | 199 base::RunLoop loop; |
| 201 init_loop_ = &loop; | 200 init_loop_ = &loop; |
| 202 init_loop_->Run(); | 201 init_loop_->Run(); |
| 203 init_loop_ = NULL; | 202 init_loop_ = NULL; |
| 204 } | 203 } |
| 205 | 204 |
| 206 ViewManagerSynchronizer::~ViewManagerSynchronizer() { | 205 ViewManagerSynchronizer::~ViewManagerSynchronizer() { |
| 207 } | 206 } |
| 208 | 207 |
| 209 TransportNodeId ViewManagerSynchronizer::CreateViewTreeNode() { | 208 TransportNodeId ViewManagerSynchronizer::CreateViewTreeNode() { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 last_node = node; | 346 last_node = node; |
| 348 } | 347 } |
| 349 ViewManagerPrivate(view_manager_).SetRoot(root); | 348 ViewManagerPrivate(view_manager_).SetRoot(root); |
| 350 if (init_loop_) | 349 if (init_loop_) |
| 351 init_loop_->Quit(); | 350 init_loop_->Quit(); |
| 352 } | 351 } |
| 353 | 352 |
| 354 } // namespace view_manager | 353 } // namespace view_manager |
| 355 } // namespace services | 354 } // namespace services |
| 356 } // namespace mojo | 355 } // namespace mojo |
| OLD | NEW |