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 "services/shell/public/cpp/lib/connection_impl.h" | 5 #include "services/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 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 bool ConnectionImpl::IsPending() const { | 79 bool ConnectionImpl::IsPending() const { |
80 return state_ == State::PENDING; | 80 return state_ == State::PENDING; |
81 } | 81 } |
82 | 82 |
83 uint32_t ConnectionImpl::GetRemoteInstanceID() const { | 83 uint32_t ConnectionImpl::GetRemoteInstanceID() const { |
84 return remote_id_; | 84 return remote_id_; |
85 } | 85 } |
86 | 86 |
87 void ConnectionImpl::AddConnectionCompletedClosure( | 87 void ConnectionImpl::AddConnectionCompletedClosure( |
88 const base::Closure& callback) { | 88 const mojo::Closure& callback) { |
89 if (IsPending()) | 89 if (IsPending()) |
90 connection_completed_callbacks_.push_back(callback); | 90 connection_completed_callbacks_.push_back(callback); |
91 else | 91 else |
92 callback.Run(); | 92 callback.Run(); |
93 } | 93 } |
94 | 94 |
95 bool ConnectionImpl::AllowsInterface(const std::string& interface_name) const { | 95 bool ConnectionImpl::AllowsInterface(const std::string& interface_name) const { |
96 return allow_all_interfaces_ || | 96 return allow_all_interfaces_ || |
97 capability_request_.interfaces.count(interface_name); | 97 capability_request_.interfaces.count(interface_name); |
98 } | 98 } |
(...skipping 20 matching lines...) Expand all Loading... |
119 void ConnectionImpl::OnConnectionCompleted(shell::mojom::ConnectResult result, | 119 void ConnectionImpl::OnConnectionCompleted(shell::mojom::ConnectResult result, |
120 mojo::String target_user_id, | 120 mojo::String target_user_id, |
121 uint32_t target_application_id) { | 121 uint32_t target_application_id) { |
122 DCHECK(State::PENDING == state_); | 122 DCHECK(State::PENDING == state_); |
123 | 123 |
124 result_ = result; | 124 result_ = result; |
125 state_ = result_ == shell::mojom::ConnectResult::SUCCEEDED ? | 125 state_ = result_ == shell::mojom::ConnectResult::SUCCEEDED ? |
126 State::CONNECTED : State::DISCONNECTED; | 126 State::CONNECTED : State::DISCONNECTED; |
127 remote_id_ = target_application_id; | 127 remote_id_ = target_application_id; |
128 remote_.set_user_id(target_user_id); | 128 remote_.set_user_id(target_user_id); |
129 std::vector<base::Closure> callbacks; | 129 std::vector<mojo::Closure> callbacks; |
130 callbacks.swap(connection_completed_callbacks_); | 130 callbacks.swap(connection_completed_callbacks_); |
131 for (auto callback : callbacks) | 131 for (auto callback : callbacks) |
132 callback.Run(); | 132 callback.Run(); |
133 } | 133 } |
134 | 134 |
135 } // namespace internal | 135 } // namespace internal |
136 } // namespace shell | 136 } // namespace shell |
OLD | NEW |