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

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

Issue 2333923004: Extracting NetLog inner classes into their own classes. (Closed)
Patch Set: Some nit fixes and better, impl-agnostic naming of net_log_parameters_callback_typedef.h -> net/log… Created 4 years, 2 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
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_engine_transport.h" 5 #include "blimp/net/tcp_engine_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/location.h" 12 #include "base/location.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "blimp/net/message_port.h" 15 #include "blimp/net/message_port.h"
16 #include "net/log/net_log_source.h"
16 #include "net/socket/stream_socket.h" 17 #include "net/socket/stream_socket.h"
17 #include "net/socket/tcp_server_socket.h" 18 #include "net/socket/tcp_server_socket.h"
18 19
19 namespace blimp { 20 namespace blimp {
20 21
21 TCPEngineTransport::TCPEngineTransport(const net::IPEndPoint& address, 22 TCPEngineTransport::TCPEngineTransport(const net::IPEndPoint& address,
22 net::NetLog* net_log) 23 net::NetLog* net_log)
23 : address_(address), net_log_(net_log) {} 24 : address_(address), net_log_(net_log) {}
24 25
25 TCPEngineTransport::~TCPEngineTransport() {} 26 TCPEngineTransport::~TCPEngineTransport() {}
26 27
27 void TCPEngineTransport::Connect(const net::CompletionCallback& callback) { 28 void TCPEngineTransport::Connect(const net::CompletionCallback& callback) {
28 DCHECK(!accepted_socket_); 29 DCHECK(!accepted_socket_);
29 DCHECK(!callback.is_null()); 30 DCHECK(!callback.is_null());
30 31
31 if (!server_socket_) { 32 if (!server_socket_) {
32 server_socket_.reset( 33 server_socket_.reset(
33 new net::TCPServerSocket(net_log_, net::NetLog::Source())); 34 new net::TCPServerSocket(net_log_, net::NetLogSource()));
34 int result = server_socket_->Listen(address_, 5); 35 int result = server_socket_->Listen(address_, 5);
35 if (result != net::OK) { 36 if (result != net::OK) {
36 server_socket_.reset(); 37 server_socket_.reset();
37 base::ThreadTaskRunnerHandle::Get()->PostTask( 38 base::ThreadTaskRunnerHandle::Get()->PostTask(
38 FROM_HERE, base::Bind(callback, result)); 39 FROM_HERE, base::Bind(callback, result));
39 return; 40 return;
40 } 41 }
41 } 42 }
42 43
43 net::CompletionCallback accept_callback = base::Bind( 44 net::CompletionCallback accept_callback = base::Bind(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 void TCPEngineTransport::OnTCPConnectAccepted(int result) { 77 void TCPEngineTransport::OnTCPConnectAccepted(int result) {
77 DCHECK_NE(net::ERR_IO_PENDING, result); 78 DCHECK_NE(net::ERR_IO_PENDING, result);
78 DCHECK(accepted_socket_); 79 DCHECK(accepted_socket_);
79 if (result != net::OK) { 80 if (result != net::OK) {
80 accepted_socket_.reset(); 81 accepted_socket_.reset();
81 } 82 }
82 base::ResetAndReturn(&connect_callback_).Run(result); 83 base::ResetAndReturn(&connect_callback_).Run(result);
83 } 84 }
84 85
85 } // namespace blimp 86 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698