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_url, |
24 const std::string& remote_url, | 24 const std::string& remote_url, |
25 uint32_t remote_id, | 25 uint32_t remote_id, |
| 26 uint32_t remote_user_id, |
26 shell::mojom::InterfaceProviderPtr remote_interfaces, | 27 shell::mojom::InterfaceProviderPtr remote_interfaces, |
27 shell::mojom::InterfaceProviderRequest local_interfaces, | 28 shell::mojom::InterfaceProviderRequest local_interfaces, |
28 const std::set<std::string>& allowed_interfaces) | 29 const std::set<std::string>& allowed_interfaces) |
29 : connection_url_(connection_url), | 30 : connection_url_(connection_url), |
30 remote_url_(remote_url), | 31 remote_url_(remote_url), |
31 remote_id_(remote_id), | 32 remote_id_(remote_id), |
32 remote_ids_valid_(false), | 33 remote_ids_valid_(false), |
| 34 remote_user_id_(remote_user_id), |
33 local_registry_(std::move(local_interfaces), this), | 35 local_registry_(std::move(local_interfaces), this), |
34 remote_interfaces_(std::move(remote_interfaces)), | 36 remote_interfaces_(std::move(remote_interfaces)), |
35 allowed_interfaces_(allowed_interfaces), | 37 allowed_interfaces_(allowed_interfaces), |
36 allow_all_interfaces_(allowed_interfaces_.size() == 1 && | 38 allow_all_interfaces_(allowed_interfaces_.size() == 1 && |
37 allowed_interfaces_.count("*") == 1), | 39 allowed_interfaces_.count("*") == 1), |
38 weak_factory_(this) {} | 40 weak_factory_(this) {} |
39 | 41 |
40 ConnectionImpl::ConnectionImpl() | 42 ConnectionImpl::ConnectionImpl() |
41 : remote_id_(shell::mojom::Shell::kInvalidApplicationID), | 43 : remote_id_(shell::mojom::Shell::kInvalidApplicationID), |
42 remote_ids_valid_(false), | 44 remote_ids_valid_(false), |
(...skipping 12 matching lines...) Expand all Loading... |
55 // ConnectionImpl, Connection implementation: | 57 // ConnectionImpl, Connection implementation: |
56 | 58 |
57 const std::string& ConnectionImpl::GetConnectionURL() { | 59 const std::string& ConnectionImpl::GetConnectionURL() { |
58 return connection_url_; | 60 return connection_url_; |
59 } | 61 } |
60 | 62 |
61 const std::string& ConnectionImpl::GetRemoteApplicationURL() { | 63 const std::string& ConnectionImpl::GetRemoteApplicationURL() { |
62 return remote_url_; | 64 return remote_url_; |
63 } | 65 } |
64 | 66 |
| 67 uint32_t ConnectionImpl::GetRemoteUserID() const { |
| 68 return remote_user_id_; |
| 69 } |
| 70 |
65 void ConnectionImpl::SetRemoteInterfaceProviderConnectionErrorHandler( | 71 void ConnectionImpl::SetRemoteInterfaceProviderConnectionErrorHandler( |
66 const Closure& handler) { | 72 const Closure& handler) { |
67 remote_interfaces_.set_connection_error_handler(handler); | 73 remote_interfaces_.set_connection_error_handler(handler); |
68 } | 74 } |
69 | 75 |
70 bool ConnectionImpl::GetRemoteApplicationID(uint32_t* remote_id) const { | 76 bool ConnectionImpl::GetRemoteApplicationID(uint32_t* remote_id) const { |
71 if (!remote_ids_valid_) | 77 if (!remote_ids_valid_) |
72 return false; | 78 return false; |
73 | 79 |
74 *remote_id = remote_id_; | 80 *remote_id = remote_id_; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 114 |
109 remote_id_ = target_application_id; | 115 remote_id_ = target_application_id; |
110 std::vector<Closure> callbacks; | 116 std::vector<Closure> callbacks; |
111 callbacks.swap(remote_id_callbacks_); | 117 callbacks.swap(remote_id_callbacks_); |
112 for (auto callback : callbacks) | 118 for (auto callback : callbacks) |
113 callback.Run(); | 119 callback.Run(); |
114 } | 120 } |
115 | 121 |
116 } // namespace internal | 122 } // namespace internal |
117 } // namespace mojo | 123 } // namespace mojo |
OLD | NEW |