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

Side by Side Diff: services/shell/public/cpp/lib/connection_impl.cc

Issue 1882423004: Move shell service to toplevel shell namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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 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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "services/shell/public/cpp/connection.h" 13 #include "services/shell/public/cpp/connection.h"
14 #include "services/shell/public/cpp/interface_binder.h" 14 #include "services/shell/public/cpp/interface_binder.h"
15 15
16 namespace mojo { 16 namespace shell {
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_name, 23 const std::string& connection_name,
24 const Identity& remote, 24 const Identity& remote,
25 uint32_t remote_id, 25 uint32_t remote_id,
26 shell::mojom::InterfaceProviderPtr remote_interfaces, 26 shell::mojom::InterfaceProviderPtr remote_interfaces,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 const std::string& ConnectionImpl::GetConnectionName() { 60 const std::string& ConnectionImpl::GetConnectionName() {
61 return connection_name_; 61 return connection_name_;
62 } 62 }
63 63
64 const Identity& ConnectionImpl::GetRemoteIdentity() const { 64 const Identity& ConnectionImpl::GetRemoteIdentity() const {
65 return remote_; 65 return remote_;
66 } 66 }
67 67
68 void ConnectionImpl::SetConnectionLostClosure(const Closure& handler) { 68 void ConnectionImpl::SetConnectionLostClosure(const mojo::Closure& handler) {
69 remote_interfaces_.set_connection_error_handler(handler); 69 remote_interfaces_.set_connection_error_handler(handler);
70 } 70 }
71 71
72 shell::mojom::ConnectResult ConnectionImpl::GetResult() const { 72 shell::mojom::ConnectResult ConnectionImpl::GetResult() const {
73 return result_; 73 return result_;
74 } 74 }
75 75
76 bool ConnectionImpl::IsPending() const { 76 bool ConnectionImpl::IsPending() const {
77 return state_ == State::PENDING; 77 return state_ == State::PENDING;
78 } 78 }
79 79
80 uint32_t ConnectionImpl::GetRemoteInstanceID() const { 80 uint32_t ConnectionImpl::GetRemoteInstanceID() const {
81 return remote_id_; 81 return remote_id_;
82 } 82 }
83 83
84 void ConnectionImpl::AddConnectionCompletedClosure(const Closure& callback) { 84 void ConnectionImpl::AddConnectionCompletedClosure(
85 const mojo::Closure& callback) {
85 if (IsPending()) 86 if (IsPending())
86 connection_completed_callbacks_.push_back(callback); 87 connection_completed_callbacks_.push_back(callback);
87 else 88 else
88 callback.Run(); 89 callback.Run();
89 } 90 }
90 91
91 bool ConnectionImpl::AllowsInterface(const std::string& interface_name) const { 92 bool ConnectionImpl::AllowsInterface(const std::string& interface_name) const {
92 return allow_all_interfaces_ || 93 return allow_all_interfaces_ ||
93 capability_request_.interfaces.count(interface_name); 94 capability_request_.interfaces.count(interface_name);
94 } 95 }
(...skipping 16 matching lines...) Expand all
111 void ConnectionImpl::OnConnectionCompleted(shell::mojom::ConnectResult result, 112 void ConnectionImpl::OnConnectionCompleted(shell::mojom::ConnectResult result,
112 const std::string& target_user_id, 113 const std::string& target_user_id,
113 uint32_t target_application_id) { 114 uint32_t target_application_id) {
114 DCHECK(State::PENDING == state_); 115 DCHECK(State::PENDING == state_);
115 116
116 result_ = result; 117 result_ = result;
117 state_ = result_ == shell::mojom::ConnectResult::SUCCEEDED ? 118 state_ = result_ == shell::mojom::ConnectResult::SUCCEEDED ?
118 State::CONNECTED : State::DISCONNECTED; 119 State::CONNECTED : State::DISCONNECTED;
119 remote_id_ = target_application_id; 120 remote_id_ = target_application_id;
120 remote_.set_user_id(target_user_id); 121 remote_.set_user_id(target_user_id);
121 std::vector<Closure> callbacks; 122 std::vector<mojo::Closure> callbacks;
122 callbacks.swap(connection_completed_callbacks_); 123 callbacks.swap(connection_completed_callbacks_);
123 for (auto callback : callbacks) 124 for (auto callback : callbacks)
124 callback.Run(); 125 callback.Run();
125 } 126 }
126 127
127 } // namespace internal 128 } // namespace internal
128 } // namespace mojo 129 } // namespace shell
OLDNEW
« no previous file with comments | « services/shell/public/cpp/lib/connection_impl.h ('k') | services/shell/public/cpp/lib/connector_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698