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/flip/flip_framer.h" | 8 #include "net/flip/flip_framer.h" |
9 #include "net/flip/flip_network_transaction.h" | 9 #include "net/flip/flip_network_transaction.h" |
10 #include "net/flip/flip_session.h" | 10 #include "net/flip/flip_session.h" |
| 11 #include "net/flip/flip_session_pool.h" |
11 #include "net/http/http_network_session.h" | 12 #include "net/http/http_network_session.h" |
12 #include "net/http/http_network_transaction.h" | 13 #include "net/http/http_network_transaction.h" |
13 #include "net/socket/client_socket_factory.h" | 14 #include "net/socket/client_socket_factory.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 | 17 |
17 //----------------------------------------------------------------------------- | 18 //----------------------------------------------------------------------------- |
18 | 19 |
19 // static | 20 // static |
20 HttpTransactionFactory* HttpNetworkLayer::CreateFactory( | 21 HttpTransactionFactory* HttpNetworkLayer::CreateFactory( |
(...skipping 19 matching lines...) Expand all Loading... |
40 | 41 |
41 HttpNetworkLayer::HttpNetworkLayer(ClientSocketFactory* socket_factory, | 42 HttpNetworkLayer::HttpNetworkLayer(ClientSocketFactory* socket_factory, |
42 HostResolver* host_resolver, | 43 HostResolver* host_resolver, |
43 ProxyService* proxy_service, | 44 ProxyService* proxy_service, |
44 SSLConfigService* ssl_config_service) | 45 SSLConfigService* ssl_config_service) |
45 : socket_factory_(socket_factory), | 46 : socket_factory_(socket_factory), |
46 host_resolver_(host_resolver), | 47 host_resolver_(host_resolver), |
47 proxy_service_(proxy_service), | 48 proxy_service_(proxy_service), |
48 ssl_config_service_(ssl_config_service), | 49 ssl_config_service_(ssl_config_service), |
49 session_(NULL), | 50 session_(NULL), |
| 51 flip_session_pool_(NULL), |
50 suspended_(false) { | 52 suspended_(false) { |
51 DCHECK(proxy_service_); | 53 DCHECK(proxy_service_); |
52 DCHECK(ssl_config_service_.get()); | 54 DCHECK(ssl_config_service_.get()); |
53 } | 55 } |
54 | 56 |
55 HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session) | 57 HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session) |
56 : socket_factory_(ClientSocketFactory::GetDefaultFactory()), | 58 : socket_factory_(ClientSocketFactory::GetDefaultFactory()), |
57 ssl_config_service_(NULL), | 59 ssl_config_service_(NULL), |
58 session_(session), | 60 session_(session), |
| 61 flip_session_pool_(session->flip_session_pool()), |
59 suspended_(false) { | 62 suspended_(false) { |
60 DCHECK(session_.get()); | 63 DCHECK(session_.get()); |
61 } | 64 } |
62 | 65 |
63 HttpNetworkLayer::~HttpNetworkLayer() { | 66 HttpNetworkLayer::~HttpNetworkLayer() { |
64 } | 67 } |
65 | 68 |
66 int HttpNetworkLayer::CreateTransaction(scoped_ptr<HttpTransaction>* trans) { | 69 int HttpNetworkLayer::CreateTransaction(scoped_ptr<HttpTransaction>* trans) { |
67 if (suspended_) | 70 if (suspended_) |
68 return ERR_NETWORK_IO_SUSPENDED; | 71 return ERR_NETWORK_IO_SUSPENDED; |
(...skipping 12 matching lines...) Expand all Loading... |
81 void HttpNetworkLayer::Suspend(bool suspend) { | 84 void HttpNetworkLayer::Suspend(bool suspend) { |
82 suspended_ = suspend; | 85 suspended_ = suspend; |
83 | 86 |
84 if (suspend && session_) | 87 if (suspend && session_) |
85 session_->tcp_socket_pool()->CloseIdleSockets(); | 88 session_->tcp_socket_pool()->CloseIdleSockets(); |
86 } | 89 } |
87 | 90 |
88 HttpNetworkSession* HttpNetworkLayer::GetSession() { | 91 HttpNetworkSession* HttpNetworkLayer::GetSession() { |
89 if (!session_) { | 92 if (!session_) { |
90 DCHECK(proxy_service_); | 93 DCHECK(proxy_service_); |
91 session_ = new HttpNetworkSession(host_resolver_, proxy_service_, | 94 FlipSessionPool* flip_pool = enable_flip_ ? new FlipSessionPool : NULL; |
92 socket_factory_, ssl_config_service_); | 95 session_ = new HttpNetworkSession( |
| 96 host_resolver_, proxy_service_, socket_factory_, |
| 97 ssl_config_service_, flip_pool); |
93 // These were just temps for lazy-initializing HttpNetworkSession. | 98 // These were just temps for lazy-initializing HttpNetworkSession. |
94 host_resolver_ = NULL; | 99 host_resolver_ = NULL; |
95 proxy_service_ = NULL; | 100 proxy_service_ = NULL; |
96 socket_factory_ = NULL; | 101 socket_factory_ = NULL; |
97 } | 102 } |
98 return session_; | 103 return session_; |
99 } | 104 } |
100 | 105 |
101 // static | 106 // static |
102 void HttpNetworkLayer::EnableFlip(const std::string& mode) { | 107 void HttpNetworkLayer::EnableFlip(const std::string& mode) { |
103 static const std::string kDisableSSL("no-ssl"); | 108 static const std::string kDisableSSL("no-ssl"); |
104 static const std::string kDisableCompression("no-compress"); | 109 static const std::string kDisableCompression("no-compress"); |
105 static const std::string kDisableEverything("no-ssl-no-compress"); | 110 static const std::string kDisableEverything("no-ssl-no-compress"); |
106 | 111 |
107 // Enable flip mode. | 112 // Enable flip mode. |
108 enable_flip_ = true; | 113 enable_flip_ = true; |
109 | 114 |
110 // Disable SSL | 115 // Disable SSL |
111 if (mode == kDisableEverything || mode == kDisableSSL) | 116 if (mode == kDisableEverything || mode == kDisableSSL) |
112 FlipSession::SetSSLMode(false); | 117 FlipSession::SetSSLMode(false); |
113 | 118 |
114 // Disable compression | 119 // Disable compression |
115 if (mode == kDisableEverything || mode == kDisableCompression) | 120 if (mode == kDisableEverything || mode == kDisableCompression) |
116 flip::FlipFramer::set_enable_compression_default(false); | 121 flip::FlipFramer::set_enable_compression_default(false); |
117 } | 122 } |
118 | 123 |
119 } // namespace net | 124 } // namespace net |
OLD | NEW |