| 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 "mojo/public/cpp/application/connect.h" | 9 #include "mojo/public/cpp/application/connect.h" |
| 10 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" | 10 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 ViewManagerSynchronizer::ViewManagerSynchronizer(ViewManagerDelegate* delegate) | 440 ViewManagerSynchronizer::ViewManagerSynchronizer(ViewManagerDelegate* delegate) |
| 441 : view_manager_(new ViewManager(this, delegate)), | 441 : view_manager_(new ViewManager(this, delegate)), |
| 442 connected_(false), | 442 connected_(false), |
| 443 connection_id_(0), | 443 connection_id_(0), |
| 444 next_id_(1), | 444 next_id_(1), |
| 445 next_server_change_id_(0), | 445 next_server_change_id_(0), |
| 446 sync_factory_(this) { | 446 sync_factory_(this) { |
| 447 } | 447 } |
| 448 | 448 |
| 449 ViewManagerSynchronizer::~ViewManagerSynchronizer() { | 449 ViewManagerSynchronizer::~ViewManagerSynchronizer() { |
| 450 // Destroying the |view_manager_| may attempt to add transactions to |
| 451 // |pending_transactions_|. So we need to destroy |view_manager_| first. |
| 452 view_manager_.reset(); |
| 450 } | 453 } |
| 451 | 454 |
| 452 TransportNodeId ViewManagerSynchronizer::CreateViewTreeNode() { | 455 TransportNodeId ViewManagerSynchronizer::CreateViewTreeNode() { |
| 453 DCHECK(connected_); | 456 DCHECK(connected_); |
| 454 const TransportNodeId node_id( | 457 const TransportNodeId node_id( |
| 455 MakeTransportId(connection_id_, ++next_id_)); | 458 MakeTransportId(connection_id_, ++next_id_)); |
| 456 pending_transactions_.push_back( | 459 pending_transactions_.push_back( |
| 457 new CreateViewTreeNodeTransaction(node_id, this)); | 460 new CreateViewTreeNodeTransaction(node_id, this)); |
| 458 Sync(); | 461 Sync(); |
| 459 return node_id; | 462 return node_id; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 void ViewManagerSynchronizer::RemoveFromPendingQueue( | 672 void ViewManagerSynchronizer::RemoveFromPendingQueue( |
| 670 ViewManagerTransaction* transaction) { | 673 ViewManagerTransaction* transaction) { |
| 671 DCHECK_EQ(transaction, pending_transactions_.front()); | 674 DCHECK_EQ(transaction, pending_transactions_.front()); |
| 672 pending_transactions_.erase(pending_transactions_.begin()); | 675 pending_transactions_.erase(pending_transactions_.begin()); |
| 673 if (pending_transactions_.empty() && !changes_acked_callback_.is_null()) | 676 if (pending_transactions_.empty() && !changes_acked_callback_.is_null()) |
| 674 changes_acked_callback_.Run(); | 677 changes_acked_callback_.Run(); |
| 675 } | 678 } |
| 676 | 679 |
| 677 } // namespace view_manager | 680 } // namespace view_manager |
| 678 } // namespace mojo | 681 } // namespace mojo |
| OLD | NEW |