OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/net/engine_authentication_handler.h" | 5 #include "blimp/net/engine_authentication_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 104 } |
105 | 105 |
106 void Authenticator::OnConnectionError(int error) { | 106 void Authenticator::OnConnectionError(int error) { |
107 DVLOG(1) << "Connection error before authenticated " | 107 DVLOG(1) << "Connection error before authenticated " |
108 << net::ErrorToString(error); | 108 << net::ErrorToString(error); |
109 OnConnectionAuthenticated(false); | 109 OnConnectionAuthenticated(false); |
110 } | 110 } |
111 | 111 |
112 void Authenticator::ProcessMessage(std::unique_ptr<BlimpMessage> message, | 112 void Authenticator::ProcessMessage(std::unique_ptr<BlimpMessage> message, |
113 const net::CompletionCallback& callback) { | 113 const net::CompletionCallback& callback) { |
114 if (message->type() == BlimpMessage::PROTOCOL_CONTROL && | 114 if (message->has_protocol_control() && |
115 message->protocol_control().type() == | 115 message->protocol_control().has_start_connection()) { |
116 ProtocolControlMessage::START_CONNECTION) { | |
117 bool token_match = | 116 bool token_match = |
118 client_token_ == | 117 client_token_ == |
119 message->protocol_control().start_connection().client_token(); | 118 message->protocol_control().start_connection().client_token(); |
120 DVLOG(1) << "Authentication challenge received: " | 119 DVLOG(1) << "Authentication challenge received: " |
121 << message->protocol_control().start_connection().client_token() | 120 << message->protocol_control().start_connection().client_token() |
122 << ", and token " | 121 << ", and token " |
123 << (token_match ? " matches" : " does not match"); | 122 << (token_match ? " matches" : " does not match"); |
124 OnConnectionAuthenticated(token_match); | 123 OnConnectionAuthenticated(token_match); |
125 } else { | 124 } else { |
126 DVLOG(1) << "Expected START_CONNECTION message, got " << *message | 125 DVLOG(1) << "Expected START_CONNECTION message, got " << *message |
(...skipping 18 matching lines...) Expand all Loading... |
145 | 144 |
146 void EngineAuthenticationHandler::HandleConnection( | 145 void EngineAuthenticationHandler::HandleConnection( |
147 std::unique_ptr<BlimpConnection> connection) { | 146 std::unique_ptr<BlimpConnection> connection) { |
148 // Authenticator manages its own lifetime. | 147 // Authenticator manages its own lifetime. |
149 new Authenticator(std::move(connection), | 148 new Authenticator(std::move(connection), |
150 connection_handler_weak_factory_.GetWeakPtr(), | 149 connection_handler_weak_factory_.GetWeakPtr(), |
151 client_token_); | 150 client_token_); |
152 } | 151 } |
153 | 152 |
154 } // namespace blimp | 153 } // namespace blimp |
OLD | NEW |