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

Unified Diff: remoting/host/security_key/security_key_ipc_client.cc

Issue 2596393002: Update IPC message handling for SecurityKeyIpcClient class (Closed)
Patch Set: Addressing CR Feedback Created 4 years 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/security_key/security_key_ipc_client.cc
diff --git a/remoting/host/security_key/security_key_ipc_client.cc b/remoting/host/security_key/security_key_ipc_client.cc
index 994f92ef231005319d07bba22c8a3451d94f294a..3b6b4058374725d8bf890fc08ed00db54fadd4eb 100644
--- a/remoting/host/security_key/security_key_ipc_client.cc
+++ b/remoting/host/security_key/security_key_ipc_client.cc
@@ -41,8 +41,8 @@ void SecurityKeyIpcClient::EstablishIpcConnection(
const ConnectedCallback& connected_callback,
const base::Closure& connection_error_callback) {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(!connected_callback.is_null());
- DCHECK(!connection_error_callback.is_null());
+ DCHECK(connected_callback);
+ DCHECK(connection_error_callback);
DCHECK(!ipc_channel_);
connected_callback_ = connected_callback;
@@ -56,14 +56,14 @@ bool SecurityKeyIpcClient::SendSecurityKeyRequest(
const ResponseCallback& response_callback) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!request_payload.empty());
- DCHECK(!response_callback.is_null());
+ DCHECK(response_callback);
if (!ipc_channel_) {
LOG(ERROR) << "Request made before IPC connection was established.";
return false;
}
- if (!response_callback_.is_null()) {
+ if (response_callback_) {
LOG(ERROR)
<< "Request made while waiting for a response to a previous request.";
return false;
@@ -131,7 +131,7 @@ void SecurityKeyIpcClient::OnChannelConnected(int32_t peer_pid) {
void SecurityKeyIpcClient::OnChannelError() {
DCHECK(thread_checker_.CalledOnValidThread());
- if (!connection_error_callback_.is_null()) {
+ if (connection_error_callback_) {
base::ResetAndReturn(&connection_error_callback_).Run();
}
}
@@ -139,26 +139,41 @@ void SecurityKeyIpcClient::OnChannelError() {
void SecurityKeyIpcClient::OnSecurityKeyResponse(
const std::string& response_data) {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(!connection_error_callback_.is_null());
if (!response_data.empty()) {
base::ResetAndReturn(&response_callback_).Run(response_data);
} else {
LOG(ERROR) << "Invalid response received";
- base::ResetAndReturn(&connection_error_callback_).Run();
+ if (connection_error_callback_) {
+ base::ResetAndReturn(&connection_error_callback_).Run();
+ }
}
}
void SecurityKeyIpcClient::OnConnectionReady() {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(!connected_callback_.is_null());
+
+ if (!connected_callback_) {
+ LOG(ERROR) << "Unexpected ConnectionReady message received.";
+ if (connection_error_callback_) {
+ base::ResetAndReturn(&connection_error_callback_).Run();
+ }
+ return;
+ }
base::ResetAndReturn(&connected_callback_).Run(/*connection_usable=*/true);
}
void SecurityKeyIpcClient::OnInvalidSession() {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(!connected_callback_.is_null());
+
+ if (!connected_callback_) {
+ LOG(ERROR) << "Unexpected InvalidSession message received.";
+ if (connection_error_callback_) {
+ base::ResetAndReturn(&connection_error_callback_).Run();
+ }
+ return;
+ }
base::ResetAndReturn(&connected_callback_).Run(/*connection_usable=*/false);
}
@@ -170,7 +185,7 @@ void SecurityKeyIpcClient::ConnectToIpcChannel() {
CloseIpcConnection();
if (!channel_handle_.is_valid() && !CheckForSecurityKeyIpcServerChannel()) {
- if (!connection_error_callback_.is_null()) {
+ if (connection_error_callback_) {
base::ResetAndReturn(&connection_error_callback_).Run();
}
return;
@@ -184,7 +199,7 @@ void SecurityKeyIpcClient::ConnectToIpcChannel() {
}
ipc_channel_.reset();
- if (!connection_error_callback_.is_null()) {
+ if (connection_error_callback_) {
base::ResetAndReturn(&connection_error_callback_).Run();
}
}
« 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