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/shell/public/cpp/lib/connection_impl.h" | 5 #include "mojo/shell/public/cpp/lib/connection_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "mojo/shell/public/cpp/connection.h" | 13 #include "mojo/shell/public/cpp/connection.h" |
14 #include "mojo/shell/public/cpp/interface_binder.h" | 14 #include "mojo/shell/public/cpp/interface_binder.h" |
15 | 15 |
16 namespace mojo { | 16 namespace mojo { |
17 namespace internal { | 17 namespace internal { |
18 | 18 |
19 //////////////////////////////////////////////////////////////////////////////// | 19 //////////////////////////////////////////////////////////////////////////////// |
20 // ConnectionImpl, public: | 20 // ConnectionImpl, public: |
21 | 21 |
22 ConnectionImpl::ConnectionImpl( | 22 ConnectionImpl::ConnectionImpl( |
23 const std::string& connection_url, | 23 const std::string& connection_name, |
24 const std::string& remote_url, | 24 const std::string& remote_name, |
25 uint32_t remote_id, | 25 uint32_t remote_id, |
26 uint32_t remote_user_id, | 26 uint32_t remote_user_id, |
27 shell::mojom::InterfaceProviderPtr remote_interfaces, | 27 shell::mojom::InterfaceProviderPtr remote_interfaces, |
28 shell::mojom::InterfaceProviderRequest local_interfaces, | 28 shell::mojom::InterfaceProviderRequest local_interfaces, |
29 const std::set<std::string>& allowed_interfaces) | 29 const std::set<std::string>& allowed_interfaces) |
30 : connection_url_(connection_url), | 30 : connection_name_(connection_name), |
31 remote_url_(remote_url), | 31 remote_name_(remote_name), |
32 remote_id_(remote_id), | 32 remote_id_(remote_id), |
33 remote_ids_valid_(false), | 33 remote_ids_valid_(false), |
34 remote_user_id_(remote_user_id), | 34 remote_user_id_(remote_user_id), |
35 local_registry_(std::move(local_interfaces), this), | 35 local_registry_(std::move(local_interfaces), this), |
36 remote_interfaces_(std::move(remote_interfaces)), | 36 remote_interfaces_(std::move(remote_interfaces)), |
37 allowed_interfaces_(allowed_interfaces), | 37 allowed_interfaces_(allowed_interfaces), |
38 allow_all_interfaces_(allowed_interfaces_.size() == 1 && | 38 allow_all_interfaces_(allowed_interfaces_.size() == 1 && |
39 allowed_interfaces_.count("*") == 1), | 39 allowed_interfaces_.count("*") == 1), |
40 weak_factory_(this) {} | 40 weak_factory_(this) {} |
41 | 41 |
42 ConnectionImpl::ConnectionImpl() | 42 ConnectionImpl::ConnectionImpl() |
43 : remote_id_(shell::mojom::Connector::kInvalidApplicationID), | 43 : remote_id_(shell::mojom::Connector::kInvalidApplicationID), |
44 remote_ids_valid_(false), | 44 remote_ids_valid_(false), |
45 local_registry_(shell::mojom::InterfaceProviderRequest(), this), | 45 local_registry_(shell::mojom::InterfaceProviderRequest(), this), |
46 allow_all_interfaces_(true), | 46 allow_all_interfaces_(true), |
47 weak_factory_(this) {} | 47 weak_factory_(this) {} |
48 | 48 |
49 ConnectionImpl::~ConnectionImpl() {} | 49 ConnectionImpl::~ConnectionImpl() {} |
50 | 50 |
51 shell::mojom::Connector::ConnectCallback ConnectionImpl::GetConnectCallback() { | 51 shell::mojom::Connector::ConnectCallback ConnectionImpl::GetConnectCallback() { |
52 return base::Bind(&ConnectionImpl::OnGotInstanceID, | 52 return base::Bind(&ConnectionImpl::OnGotInstanceID, |
53 weak_factory_.GetWeakPtr()); | 53 weak_factory_.GetWeakPtr()); |
54 } | 54 } |
55 | 55 |
56 //////////////////////////////////////////////////////////////////////////////// | 56 //////////////////////////////////////////////////////////////////////////////// |
57 // ConnectionImpl, Connection implementation: | 57 // ConnectionImpl, Connection implementation: |
58 | 58 |
59 const std::string& ConnectionImpl::GetConnectionURL() { | 59 const std::string& ConnectionImpl::GetConnectionName() { |
60 return connection_url_; | 60 return connection_name_; |
61 } | 61 } |
62 | 62 |
63 const std::string& ConnectionImpl::GetRemoteApplicationURL() { | 63 const std::string& ConnectionImpl::GetRemoteApplicationName() { |
64 return remote_url_; | 64 return remote_name_; |
65 } | 65 } |
66 | 66 |
67 uint32_t ConnectionImpl::GetRemoteUserID() const { | 67 uint32_t ConnectionImpl::GetRemoteUserID() const { |
68 return remote_user_id_; | 68 return remote_user_id_; |
69 } | 69 } |
70 | 70 |
71 void ConnectionImpl::SetRemoteInterfaceProviderConnectionErrorHandler( | 71 void ConnectionImpl::SetRemoteInterfaceProviderConnectionErrorHandler( |
72 const Closure& handler) { | 72 const Closure& handler) { |
73 remote_interfaces_.set_connection_error_handler(handler); | 73 remote_interfaces_.set_connection_error_handler(handler); |
74 } | 74 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 remote_id_ = target_application_id; | 115 remote_id_ = target_application_id; |
116 std::vector<Closure> callbacks; | 116 std::vector<Closure> callbacks; |
117 callbacks.swap(remote_id_callbacks_); | 117 callbacks.swap(remote_id_callbacks_); |
118 for (auto callback : callbacks) | 118 for (auto callback : callbacks) |
119 callback.Run(); | 119 callback.Run(); |
120 } | 120 } |
121 | 121 |
122 } // namespace internal | 122 } // namespace internal |
123 } // namespace mojo | 123 } // namespace mojo |
OLD | NEW |