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

Side by Side Diff: chrome/browser/sync/notifier/communicator/ssl_socket_adapter.cc

Issue 598071: Really connect to the same server in FTP network transaction. (Closed)
Patch Set: updates Created 10 years, 10 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 | « chrome/browser/sync/notifier/communicator/ssl_socket_adapter.h ('k') | net/base/address_list.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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/sync/notifier/communicator/ssl_socket_adapter.h" 5 #include "chrome/browser/sync/notifier/communicator/ssl_socket_adapter.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/browser/net/url_request_context_getter.h" 9 #include "chrome/browser/net/url_request_context_getter.h"
10 #include "chrome/browser/profile.h" 10 #include "chrome/browser/profile.h"
11 #include "net/base/address_list.h"
11 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
12 #include "net/base/ssl_config_service.h" 13 #include "net/base/ssl_config_service.h"
14 #include "net/base/sys_addrinfo.h"
13 #include "net/socket/client_socket_factory.h" 15 #include "net/socket/client_socket_factory.h"
14 #include "net/url_request/url_request_context.h" 16 #include "net/url_request/url_request_context.h"
15 17
16 namespace notifier { 18 namespace notifier {
17 19
18 namespace { 20 namespace {
19 21
20 // Convert values from <errno.h> to values from "net/base/net_errors.h" 22 // Convert values from <errno.h> to values from "net/base/net_errors.h"
21 int MapPosixError(int err) { 23 int MapPosixError(int err) {
22 // There are numerous posix error codes, but these are the ones we thus far 24 // There are numerous posix error codes, but these are the ones we thus far
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 bool TransportSocket::IsConnected() const { 249 bool TransportSocket::IsConnected() const {
248 return (socket_->GetState() == talk_base::Socket::CS_CONNECTED); 250 return (socket_->GetState() == talk_base::Socket::CS_CONNECTED);
249 } 251 }
250 252
251 bool TransportSocket::IsConnectedAndIdle() const { 253 bool TransportSocket::IsConnectedAndIdle() const {
252 // Not implemented. 254 // Not implemented.
253 NOTREACHED(); 255 NOTREACHED();
254 return false; 256 return false;
255 } 257 }
256 258
257 int TransportSocket::GetPeerName(struct sockaddr* name, socklen_t* namelen) { 259 int TransportSocket::GetPeerAddress(net::AddressList* address) const {
258 talk_base::SocketAddress address = socket_->GetRemoteAddress(); 260 talk_base::SocketAddress socket_address = socket_->GetRemoteAddress();
259 address.ToSockAddr(reinterpret_cast<sockaddr_in *>(name)); 261
260 return 0; 262 // libjingle supports only IPv4 addresses.
263 sockaddr_in ipv4addr;
264 socket_address.ToSockAddr(&ipv4addr);
265
266 struct addrinfo ai;
267 memset(&ai, sizeof(ai), 0);
268 ai.ai_family = ipv4addr.sin_family;
269 ai.ai_socktype = SOCK_STREAM;
270 ai.ai_protocol = IPPROTO_TCP;
271 ai.ai_addr = reinterpret_cast<struct sockaddr*>(&ipv4addr);
272 ai.ai_addrlen = sizeof(ipv4addr);
273
274 address->Copy(&ai, false);
275 return net::OK;
261 } 276 }
262 277
263 int TransportSocket::Read(net::IOBuffer* buf, int buf_len, 278 int TransportSocket::Read(net::IOBuffer* buf, int buf_len,
264 net::CompletionCallback* callback) { 279 net::CompletionCallback* callback) {
265 DCHECK(buf); 280 DCHECK(buf);
266 DCHECK(!read_callback_); 281 DCHECK(!read_callback_);
267 DCHECK(!read_buffer_.get()); 282 DCHECK(!read_buffer_.get());
268 int result = socket_->Recv(buf->data(), buf_len); 283 int result = socket_->Recv(buf->data(), buf_len);
269 if (result < 0) { 284 if (result < 0) {
270 result = MapPosixError(socket_->GetError()); 285 result = MapPosixError(socket_->GetError());
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 } 377 }
363 } 378 }
364 callback->RunWithParams(Tuple1<int>(result)); 379 callback->RunWithParams(Tuple1<int>(result));
365 return true; 380 return true;
366 } else { 381 } else {
367 return false; 382 return false;
368 } 383 }
369 } 384 }
370 385
371 } // namespace notifier 386 } // namespace notifier
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/communicator/ssl_socket_adapter.h ('k') | net/base/address_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698