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

Side by Side Diff: remoting/host/security_key/security_key_ipc_client.cc

Issue 2596393002: Update IPC message handling for SecurityKeyIpcClient class (Closed)
Patch Set: Removing unnecessary patchset dependency Created 3 years, 12 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
« no previous file with comments | « no previous file | remoting/host/security_key/security_key_ipc_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "remoting/host/security_key/security_key_ipc_client.h" 5 #include "remoting/host/security_key/security_key_ipc_client.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 if (!response_data.empty()) { 144 if (!response_data.empty()) {
145 base::ResetAndReturn(&response_callback_).Run(response_data); 145 base::ResetAndReturn(&response_callback_).Run(response_data);
146 } else { 146 } else {
147 LOG(ERROR) << "Invalid response received"; 147 LOG(ERROR) << "Invalid response received";
148 base::ResetAndReturn(&connection_error_callback_).Run(); 148 base::ResetAndReturn(&connection_error_callback_).Run();
149 } 149 }
150 } 150 }
151 151
152 void SecurityKeyIpcClient::OnConnectionReady() { 152 void SecurityKeyIpcClient::OnConnectionReady() {
153 DCHECK(thread_checker_.CalledOnValidThread()); 153 DCHECK(thread_checker_.CalledOnValidThread());
154 DCHECK(!connected_callback_.is_null());
155 154
156 base::ResetAndReturn(&connected_callback_).Run(/*connection_usable=*/true); 155 if (!connected_callback_.is_null()) {
156 base::ResetAndReturn(&connected_callback_).Run(/*connection_usable=*/true);
157 } else {
Sergey Ulanov 2016/12/22 23:01:36 nit: It would be a bit more readable if you handle
joedow 2016/12/22 23:39:00 Done.
158 LOG(ERROR) << "Unexpected ConnectionReady message received.";
159 if (!connection_error_callback_.is_null()) {
Sergey Ulanov 2016/12/22 23:01:36 if (connection_error_callback_)
joedow 2016/12/22 23:39:00 I've updated this line and the rest of the file to
160 base::ResetAndReturn(&connection_error_callback_).Run();
161 }
162 }
157 } 163 }
158 164
159 void SecurityKeyIpcClient::OnInvalidSession() { 165 void SecurityKeyIpcClient::OnInvalidSession() {
160 DCHECK(thread_checker_.CalledOnValidThread()); 166 DCHECK(thread_checker_.CalledOnValidThread());
161 DCHECK(!connected_callback_.is_null());
162 167
163 base::ResetAndReturn(&connected_callback_).Run(/*connection_usable=*/false); 168 if (!connected_callback_.is_null()) {
169 base::ResetAndReturn(&connected_callback_).Run(/*connection_usable=*/false);
170 } else {
171 LOG(ERROR) << "Unexpected InvalidSession message received.";
172 if (!connection_error_callback_.is_null()) {
173 base::ResetAndReturn(&connection_error_callback_).Run();
174 }
175 }
164 } 176 }
165 177
166 void SecurityKeyIpcClient::ConnectToIpcChannel() { 178 void SecurityKeyIpcClient::ConnectToIpcChannel() {
167 DCHECK(thread_checker_.CalledOnValidThread()); 179 DCHECK(thread_checker_.CalledOnValidThread());
168 180
169 // Verify that any existing IPC connection has been closed. 181 // Verify that any existing IPC connection has been closed.
170 CloseIpcConnection(); 182 CloseIpcConnection();
171 183
172 if (!channel_handle_.is_valid() && !CheckForSecurityKeyIpcServerChannel()) { 184 if (!channel_handle_.is_valid() && !CheckForSecurityKeyIpcServerChannel()) {
173 if (!connection_error_callback_.is_null()) { 185 if (!connection_error_callback_.is_null()) {
174 base::ResetAndReturn(&connection_error_callback_).Run(); 186 base::ResetAndReturn(&connection_error_callback_).Run();
175 } 187 }
176 return; 188 return;
177 } 189 }
178 190
179 ipc_channel_ = IPC::Channel::CreateClient( 191 ipc_channel_ = IPC::Channel::CreateClient(
180 mojo::edk::ConnectToPeerProcess(std::move(channel_handle_)).release(), 192 mojo::edk::ConnectToPeerProcess(std::move(channel_handle_)).release(),
181 this); 193 this);
182 if (ipc_channel_->Connect()) { 194 if (ipc_channel_->Connect()) {
183 return; 195 return;
184 } 196 }
185 ipc_channel_.reset(); 197 ipc_channel_.reset();
186 198
187 if (!connection_error_callback_.is_null()) { 199 if (!connection_error_callback_.is_null()) {
188 base::ResetAndReturn(&connection_error_callback_).Run(); 200 base::ResetAndReturn(&connection_error_callback_).Run();
189 } 201 }
190 } 202 }
191 203
192 } // namespace remoting 204 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/host/security_key/security_key_ipc_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698