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

Side by Side Diff: blimp/net/engine_connection_manager.cc

Issue 2439403003: Refactor BlimpConnection to TCPConnection (Closed)
Patch Set: Sync merge Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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/message_port.h" 13 #include "blimp/net/message_port.h"
14 #include "blimp/net/tcp_engine_transport.h"
15 #include "net/base/ip_address.h"
14 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
15 17
16 namespace blimp { 18 namespace blimp {
17 19
18 EngineConnectionManager::EngineConnectionManager( 20 EngineConnectionManager::EngineConnectionManager(
19 ConnectionHandler* connection_handler) 21 ConnectionHandler* connection_handler, net::NetLog* net_log)
20 : connection_handler_(connection_handler) { 22 : connection_handler_(connection_handler), net_log_(net_log) {
21 DCHECK(connection_handler_); 23 DCHECK(connection_handler_);
22 } 24 }
23 25
24 EngineConnectionManager::~EngineConnectionManager() {} 26 EngineConnectionManager::~EngineConnectionManager() {}
25 27
26 void EngineConnectionManager::AddTransport( 28 void EngineConnectionManager::ConnectTransport(
27 std::unique_ptr<BlimpTransport> transport) { 29 const net::IPEndPoint& ip_endpoint, EngineTransportType transport_type) {
28 BlimpTransport* transport_ptr = transport.get(); 30 switch (transport_type) {
29 transports_.push_back(std::move(transport)); 31 case EngineTransportType::TCP: {
30 Connect(transport_ptr); 32 transport_ = base::MakeUnique<TCPEngineTransport>(ip_endpoint, net_log_);
31 } 33 break;
34 }
32 35
33 void EngineConnectionManager::Connect(BlimpTransport* transport) { 36 case EngineTransportType::GRPC: {
34 transport->Connect(base::Bind(&EngineConnectionManager::OnConnectResult, 37 LOG(FATAL) << "gRPC support not yet implemented.";
35 base::Unretained(this), 38 // TODO(perumaal): Unimplemented as yet.
36 base::Unretained(transport))); 39 // transport_ =
40 // base::MakeUnique<GrpcEngineTransport>(ip_endpoint.ToString());
41 break;
42 }
43 }
44
45 transport_->Connect(base::Bind(&EngineConnectionManager::OnConnectResult,
46 base::Unretained(this),
47 base::Unretained(transport_.get())));
37 } 48 }
38 49
39 void EngineConnectionManager::OnConnectResult(BlimpTransport* transport, 50 void EngineConnectionManager::OnConnectResult(BlimpTransport* transport,
40 int result) { 51 int result) {
41 CHECK_EQ(net::OK, result) << "Transport failure:" << transport->GetName(); 52 CHECK_EQ(net::OK, result) << "Transport failure:" << transport->GetName();
42 connection_handler_->HandleConnection( 53 connection_handler_->HandleConnection(transport->MakeConnection());
43 base::MakeUnique<BlimpConnection>(transport->TakeMessagePort()));
44 Connect(transport);
45 } 54 }
46 55
47 } // namespace blimp 56 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698