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/run_loop.h" | 8 #include "base/run_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" |
11 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h" | 11 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h" |
12 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" | 12 #include "mojo/services/public/cpp/view_manager/lib/view_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 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
16 #include "ui/gfx/codec/png_codec.h" | 17 #include "ui/gfx/codec/png_codec.h" |
17 | 18 |
18 namespace mojo { | 19 namespace mojo { |
19 namespace view_manager { | 20 namespace view_manager { |
20 | 21 |
21 uint32_t MakeTransportId(uint16_t connection_id, uint16_t local_id) { | 22 uint32_t MakeTransportId(uint16_t connection_id, uint16_t local_id) { |
22 return (connection_id << 16) | local_id; | 23 return (connection_id << 16) | local_id; |
23 } | 24 } |
24 | 25 |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 DCHECK_EQ(old_view, node->active_view()); | 597 DCHECK_EQ(old_view, node->active_view()); |
597 ViewTreeNodePrivate(node).LocalSetActiveView(new_view); | 598 ViewTreeNodePrivate(node).LocalSetActiveView(new_view); |
598 } | 599 } |
599 | 600 |
600 void ViewManagerSynchronizer::OnViewDeleted(uint32_t view_id) { | 601 void ViewManagerSynchronizer::OnViewDeleted(uint32_t view_id) { |
601 View* view = view_manager_->GetViewById(view_id); | 602 View* view = view_manager_->GetViewById(view_id); |
602 if (view) | 603 if (view) |
603 ViewPrivate(view).LocalDestroy(); | 604 ViewPrivate(view).LocalDestroy(); |
604 } | 605 } |
605 | 606 |
| 607 void ViewManagerSynchronizer::OnViewInputEvent( |
| 608 uint32_t view_id, |
| 609 EventPtr event, |
| 610 const Callback<void()>& ack_callback) { |
| 611 View* view = view_manager_->GetViewById(view_id); |
| 612 if (view) { |
| 613 FOR_EACH_OBSERVER(ViewObserver, |
| 614 *ViewPrivate(view).observers(), |
| 615 OnViewInputEvent(view, event.Pass())); |
| 616 } |
| 617 ack_callback.Run(); |
| 618 } |
| 619 |
| 620 |
606 //////////////////////////////////////////////////////////////////////////////// | 621 //////////////////////////////////////////////////////////////////////////////// |
607 // ViewManagerSynchronizer, private: | 622 // ViewManagerSynchronizer, private: |
608 | 623 |
609 void ViewManagerSynchronizer::Sync() { | 624 void ViewManagerSynchronizer::Sync() { |
610 // The service connection may not be set up yet. OnConnectionEstablished() | 625 // The service connection may not be set up yet. OnConnectionEstablished() |
611 // will schedule another sync when it is. | 626 // will schedule another sync when it is. |
612 if (!connected_) | 627 if (!connected_) |
613 return; | 628 return; |
614 | 629 |
615 Transactions::const_iterator it = pending_transactions_.begin(); | 630 Transactions::const_iterator it = pending_transactions_.begin(); |
616 for (; it != pending_transactions_.end(); ++it) { | 631 for (; it != pending_transactions_.end(); ++it) { |
617 if (!(*it)->committed()) | 632 if (!(*it)->committed()) |
618 (*it)->Commit(); | 633 (*it)->Commit(); |
619 } | 634 } |
620 } | 635 } |
621 | 636 |
622 void ViewManagerSynchronizer::RemoveFromPendingQueue( | 637 void ViewManagerSynchronizer::RemoveFromPendingQueue( |
623 ViewManagerTransaction* transaction) { | 638 ViewManagerTransaction* transaction) { |
624 DCHECK_EQ(transaction, pending_transactions_.front()); | 639 DCHECK_EQ(transaction, pending_transactions_.front()); |
625 pending_transactions_.erase(pending_transactions_.begin()); | 640 pending_transactions_.erase(pending_transactions_.begin()); |
626 if (pending_transactions_.empty() && !changes_acked_callback_.is_null()) | 641 if (pending_transactions_.empty() && !changes_acked_callback_.is_null()) |
627 changes_acked_callback_.Run(); | 642 changes_acked_callback_.Run(); |
628 } | 643 } |
629 | 644 |
630 } // namespace view_manager | 645 } // namespace view_manager |
631 } // namespace mojo | 646 } // namespace mojo |
OLD | NEW |