| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "net/http/http_network_layer.h" | 5 #include "net/http/http_network_layer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/base/client_socket_factory.h" | 8 #include "net/base/client_socket_factory.h" |
| 9 #include "net/http/http_network_session.h" | 9 #include "net/http/http_network_session.h" |
| 10 #include "net/http/http_network_transaction.h" | 10 #include "net/http/http_network_transaction.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 //----------------------------------------------------------------------------- | 14 //----------------------------------------------------------------------------- |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 HttpTransactionFactory* HttpNetworkLayer::CreateFactory( | 17 HttpTransactionFactory* HttpNetworkLayer::CreateFactory( |
| 18 HostResolver* host_resolver, |
| 18 ProxyService* proxy_service) { | 19 ProxyService* proxy_service) { |
| 19 DCHECK(proxy_service); | 20 DCHECK(proxy_service); |
| 20 | 21 |
| 21 return new HttpNetworkLayer(proxy_service); | 22 return new HttpNetworkLayer(host_resolver, proxy_service); |
| 22 } | 23 } |
| 23 | 24 |
| 24 // static | 25 // static |
| 25 HttpTransactionFactory* HttpNetworkLayer::CreateFactory( | 26 HttpTransactionFactory* HttpNetworkLayer::CreateFactory( |
| 26 HttpNetworkSession* session) { | 27 HttpNetworkSession* session) { |
| 27 DCHECK(session); | 28 DCHECK(session); |
| 28 | 29 |
| 29 return new HttpNetworkLayer(session); | 30 return new HttpNetworkLayer(session); |
| 30 } | 31 } |
| 31 | 32 |
| 32 //----------------------------------------------------------------------------- | 33 //----------------------------------------------------------------------------- |
| 33 | 34 |
| 34 HttpNetworkLayer::HttpNetworkLayer(ProxyService* proxy_service) | 35 HttpNetworkLayer::HttpNetworkLayer(HostResolver* host_resolver, |
| 35 : proxy_service_(proxy_service), session_(NULL), suspended_(false) { | 36 ProxyService* proxy_service) |
| 37 : host_resolver_(host_resolver), |
| 38 proxy_service_(proxy_service), |
| 39 session_(NULL), |
| 40 suspended_(false) { |
| 36 DCHECK(proxy_service_); | 41 DCHECK(proxy_service_); |
| 37 } | 42 } |
| 38 | 43 |
| 39 HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session) | 44 HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session) |
| 40 : proxy_service_(NULL), session_(session), suspended_(false) { | 45 : proxy_service_(NULL), session_(session), suspended_(false) { |
| 41 DCHECK(session_.get()); | 46 DCHECK(session_.get()); |
| 42 } | 47 } |
| 43 | 48 |
| 44 HttpNetworkLayer::~HttpNetworkLayer() { | 49 HttpNetworkLayer::~HttpNetworkLayer() { |
| 45 } | 50 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 59 void HttpNetworkLayer::Suspend(bool suspend) { | 64 void HttpNetworkLayer::Suspend(bool suspend) { |
| 60 suspended_ = suspend; | 65 suspended_ = suspend; |
| 61 | 66 |
| 62 if (suspend && session_) | 67 if (suspend && session_) |
| 63 session_->connection_pool()->CloseIdleSockets(); | 68 session_->connection_pool()->CloseIdleSockets(); |
| 64 } | 69 } |
| 65 | 70 |
| 66 HttpNetworkSession* HttpNetworkLayer::GetSession() { | 71 HttpNetworkSession* HttpNetworkLayer::GetSession() { |
| 67 if (!session_) { | 72 if (!session_) { |
| 68 DCHECK(proxy_service_); | 73 DCHECK(proxy_service_); |
| 69 session_ = new HttpNetworkSession(proxy_service_, | 74 session_ = new HttpNetworkSession(host_resolver_, proxy_service_, |
| 70 ClientSocketFactory::GetDefaultFactory()); | 75 ClientSocketFactory::GetDefaultFactory()); |
| 71 } | 76 } |
| 72 return session_; | 77 return session_; |
| 73 } | 78 } |
| 74 | 79 |
| 75 } // namespace net | 80 } // namespace net |
| OLD | NEW |