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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_tcp_socket.cc

Issue 10909154: Remove PPAPI dependency on 'net'. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/pepper/pepper_tcp_socket.h" 5 #include "content/browser/renderer_host/pepper/pepper_tcp_socket.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 base::Bind(&PepperTCPSocket::OnResolveCompleted, base::Unretained(this)), 86 base::Bind(&PepperTCPSocket::OnResolveCompleted, base::Unretained(this)),
87 net::BoundNetLog()); 87 net::BoundNetLog());
88 if (result != net::ERR_IO_PENDING) 88 if (result != net::ERR_IO_PENDING)
89 OnResolveCompleted(result); 89 OnResolveCompleted(result);
90 } 90 }
91 91
92 void PepperTCPSocket::ConnectWithNetAddress( 92 void PepperTCPSocket::ConnectWithNetAddress(
93 const PP_NetAddress_Private& net_addr) { 93 const PP_NetAddress_Private& net_addr) {
94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
95 95
96 net::IPAddressNumber address;
97 int port;
96 if (connection_state_ != BEFORE_CONNECT || 98 if (connection_state_ != BEFORE_CONNECT ||
97 !NetAddressPrivateImpl::NetAddressToAddressList(net_addr, 99 !NetAddressPrivateImpl::NetAddressToIPEndPoint(net_addr,
98 &address_list_)) { 100 &address,
101 &port)) {
99 SendConnectACKError(); 102 SendConnectACKError();
100 return; 103 return;
101 } 104 }
102 105
106 // Copy the single IPEndPoint to address_list_.
107 address_list_.clear();
108 address_list_.push_back(net::IPEndPoint(address, port));
103 connection_state_ = CONNECT_IN_PROGRESS; 109 connection_state_ = CONNECT_IN_PROGRESS;
104 StartConnect(address_list_); 110 StartConnect(address_list_);
105 } 111 }
106 112
107 void PepperTCPSocket::SSLHandshake( 113 void PepperTCPSocket::SSLHandshake(
108 const std::string& server_name, 114 const std::string& server_name,
109 uint16_t server_port, 115 uint16_t server_port,
110 const std::vector<std::vector<char> >& trusted_certs, 116 const std::vector<std::vector<char> >& trusted_certs,
111 const std::vector<std::vector<char> >& untrusted_certs) { 117 const std::vector<std::vector<char> >& untrusted_certs) {
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 connection_state_ = BEFORE_CONNECT; 322 connection_state_ = BEFORE_CONNECT;
317 } else { 323 } else {
318 net::IPEndPoint ip_end_point_local; 324 net::IPEndPoint ip_end_point_local;
319 net::IPEndPoint ip_end_point_remote; 325 net::IPEndPoint ip_end_point_remote;
320 PP_NetAddress_Private local_addr = 326 PP_NetAddress_Private local_addr =
321 NetAddressPrivateImpl::kInvalidNetAddress; 327 NetAddressPrivateImpl::kInvalidNetAddress;
322 PP_NetAddress_Private remote_addr = 328 PP_NetAddress_Private remote_addr =
323 NetAddressPrivateImpl::kInvalidNetAddress; 329 NetAddressPrivateImpl::kInvalidNetAddress;
324 330
325 if (socket_->GetLocalAddress(&ip_end_point_local) != net::OK || 331 if (socket_->GetLocalAddress(&ip_end_point_local) != net::OK ||
326 !NetAddressPrivateImpl::IPEndPointToNetAddress(ip_end_point_local, 332 !NetAddressPrivateImpl::IPEndPointToNetAddress(
327 &local_addr) || 333 ip_end_point_local.address(),
334 ip_end_point_local.port(),
335 &local_addr) ||
328 socket_->GetPeerAddress(&ip_end_point_remote) != net::OK || 336 socket_->GetPeerAddress(&ip_end_point_remote) != net::OK ||
329 !NetAddressPrivateImpl::IPEndPointToNetAddress(ip_end_point_remote, 337 !NetAddressPrivateImpl::IPEndPointToNetAddress(
330 &remote_addr)) { 338 ip_end_point_remote.address(),
339 ip_end_point_remote.port(),
340 &remote_addr)) {
331 SendConnectACKError(); 341 SendConnectACKError();
332 connection_state_ = BEFORE_CONNECT; 342 connection_state_ = BEFORE_CONNECT;
333 } else { 343 } else {
334 manager_->Send(new PpapiMsg_PPBTCPSocket_ConnectACK( 344 manager_->Send(new PpapiMsg_PPBTCPSocket_ConnectACK(
335 routing_id_, plugin_dispatcher_id_, socket_id_, true, 345 routing_id_, plugin_dispatcher_id_, socket_id_, true,
336 local_addr, remote_addr)); 346 local_addr, remote_addr));
337 connection_state_ = CONNECTED; 347 connection_state_ = CONNECTED;
338 } 348 }
339 } 349 }
340 } 350 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 DCHECK(write_buffer_base_.get()); 408 DCHECK(write_buffer_base_.get());
399 DCHECK(write_buffer_.get()); 409 DCHECK(write_buffer_.get());
400 DCHECK_GT(write_buffer_->BytesRemaining(), 0); 410 DCHECK_GT(write_buffer_->BytesRemaining(), 0);
401 411
402 int result = socket_->Write(write_buffer_, write_buffer_->BytesRemaining(), 412 int result = socket_->Write(write_buffer_, write_buffer_->BytesRemaining(),
403 base::Bind(&PepperTCPSocket::OnWriteCompleted, 413 base::Bind(&PepperTCPSocket::OnWriteCompleted,
404 base::Unretained(this))); 414 base::Unretained(this)));
405 if (result != net::ERR_IO_PENDING) 415 if (result != net::ERR_IO_PENDING)
406 OnWriteCompleted(result); 416 OnWriteCompleted(result);
407 } 417 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698