Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: services/ui/input_manager/input_associate.cc

Issue 1682113003: Mojo C++ bindings: Generate InterfaceHandle<> instead of InterfacePtr<>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebase ontop of master, address trung's comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/input_manager/input_associate.h ('k') | services/ui/view_manager/view_host_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "services/ui/input_manager/input_associate.h" 5 #include "services/ui/input_manager/input_associate.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "mojo/public/cpp/bindings/interface_request.h" 11 #include "mojo/public/cpp/bindings/interface_request.h"
10 12
11 namespace input_manager { 13 namespace input_manager {
12 14
13 InputAssociate::InputAssociate() {} 15 InputAssociate::InputAssociate() {}
14 16
15 InputAssociate::~InputAssociate() {} 17 InputAssociate::~InputAssociate() {}
16 18
17 void InputAssociate::Connect(mojo::ui::ViewInspectorPtr inspector, 19 void InputAssociate::Connect(
18 const ConnectCallback& callback) { 20 mojo::InterfaceHandle<mojo::ui::ViewInspector> inspector,
21 const ConnectCallback& callback) {
19 DCHECK(inspector); // checked by mojom 22 DCHECK(inspector); // checked by mojom
20 23
21 auto info = mojo::ui::ViewAssociateInfo::New(); 24 auto info = mojo::ui::ViewAssociateInfo::New();
22 info->view_service_names.push_back(mojo::ui::InputConnection::Name_); 25 info->view_service_names.push_back(mojo::ui::InputConnection::Name_);
23 info->view_tree_service_names.push_back(mojo::ui::InputDispatcher::Name_); 26 info->view_tree_service_names.push_back(mojo::ui::InputDispatcher::Name_);
24 callback.Run(info.Pass()); 27 callback.Run(info.Pass());
25 } 28 }
26 29
27 void InputAssociate::ConnectToViewService( 30 void InputAssociate::ConnectToViewService(
28 mojo::ui::ViewTokenPtr view_token, 31 mojo::ui::ViewTokenPtr view_token,
(...skipping 14 matching lines...) Expand all
43 mojo::ScopedMessagePipeHandle client_handle) { 46 mojo::ScopedMessagePipeHandle client_handle) {
44 DCHECK(view_tree_token); // checked by mojom 47 DCHECK(view_tree_token); // checked by mojom
45 48
46 if (service_name == mojo::ui::InputDispatcher::Name_) { 49 if (service_name == mojo::ui::InputDispatcher::Name_) {
47 input_dispatchers_.AddBinding( 50 input_dispatchers_.AddBinding(
48 new InputDispatcherImpl(this, view_tree_token.Pass()), 51 new InputDispatcherImpl(this, view_tree_token.Pass()),
49 mojo::MakeRequest<mojo::ui::InputDispatcher>(client_handle.Pass())); 52 mojo::MakeRequest<mojo::ui::InputDispatcher>(client_handle.Pass()));
50 } 53 }
51 } 54 }
52 55
53 void InputAssociate::SetListener(mojo::ui::ViewToken* view_token, 56 void InputAssociate::SetListener(
54 mojo::ui::InputListenerPtr listener) { 57 mojo::ui::ViewToken* view_token,
58 mojo::InterfaceHandle<mojo::ui::InputListener> listener) {
55 // TODO(jeffbrown): This simple hack just hooks up the first listener 59 // TODO(jeffbrown): This simple hack just hooks up the first listener
56 // ever seen. 60 // ever seen.
57 if (!listener_) 61 if (!listener_)
58 listener_ = listener.Pass(); 62 listener_ = mojo::ui::InputListenerPtr::Create(std::move(listener));
59 } 63 }
60 64
61 void InputAssociate::DispatchEvent(mojo::ui::ViewTreeToken* view_tree_token, 65 void InputAssociate::DispatchEvent(mojo::ui::ViewTreeToken* view_tree_token,
62 mojo::EventPtr event) { 66 mojo::EventPtr event) {
63 if (listener_) 67 if (listener_)
64 listener_->OnEvent( 68 listener_->OnEvent(
65 event.Pass(), 69 event.Pass(),
66 base::Bind(&InputAssociate::OnEventFinished, base::Unretained(this))); 70 base::Bind(&InputAssociate::OnEventFinished, base::Unretained(this)));
67 } 71 }
68 72
69 void InputAssociate::OnEventFinished(bool handled) { 73 void InputAssociate::OnEventFinished(bool handled) {
70 // TODO: detect ANRs 74 // TODO: detect ANRs
71 } 75 }
72 76
73 InputAssociate::InputConnectionImpl::InputConnectionImpl( 77 InputAssociate::InputConnectionImpl::InputConnectionImpl(
74 InputAssociate* associate, 78 InputAssociate* associate,
75 mojo::ui::ViewTokenPtr view_token) 79 mojo::ui::ViewTokenPtr view_token)
76 : associate_(associate), view_token_(view_token.Pass()) { 80 : associate_(associate), view_token_(view_token.Pass()) {
77 DCHECK(associate_); 81 DCHECK(associate_);
78 DCHECK(view_token_); 82 DCHECK(view_token_);
79 } 83 }
80 84
81 InputAssociate::InputConnectionImpl::~InputConnectionImpl() {} 85 InputAssociate::InputConnectionImpl::~InputConnectionImpl() {}
82 86
83 void InputAssociate::InputConnectionImpl::SetListener( 87 void InputAssociate::InputConnectionImpl::SetListener(
84 mojo::ui::InputListenerPtr listener) { 88 mojo::InterfaceHandle<mojo::ui::InputListener> listener) {
85 associate_->SetListener(view_token_.get(), listener.Pass()); 89 associate_->SetListener(view_token_.get(), std::move(listener));
86 } 90 }
87 91
88 InputAssociate::InputDispatcherImpl::InputDispatcherImpl( 92 InputAssociate::InputDispatcherImpl::InputDispatcherImpl(
89 InputAssociate* associate, 93 InputAssociate* associate,
90 mojo::ui::ViewTreeTokenPtr view_tree_token) 94 mojo::ui::ViewTreeTokenPtr view_tree_token)
91 : associate_(associate), view_tree_token_(view_tree_token.Pass()) { 95 : associate_(associate), view_tree_token_(view_tree_token.Pass()) {
92 DCHECK(associate_); 96 DCHECK(associate_);
93 DCHECK(view_tree_token_); 97 DCHECK(view_tree_token_);
94 } 98 }
95 99
96 InputAssociate::InputDispatcherImpl::~InputDispatcherImpl() {} 100 InputAssociate::InputDispatcherImpl::~InputDispatcherImpl() {}
97 101
98 void InputAssociate::InputDispatcherImpl::DispatchEvent(mojo::EventPtr event) { 102 void InputAssociate::InputDispatcherImpl::DispatchEvent(mojo::EventPtr event) {
99 associate_->DispatchEvent(view_tree_token_.get(), event.Pass()); 103 associate_->DispatchEvent(view_tree_token_.get(), event.Pass());
100 } 104 }
101 105
102 } // namespace input_manager 106 } // namespace input_manager
OLDNEW
« no previous file with comments | « services/ui/input_manager/input_associate.h ('k') | services/ui/view_manager/view_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698