| 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/client_connection_manager.h" | 5 #include "blimp/net/client_connection_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "blimp/common/create_blimp_message.h" | 8 #include "blimp/common/create_blimp_message.h" |
| 9 #include "blimp/common/proto/blimp_message.pb.h" | 9 #include "blimp/common/proto/blimp_message.pb.h" |
| 10 #include "blimp/common/protocol_version.h" | 10 #include "blimp/common/version_info.h" |
| 11 #include "blimp/net/blimp_connection.h" | 11 #include "blimp/net/blimp_connection.h" |
| 12 #include "blimp/net/blimp_message_processor.h" | 12 #include "blimp/net/blimp_message_processor.h" |
| 13 #include "blimp/net/blimp_transport.h" | 13 #include "blimp/net/blimp_transport.h" |
| 14 #include "blimp/net/browser_connection_handler.h" | 14 #include "blimp/net/browser_connection_handler.h" |
| 15 #include "blimp/net/connection_handler.h" | 15 #include "blimp/net/connection_handler.h" |
| 16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 17 | 17 |
| 18 namespace blimp { | 18 namespace blimp { |
| 19 | 19 |
| 20 ClientConnectionManager::ClientConnectionManager( | 20 ClientConnectionManager::ClientConnectionManager( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 DVLOG(1) << "Transport " << transport->GetName() | 61 DVLOG(1) << "Transport " << transport->GetName() |
| 62 << " failed to connect:" << net::ErrorToString(result); | 62 << " failed to connect:" << net::ErrorToString(result); |
| 63 Connect(transport_index + 1); | 63 Connect(transport_index + 1); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 void ClientConnectionManager::SendAuthenticationMessage( | 67 void ClientConnectionManager::SendAuthenticationMessage( |
| 68 std::unique_ptr<BlimpConnection> connection) { | 68 std::unique_ptr<BlimpConnection> connection) { |
| 69 DVLOG(1) << "Sending authentication message."; | 69 DVLOG(1) << "Sending authentication message."; |
| 70 connection->GetOutgoingMessageProcessor()->ProcessMessage( | 70 connection->GetOutgoingMessageProcessor()->ProcessMessage( |
| 71 CreateStartConnectionMessage(client_token_, kProtocolVersion), | 71 CreateStartConnectionMessage(client_token_, GetProtocolVersion()), |
| 72 base::Bind(&ClientConnectionManager::OnAuthenticationMessageSent, | 72 base::Bind(&ClientConnectionManager::OnAuthenticationMessageSent, |
| 73 weak_factory_.GetWeakPtr(), | 73 weak_factory_.GetWeakPtr(), |
| 74 base::Passed(std::move(connection)))); | 74 base::Passed(std::move(connection)))); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void ClientConnectionManager::OnAuthenticationMessageSent( | 77 void ClientConnectionManager::OnAuthenticationMessageSent( |
| 78 std::unique_ptr<BlimpConnection> connection, | 78 std::unique_ptr<BlimpConnection> connection, |
| 79 int result) { | 79 int result) { |
| 80 DVLOG(1) << "AuthenticationMessageSent, result=" << result; | 80 DVLOG(1) << "AuthenticationMessageSent, result=" << result; |
| 81 if (result != net::OK) { | 81 if (result != net::OK) { |
| 82 // If a write error occurred, just throw away |connection|. | 82 // If a write error occurred, just throw away |connection|. |
| 83 // We don't need to propagate the error code here because the connection | 83 // We don't need to propagate the error code here because the connection |
| 84 // will already have done so via the ErrorObserver object. | 84 // will already have done so via the ErrorObserver object. |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 connection_handler_->HandleConnection(std::move(connection)); | 87 connection_handler_->HandleConnection(std::move(connection)); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void ClientConnectionManager::OnConnectionError(int error) { | 90 void ClientConnectionManager::OnConnectionError(int error) { |
| 91 // TODO(kmarshall): Replace this with actual reconnection logic. | 91 // TODO(kmarshall): Replace this with actual reconnection logic. |
| 92 VLOG(0) << "Connection dropped, error=" << error; | 92 VLOG(0) << "Connection dropped, error=" << error; |
| 93 Connect(); | 93 Connect(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace blimp | 96 } // namespace blimp |
| OLD | NEW |