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

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

Issue 2080083002: Revert of Deletes mojo::Callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « services/shell/public/cpp/lib/connection_impl.h ('k') | services/shell/public/cpp/shell_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698