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" |
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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 DCHECK_EQ(old_view, node->active_view()); | 630 DCHECK_EQ(old_view, node->active_view()); |
630 ViewTreeNodePrivate(node).LocalSetActiveView(new_view); | 631 ViewTreeNodePrivate(node).LocalSetActiveView(new_view); |
631 } | 632 } |
632 | 633 |
633 void ViewManagerSynchronizer::OnViewDeleted(uint32_t view_id) { | 634 void ViewManagerSynchronizer::OnViewDeleted(uint32_t view_id) { |
634 View* view = view_manager()->GetViewById(view_id); | 635 View* view = view_manager()->GetViewById(view_id); |
635 if (view) | 636 if (view) |
636 ViewPrivate(view).LocalDestroy(); | 637 ViewPrivate(view).LocalDestroy(); |
637 } | 638 } |
638 | 639 |
| 640 void ViewManagerSynchronizer::OnViewInputEvent( |
| 641 uint32_t view_id, |
| 642 EventPtr event, |
| 643 const Callback<void()>& ack_callback) { |
| 644 View* view = view_manager_->GetViewById(view_id); |
| 645 if (view) { |
| 646 FOR_EACH_OBSERVER(ViewObserver, |
| 647 *ViewPrivate(view).observers(), |
| 648 OnViewInputEvent(view, event.Pass())); |
| 649 } |
| 650 ack_callback.Run(); |
| 651 } |
| 652 |
| 653 |
639 //////////////////////////////////////////////////////////////////////////////// | 654 //////////////////////////////////////////////////////////////////////////////// |
640 // ViewManagerSynchronizer, private: | 655 // ViewManagerSynchronizer, private: |
641 | 656 |
642 void ViewManagerSynchronizer::Sync() { | 657 void ViewManagerSynchronizer::Sync() { |
643 // The service connection may not be set up yet. OnConnectionEstablished() | 658 // The service connection may not be set up yet. OnConnectionEstablished() |
644 // will schedule another sync when it is. | 659 // will schedule another sync when it is. |
645 if (!connected_) | 660 if (!connected_) |
646 return; | 661 return; |
647 | 662 |
648 Transactions::const_iterator it = pending_transactions_.begin(); | 663 Transactions::const_iterator it = pending_transactions_.begin(); |
649 for (; it != pending_transactions_.end(); ++it) { | 664 for (; it != pending_transactions_.end(); ++it) { |
650 if (!(*it)->committed()) | 665 if (!(*it)->committed()) |
651 (*it)->Commit(); | 666 (*it)->Commit(); |
652 } | 667 } |
653 } | 668 } |
654 | 669 |
655 void ViewManagerSynchronizer::RemoveFromPendingQueue( | 670 void ViewManagerSynchronizer::RemoveFromPendingQueue( |
656 ViewManagerTransaction* transaction) { | 671 ViewManagerTransaction* transaction) { |
657 DCHECK_EQ(transaction, pending_transactions_.front()); | 672 DCHECK_EQ(transaction, pending_transactions_.front()); |
658 pending_transactions_.erase(pending_transactions_.begin()); | 673 pending_transactions_.erase(pending_transactions_.begin()); |
659 if (pending_transactions_.empty() && !changes_acked_callback_.is_null()) | 674 if (pending_transactions_.empty() && !changes_acked_callback_.is_null()) |
660 changes_acked_callback_.Run(); | 675 changes_acked_callback_.Run(); |
661 } | 676 } |
662 | 677 |
663 } // namespace view_manager | 678 } // namespace view_manager |
664 } // namespace mojo | 679 } // namespace mojo |
OLD | NEW |