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