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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 base::Unretained(this), transport_index)); | 50 base::Unretained(this), transport_index)); |
51 } else { | 51 } else { |
52 // TODO(haibinlu): add an error reporting path out for this. | 52 // TODO(haibinlu): add an error reporting path out for this. |
53 LOG(WARNING) << "All transports failed to connect"; | 53 LOG(WARNING) << "All transports failed to connect"; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 void ClientConnectionManager::OnConnectResult(int transport_index, int result) { | 57 void ClientConnectionManager::OnConnectResult(int transport_index, int result) { |
58 DCHECK_NE(result, net::ERR_IO_PENDING); | 58 DCHECK_NE(result, net::ERR_IO_PENDING); |
59 const auto& transport = transports_[transport_index]; | 59 const auto& transport = transports_[transport_index]; |
60 DVLOG(3) << "OnConnectResult; result = " << result; | |
Garrett Casto
2016/10/25 18:33:50
Nit: Everything else in this file is DVLOG(1). If
perumaal
2016/10/25 23:02:39
Cool, good idea. thanks
| |
60 if (result == net::OK) { | 61 if (result == net::OK) { |
61 std::unique_ptr<BlimpConnection> connection = | 62 std::unique_ptr<BlimpConnection> connection = transport->MakeConnection(); |
62 base::MakeUnique<BlimpConnection>(transport->TakeMessagePort()); | |
63 connection->AddConnectionErrorObserver(this); | 63 connection->AddConnectionErrorObserver(this); |
64 SendAuthenticationMessage(std::move(connection)); | 64 SendAuthenticationMessage(std::move(connection)); |
65 } else { | 65 } else { |
66 DVLOG(1) << "Transport " << transport->GetName() | 66 DVLOG(1) << "Transport " << transport->GetName() |
67 << " failed to connect:" << net::ErrorToString(result); | 67 << " failed to connect:" << net::ErrorToString(result); |
68 Connect(transport_index + 1); | 68 Connect(transport_index + 1); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 void ClientConnectionManager::SendAuthenticationMessage( | 72 void ClientConnectionManager::SendAuthenticationMessage( |
73 std::unique_ptr<BlimpConnection> connection) { | 73 std::unique_ptr<BlimpConnection> connection) { |
74 DVLOG(1) << "Sending authentication message."; | 74 DVLOG(1) << "Sending authentication message."; |
75 connection->GetOutgoingMessageProcessor()->ProcessMessage( | 75 connection->GetOutgoingMessageProcessor()->ProcessMessage( |
76 CreateStartConnectionMessage(client_auth_token_, kProtocolVersion), | 76 CreateStartConnectionMessage(client_auth_token_, kProtocolVersion), |
77 base::Bind(&ClientConnectionManager::OnAuthenticationMessageSent, | 77 base::Bind(&ClientConnectionManager::OnAuthenticationMessageSent, |
78 weak_factory_.GetWeakPtr(), | 78 weak_factory_.GetWeakPtr(), |
79 base::Passed(std::move(connection)))); | 79 base::Passed(std::move(connection)))); |
80 } | 80 } |
81 | 81 |
82 void ClientConnectionManager::OnAuthenticationMessageSent( | 82 void ClientConnectionManager::OnAuthenticationMessageSent( |
83 std::unique_ptr<BlimpConnection> connection, | 83 std::unique_ptr<BlimpConnection> connection, int result) { |
84 int result) { | |
85 DVLOG(1) << "AuthenticationMessageSent, result=" << result; | 84 DVLOG(1) << "AuthenticationMessageSent, result=" << result; |
86 if (result != net::OK) { | 85 if (result != net::OK) { |
87 // If a write error occurred, just throw away |connection|. | 86 // If a write error occurred, just throw away |connection|. |
88 // We don't need to propagate the error code here because the connection | 87 // We don't need to propagate the error code here because the connection |
89 // will already have done so via the ErrorObserver object. | 88 // will already have done so via the ErrorObserver object. |
90 return; | 89 return; |
91 } | 90 } |
92 connection_handler_->HandleConnection(std::move(connection)); | 91 connection_handler_->HandleConnection(std::move(connection)); |
93 } | 92 } |
94 | 93 |
95 void ClientConnectionManager::OnConnectionError(int error) { | 94 void ClientConnectionManager::OnConnectionError(int error) { |
96 // TODO(kmarshall): implement reconnection logic. | 95 // TODO(kmarshall): implement reconnection logic. |
97 VLOG(0) << "Connection dropped, error=" << error; | 96 VLOG(0) << "Connection dropped, error=" << error; |
98 } | 97 } |
99 | 98 |
100 } // namespace blimp | 99 } // namespace blimp |
OLD | NEW |