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

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

Issue 2236093002: Decouple Blimp transport output from BlimpConnections using MessagePort. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@statistics-singleton
Patch Set: wez feedback Created 4 years, 3 months 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
« no previous file with comments | « blimp/net/tcp_client_transport.h ('k') | blimp/net/tcp_engine_transport.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/tcp_client_transport.h" 5 #include "blimp/net/tcp_client_transport.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/callback_helpers.h" 11 #include "base/callback_helpers.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "blimp/net/message_port.h"
14 #include "blimp/net/stream_socket_connection.h" 15 #include "blimp/net/stream_socket_connection.h"
15 #include "net/socket/client_socket_factory.h" 16 #include "net/socket/client_socket_factory.h"
16 #include "net/socket/stream_socket.h" 17 #include "net/socket/stream_socket.h"
17 #include "net/socket/tcp_client_socket.h" 18 #include "net/socket/tcp_client_socket.h"
18 19
19 namespace blimp { 20 namespace blimp {
20 21
21 TCPClientTransport::TCPClientTransport(const net::IPEndPoint& ip_endpoint, 22 TCPClientTransport::TCPClientTransport(const net::IPEndPoint& ip_endpoint,
22 net::NetLog* net_log) 23 net::NetLog* net_log)
23 : ip_endpoint_(ip_endpoint), 24 : ip_endpoint_(ip_endpoint),
(...skipping 19 matching lines...) Expand all
43 &TCPClientTransport::OnTCPConnectComplete, base::Unretained(this)); 44 &TCPClientTransport::OnTCPConnectComplete, base::Unretained(this));
44 45
45 int result = socket_->Connect(completion_callback); 46 int result = socket_->Connect(completion_callback);
46 if (result == net::ERR_IO_PENDING) { 47 if (result == net::ERR_IO_PENDING) {
47 return; 48 return;
48 } 49 }
49 50
50 OnTCPConnectComplete(result); 51 OnTCPConnectComplete(result);
51 } 52 }
52 53
53 std::unique_ptr<BlimpConnection> TCPClientTransport::TakeConnection() { 54 std::unique_ptr<MessagePort> TCPClientTransport::TakeMessagePort() {
54 DCHECK(connect_callback_.is_null()); 55 DCHECK(connect_callback_.is_null());
55 DCHECK(socket_); 56 DCHECK(socket_);
56 return base::MakeUnique<StreamSocketConnection>(std::move(socket_)); 57 return MessagePort::CreateForStreamSocketWithCompression(std::move(socket_));
57 } 58 }
58 59
59 const char* TCPClientTransport::GetName() const { 60 const char* TCPClientTransport::GetName() const {
60 return "TCP"; 61 return "TCP";
61 } 62 }
62 63
63 void TCPClientTransport::OnTCPConnectComplete(int result) { 64 void TCPClientTransport::OnTCPConnectComplete(int result) {
64 DCHECK_NE(net::ERR_IO_PENDING, result); 65 DCHECK_NE(net::ERR_IO_PENDING, result);
65 OnConnectComplete(result); 66 OnConnectComplete(result);
66 } 67 }
(...skipping 12 matching lines...) Expand all
79 void TCPClientTransport::SetSocket(std::unique_ptr<net::StreamSocket> socket) { 80 void TCPClientTransport::SetSocket(std::unique_ptr<net::StreamSocket> socket) {
80 DCHECK(socket); 81 DCHECK(socket);
81 socket_ = std::move(socket); 82 socket_ = std::move(socket);
82 } 83 }
83 84
84 net::ClientSocketFactory* TCPClientTransport::socket_factory() const { 85 net::ClientSocketFactory* TCPClientTransport::socket_factory() const {
85 return socket_factory_; 86 return socket_factory_;
86 } 87 }
87 88
88 } // namespace blimp 89 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/tcp_client_transport.h ('k') | blimp/net/tcp_engine_transport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698