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

Side by Side Diff: chrome/browser/devtools/device/adb/adb_client_socket.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/devtools/device/adb/adb_client_socket.h" 5 #include "chrome/browser/devtools/device/adb/adb_client_socket.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "net/base/ip_address.h" 18 #include "net/base/ip_address.h"
19 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
20 #include "net/log/net_log_source.h"
20 #include "net/socket/tcp_client_socket.h" 21 #include "net/socket/tcp_client_socket.h"
21 22
22 namespace { 23 namespace {
23 24
24 const int kBufferSize = 16 * 1024; 25 const int kBufferSize = 16 * 1024;
25 const char kOkayResponse[] = "OKAY"; 26 const char kOkayResponse[] = "OKAY";
26 const char kHostTransportCommand[] = "host:transport:%s"; 27 const char kHostTransportCommand[] = "host:transport:%s";
27 const char kLocalhost[] = "127.0.0.1"; 28 const char kLocalhost[] = "127.0.0.1";
28 29
29 std::string EncodeMessage(const std::string& message) { 30 std::string EncodeMessage(const std::string& message) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 void AdbClientSocket::Connect(const net::CompletionCallback& callback) { 178 void AdbClientSocket::Connect(const net::CompletionCallback& callback) {
178 net::IPAddress ip_address; 179 net::IPAddress ip_address;
179 if (!ip_address.AssignFromIPLiteral(host_)) { 180 if (!ip_address.AssignFromIPLiteral(host_)) {
180 callback.Run(net::ERR_FAILED); 181 callback.Run(net::ERR_FAILED);
181 return; 182 return;
182 } 183 }
183 184
184 net::AddressList address_list = 185 net::AddressList address_list =
185 net::AddressList::CreateFromIPAddress(ip_address, port_); 186 net::AddressList::CreateFromIPAddress(ip_address, port_);
186 socket_.reset(new net::TCPClientSocket(address_list, NULL, NULL, 187 socket_.reset(new net::TCPClientSocket(address_list, NULL, NULL,
187 net::NetLog::Source())); 188 net::NetLogSource()));
188 int result = socket_->Connect(callback); 189 int result = socket_->Connect(callback);
189 if (result != net::ERR_IO_PENDING) 190 if (result != net::ERR_IO_PENDING)
190 callback.Run(result); 191 callback.Run(result);
191 } 192 }
192 193
193 void AdbClientSocket::SendCommand(const std::string& command, 194 void AdbClientSocket::SendCommand(const std::string& command,
194 bool is_void, 195 bool is_void,
195 const CommandCallback& callback) { 196 const CommandCallback& callback) {
196 scoped_refptr<net::StringIOBuffer> request_buffer = 197 scoped_refptr<net::StringIOBuffer> request_buffer =
197 new net::StringIOBuffer(EncodeMessage(command)); 198 new net::StringIOBuffer(EncodeMessage(command));
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 base::Unretained(this), 295 base::Unretained(this),
295 callback, 296 callback,
296 new_response, 297 new_response,
297 response_buffer, 298 response_buffer,
298 bytes_left)); 299 bytes_left));
299 if (result > 0) 300 if (result > 0)
300 OnResponseData(callback, new_response, response_buffer, bytes_left, result); 301 OnResponseData(callback, new_response, response_buffer, bytes_left, result);
301 else if (result != net::ERR_IO_PENDING) 302 else if (result != net::ERR_IO_PENDING)
302 callback.Run(net::OK, new_response); 303 callback.Run(net::OK, new_response);
303 } 304 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698