OLD | NEW |
---|---|
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 // TODO(ukai): code is similar with http_network_transaction.cc. We should | 5 // TODO(ukai): code is similar with http_network_transaction.cc. We should |
6 // think about ways to share code, if possible. | 6 // think about ways to share code, if possible. |
7 | 7 |
8 #include "net/socket_stream/socket_stream.h" | 8 #include "net/socket_stream/socket_stream.h" |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 29 matching lines...) Expand all Loading... | |
40 } | 40 } |
41 | 41 |
42 SocketStream::SocketStream(const GURL& url, Delegate* delegate) | 42 SocketStream::SocketStream(const GURL& url, Delegate* delegate) |
43 : load_log_(new net::LoadLog(kMaxNumLoadLogEntries)), | 43 : load_log_(new net::LoadLog(kMaxNumLoadLogEntries)), |
44 url_(url), | 44 url_(url), |
45 delegate_(delegate), | 45 delegate_(delegate), |
46 max_pending_send_allowed_(kMaxPendingSendAllowed), | 46 max_pending_send_allowed_(kMaxPendingSendAllowed), |
47 next_state_(STATE_NONE), | 47 next_state_(STATE_NONE), |
48 factory_(ClientSocketFactory::GetDefaultFactory()), | 48 factory_(ClientSocketFactory::GetDefaultFactory()), |
49 proxy_mode_(kDirectConnection), | 49 proxy_mode_(kDirectConnection), |
50 proxy_url_(url), | |
50 pac_request_(NULL), | 51 pac_request_(NULL), |
51 ALLOW_THIS_IN_INITIALIZER_LIST( | 52 ALLOW_THIS_IN_INITIALIZER_LIST( |
52 io_callback_(this, &SocketStream::OnIOCompleted)), | 53 io_callback_(this, &SocketStream::OnIOCompleted)), |
53 ALLOW_THIS_IN_INITIALIZER_LIST( | 54 ALLOW_THIS_IN_INITIALIZER_LIST( |
54 read_callback_(this, &SocketStream::OnReadCompleted)), | 55 read_callback_(this, &SocketStream::OnReadCompleted)), |
55 ALLOW_THIS_IN_INITIALIZER_LIST( | 56 ALLOW_THIS_IN_INITIALIZER_LIST( |
56 write_callback_(this, &SocketStream::OnWriteCompleted)), | 57 write_callback_(this, &SocketStream::OnWriteCompleted)), |
57 read_buf_(NULL), | 58 read_buf_(NULL), |
58 write_buf_(NULL), | 59 write_buf_(NULL), |
59 current_write_buf_(NULL), | 60 current_write_buf_(NULL), |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 LoadLog::EndEvent(load_log_, LoadLog::TYPE_SOCKET_STREAM_CONNECT); | 408 LoadLog::EndEvent(load_log_, LoadLog::TYPE_SOCKET_STREAM_CONNECT); |
408 } | 409 } |
409 } while (result != ERR_IO_PENDING); | 410 } while (result != ERR_IO_PENDING); |
410 } | 411 } |
411 | 412 |
412 int SocketStream::DoResolveProxy() { | 413 int SocketStream::DoResolveProxy() { |
413 DCHECK(!pac_request_); | 414 DCHECK(!pac_request_); |
414 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | 415 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; |
415 | 416 |
416 return proxy_service()->ResolveProxy( | 417 return proxy_service()->ResolveProxy( |
417 url_, &proxy_info_, &io_callback_, &pac_request_, load_log_); | 418 proxy_url_, &proxy_info_, &io_callback_, &pac_request_, load_log_); |
418 } | 419 } |
419 | 420 |
420 int SocketStream::DoResolveProxyComplete(int result) { | 421 int SocketStream::DoResolveProxyComplete(int result) { |
421 next_state_ = STATE_RESOLVE_HOST; | 422 next_state_ = STATE_RESOLVE_HOST; |
422 | 423 |
423 pac_request_ = NULL; | 424 pac_request_ = NULL; |
424 if (result != OK) { | 425 if (result != OK) { |
425 LOG(ERROR) << "Failed to resolve proxy: " << result; | 426 LOG(ERROR) << "Failed to resolve proxy: " << result; |
426 if (delegate_) | 427 if (delegate_) |
427 delegate_->OnError(this, result); | 428 delegate_->OnError(this, result); |
428 proxy_info_.UseDirect(); | 429 proxy_info_.UseDirect(); |
429 } | 430 } |
431 if (proxy_info_.is_direct()) { | |
432 // If proxy was not found for original URL (ie. websocket URL), | |
tyoshino (SeeGerritForStatus)
2009/11/16 07:33:49
i.e.
| |
433 // try again with https URL, like Safari implementation. | |
434 // Note that we don't want to use http proxy, because we'll use tunnel | |
435 // proxy using CONNECT method, which is used by https proxy. | |
436 if (!proxy_url_.SchemeIs("https")) { | |
437 GURL::Replacements repl; | |
438 repl.SetSchemeStr("https"); | |
439 proxy_url_ = url_.ReplaceComponents(repl); | |
440 DLOG(INFO) << "Try https proxy: " << proxy_url_; | |
441 next_state_ = STATE_RESOLVE_PROXY; | |
442 return OK; | |
443 } | |
444 } | |
430 | 445 |
431 return OK; | 446 return OK; |
432 } | 447 } |
433 | 448 |
434 int SocketStream::DoResolveHost() { | 449 int SocketStream::DoResolveHost() { |
435 next_state_ = STATE_RESOLVE_HOST_COMPLETE; | 450 next_state_ = STATE_RESOLVE_HOST_COMPLETE; |
436 | 451 |
437 if (proxy_info_.is_direct()) | 452 if (proxy_info_.is_direct()) |
438 proxy_mode_ = kDirectConnection; | 453 proxy_mode_ = kDirectConnection; |
439 else if (proxy_info_.proxy_server().is_socks()) | 454 else if (proxy_info_.proxy_server().is_socks()) |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
881 return context_->proxy_service(); | 896 return context_->proxy_service(); |
882 } | 897 } |
883 | 898 |
884 void SocketStream::GetInfoForTracker( | 899 void SocketStream::GetInfoForTracker( |
885 RequestTracker<SocketStream>::RecentRequestInfo* info) const { | 900 RequestTracker<SocketStream>::RecentRequestInfo* info) const { |
886 info->original_url = url_; | 901 info->original_url = url_; |
887 info->load_log = load_log_; | 902 info->load_log = load_log_; |
888 } | 903 } |
889 | 904 |
890 } // namespace net | 905 } // namespace net |
OLD | NEW |