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_connection_manager.h" | 5 #include "blimp/net/engine_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" |
11 #include "blimp/net/blimp_connection.h" | 11 #include "blimp/net/blimp_connection.h" |
12 #include "blimp/net/blimp_transport.h" | 12 #include "blimp/net/blimp_transport.h" |
| 13 #include "blimp/net/grpc_engine_transport.h" |
13 #include "blimp/net/message_port.h" | 14 #include "blimp/net/message_port.h" |
14 #include "blimp/net/tcp_engine_transport.h" | 15 #include "blimp/net/tcp_engine_transport.h" |
15 #include "net/base/ip_address.h" | 16 #include "net/base/ip_address.h" |
16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
17 | 18 |
18 namespace blimp { | 19 namespace blimp { |
19 | 20 |
20 EngineConnectionManager::EngineConnectionManager( | 21 EngineConnectionManager::EngineConnectionManager( |
21 ConnectionHandler* connection_handler, | 22 ConnectionHandler* connection_handler, |
22 net::NetLog* net_log) | 23 net::NetLog* net_log) |
23 : connection_handler_(connection_handler), net_log_(net_log) { | 24 : connection_handler_(connection_handler), net_log_(net_log) { |
24 DCHECK(connection_handler_); | 25 DCHECK(connection_handler_); |
25 } | 26 } |
26 | 27 |
27 EngineConnectionManager::~EngineConnectionManager() {} | 28 EngineConnectionManager::~EngineConnectionManager() {} |
28 | 29 |
29 void EngineConnectionManager::ConnectTransport( | 30 void EngineConnectionManager::ConnectTransport( |
30 net::IPEndPoint* ip_endpoint, | 31 AssignmentOptions* assignment_options, |
31 EngineTransportType transport_type) { | 32 EngineTransportType transport_type) { |
32 switch (transport_type) { | 33 switch (transport_type) { |
33 case EngineTransportType::TCP: { | 34 case EngineTransportType::TCP: { |
34 transport_ = base::MakeUnique<TCPEngineTransport>(*ip_endpoint, net_log_); | 35 transport_ = base::MakeUnique<TCPEngineTransport>( |
| 36 assignment_options->engine_endpoint, net_log_); |
35 break; | 37 break; |
36 } | 38 } |
37 | 39 |
38 case EngineTransportType::GRPC: { | 40 case EngineTransportType::GRPC: { |
39 NOTIMPLEMENTED(); | 41 transport_ = base::MakeUnique<GrpcEngineTransport>(*assignment_options); |
40 // TODO(perumaal): Unimplemented as yet. | |
41 // transport_ = | |
42 // base::MakeUnique<GrpcEngineTransport>(ip_endpoint.ToString()); | |
43 break; | 42 break; |
44 } | 43 } |
45 } | 44 } |
46 | 45 |
47 transport_->Connect(base::Bind(&EngineConnectionManager::OnConnectResult, | 46 transport_->Connect(base::Bind(&EngineConnectionManager::OnConnectResult, |
48 base::Unretained(this), | 47 base::Unretained(this), |
49 base::Unretained(transport_.get()))); | 48 base::Unretained(transport_.get()))); |
50 transport_->GetLocalAddress(ip_endpoint); | 49 transport_->GetAssignmentOptions(assignment_options); |
| 50 |
| 51 DVLOG(3) << "Assigner options: ip addr = " |
| 52 << assignment_options->engine_endpoint.ToString() |
| 53 << ", file_descriptor = " << assignment_options->file_descriptor; |
51 } | 54 } |
52 | 55 |
53 void EngineConnectionManager::OnConnectResult(BlimpTransport* transport, | 56 void EngineConnectionManager::OnConnectResult(BlimpTransport* transport, |
54 int result) { | 57 int result) { |
55 CHECK_EQ(net::OK, result) << "Transport failure:" << transport->GetName(); | 58 CHECK_EQ(net::OK, result) << "Transport failure:" << transport->GetName(); |
56 connection_handler_->HandleConnection(transport->MakeConnection()); | 59 connection_handler_->HandleConnection(transport->MakeConnection()); |
57 } | 60 } |
58 | 61 |
59 } // namespace blimp | 62 } // namespace blimp |
OLD | NEW |