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

Side by Side Diff: services/service_manager/connect_params.h

Issue 2804373002: Eliminate Connector::Connect(), Connection, etc. (Closed)
Patch Set: . Created 3 years, 8 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
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 #ifndef SERVICES_SERVICE_MANAGER_CONNECT_PARAMS_H_ 5 #ifndef SERVICES_SERVICE_MANAGER_CONNECT_PARAMS_H_
6 #define SERVICES_SERVICE_MANAGER_CONNECT_PARAMS_H_ 6 #define SERVICES_SERVICE_MANAGER_CONNECT_PARAMS_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "services/service_manager/public/cpp/connector.h"
13 #include "services/service_manager/public/cpp/identity.h" 14 #include "services/service_manager/public/cpp/identity.h"
14 #include "services/service_manager/public/interfaces/connector.mojom.h" 15 #include "services/service_manager/public/interfaces/connector.mojom.h"
15 #include "services/service_manager/public/interfaces/interface_provider.mojom.h"
16 #include "services/service_manager/public/interfaces/service.mojom.h" 16 #include "services/service_manager/public/interfaces/service.mojom.h"
17 17
18 namespace service_manager { 18 namespace service_manager {
19 19
20 // This class represents a request for the application manager to connect to an 20 // This class represents a request for the application manager to connect to an
21 // application. 21 // application.
22 class ConnectParams { 22 class ConnectParams {
23 public: 23 public:
24 ConnectParams(); 24 ConnectParams();
25 ~ConnectParams(); 25 ~ConnectParams();
26 26
27 void set_source(const Identity& source) { source_ = source; } 27 void set_source(const Identity& source) { source_ = source; }
28 const Identity& source() const { return source_; } 28 const Identity& source() const { return source_; }
29 void set_target(const Identity& target) { target_ = target; } 29 void set_target(const Identity& target) { target_ = target; }
30 const Identity& target() const { return target_; } 30 const Identity& target() const { return target_; }
31 31
32 void set_remote_interfaces(mojom::InterfaceProviderRequest value) {
33 remote_interfaces_ = std::move(value);
34 }
35 mojom::InterfaceProviderRequest TakeRemoteInterfaces() {
36 return std::move(remote_interfaces_);
37 }
38
39 void set_client_process_info( 32 void set_client_process_info(
40 mojom::ServicePtr service, 33 mojom::ServicePtr service,
41 mojom::PIDReceiverRequest pid_receiver_request) { 34 mojom::PIDReceiverRequest pid_receiver_request) {
42 service_ = std::move(service); 35 service_ = std::move(service);
43 pid_receiver_request_ = std::move(pid_receiver_request); 36 pid_receiver_request_ = std::move(pid_receiver_request);
44 } 37 }
45 bool HasClientProcessInfo() const { 38 bool HasClientProcessInfo() const {
46 return service_.is_bound() && pid_receiver_request_.is_pending(); 39 return service_.is_bound() && pid_receiver_request_.is_pending();
47 } 40 }
48 mojom::ServicePtr TakeService() { 41 mojom::ServicePtr TakeService() {
(...skipping 12 matching lines...) Expand all
61 const std::string& interface_name() const { 54 const std::string& interface_name() const {
62 return interface_name_; 55 return interface_name_;
63 } 56 }
64 bool HasInterfaceRequestInfo() const { 57 bool HasInterfaceRequestInfo() const {
65 return !interface_name_.empty() && interface_pipe_.is_valid(); 58 return !interface_name_.empty() && interface_pipe_.is_valid();
66 } 59 }
67 mojo::ScopedMessagePipeHandle TakeInterfaceRequestPipe() { 60 mojo::ScopedMessagePipeHandle TakeInterfaceRequestPipe() {
68 return std::move(interface_pipe_); 61 return std::move(interface_pipe_);
69 } 62 }
70 63
71 void set_connect_callback(const mojom::Connector::ConnectCallback& value) { 64 void set_start_service_callback(
72 connect_callback_ = value; 65 const Connector::StartServiceCallback& callback) {
73 } 66 start_service_callback_ = callback;
74 const mojom::Connector::ConnectCallback& connect_callback() const {
75 return connect_callback_;
76 } 67 }
77 68
78 void set_bind_interface_callback( 69 void set_response_data(mojom::ConnectResult result,
79 const mojom::Connector::BindInterfaceCallback& callback) { 70 const Identity& resolved_identity) {
80 bind_interface_callback_ = callback; 71 result_ = result;
81 } 72 resolved_identity_ = resolved_identity;
82 const mojom::Connector::BindInterfaceCallback&
83 bind_interface_callback() const {
84 return bind_interface_callback_;
85 } 73 }
86 74
87 private: 75 private:
88 // It may be null (i.e., is_null() returns true) which indicates that there is 76 // It may be null (i.e., is_null() returns true) which indicates that there is
89 // no source (e.g., for the first application or in tests). 77 // no source (e.g., for the first application or in tests).
90 Identity source_; 78 Identity source_;
91 // The identity of the application being connected to. 79 // The identity of the application being connected to.
92 Identity target_; 80 Identity target_;
93 81
94 mojom::InterfaceProviderRequest remote_interfaces_;
95 mojom::ServicePtr service_; 82 mojom::ServicePtr service_;
96 mojom::PIDReceiverRequest pid_receiver_request_; 83 mojom::PIDReceiverRequest pid_receiver_request_;
97 std::string interface_name_; 84 std::string interface_name_;
98 mojo::ScopedMessagePipeHandle interface_pipe_; 85 mojo::ScopedMessagePipeHandle interface_pipe_;
99 mojom::Connector::ConnectCallback connect_callback_; 86 mojom::Connector::StartServiceCallback start_service_callback_;
100 mojom::Connector::BindInterfaceCallback bind_interface_callback_; 87
88 // These values are supplied to the response callback for StartService()/
89 // BindInterface() etc. when the connection is completed.
90 mojom::ConnectResult result_ = mojom::ConnectResult::INVALID_ARGUMENT;
91 Identity resolved_identity_;
101 92
102 DISALLOW_COPY_AND_ASSIGN(ConnectParams); 93 DISALLOW_COPY_AND_ASSIGN(ConnectParams);
103 }; 94 };
104 95
105 } // namespace service_manager 96 } // namespace service_manager
106 97
107 #endif // SERVICES_SERVICE_MANAGER_CONNECT_PARAMS_H_ 98 #endif // SERVICES_SERVICE_MANAGER_CONNECT_PARAMS_H_
OLDNEW
« no previous file with comments | « services/service_manager/background/tests/test_service.cc ('k') | services/service_manager/connect_params.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698