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" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // static | 39 // static |
40 void HttpNetworkLayer::UseWinHttp(bool value) { | 40 void HttpNetworkLayer::UseWinHttp(bool value) { |
41 use_winhttp_ = value; | 41 use_winhttp_ = value; |
42 } | 42 } |
43 #endif | 43 #endif |
44 | 44 |
45 //----------------------------------------------------------------------------- | 45 //----------------------------------------------------------------------------- |
46 | 46 |
47 HttpNetworkLayer::HttpNetworkLayer(const ProxyInfo* pi) | 47 HttpNetworkLayer::HttpNetworkLayer(const ProxyInfo* pi) |
48 : suspended_(false) { | 48 : suspended_(false) { |
49 ProxyResolver* proxy_resolver; | |
50 if (pi) { | 49 if (pi) { |
51 proxy_resolver = new ProxyResolverFixed(*pi); | 50 proxy_resolver_.reset(new ProxyResolverFixed(*pi)); |
52 } else { | 51 } else { |
53 #if defined(OS_WIN) | 52 #if defined(OS_WIN) |
54 proxy_resolver = new ProxyResolverWinHttp(); | 53 proxy_resolver_.reset(new ProxyResolverWinHttp()); |
55 #else | 54 #else |
56 NOTIMPLEMENTED(); | 55 NOTIMPLEMENTED(); |
57 proxy_resolver = new ProxyResolverNull(); | 56 proxy_resolver_.reset(new ProxyResolverNull()); |
58 #endif | 57 #endif |
59 } | 58 } |
60 session_ = new HttpNetworkSession(proxy_resolver); | |
61 } | 59 } |
62 | 60 |
63 HttpNetworkLayer::~HttpNetworkLayer() { | 61 HttpNetworkLayer::~HttpNetworkLayer() { |
64 } | 62 } |
65 | 63 |
66 HttpTransaction* HttpNetworkLayer::CreateTransaction() { | 64 HttpTransaction* HttpNetworkLayer::CreateTransaction() { |
67 if (suspended_) | 65 if (suspended_) |
68 return NULL; | 66 return NULL; |
69 | 67 |
| 68 if (!session_) |
| 69 session_ = new HttpNetworkSession(proxy_resolver_.release()); |
| 70 |
70 return new HttpNetworkTransaction( | 71 return new HttpNetworkTransaction( |
71 session_, ClientSocketFactory::GetDefaultFactory()); | 72 session_, ClientSocketFactory::GetDefaultFactory()); |
72 } | 73 } |
73 | 74 |
74 HttpCache* HttpNetworkLayer::GetCache() { | 75 HttpCache* HttpNetworkLayer::GetCache() { |
75 return NULL; | 76 return NULL; |
76 } | 77 } |
77 | 78 |
78 AuthCache* HttpNetworkLayer::GetAuthCache() { | 79 AuthCache* HttpNetworkLayer::GetAuthCache() { |
79 return session_->auth_cache(); | 80 return session_->auth_cache(); |
80 } | 81 } |
81 | 82 |
82 void HttpNetworkLayer::Suspend(bool suspend) { | 83 void HttpNetworkLayer::Suspend(bool suspend) { |
83 suspended_ = suspend; | 84 suspended_ = suspend; |
84 | 85 |
85 if (suspend) | 86 if (suspend && session_) |
86 session_->connection_pool()->CloseIdleSockets(); | 87 session_->connection_pool()->CloseIdleSockets(); |
87 } | 88 } |
88 | 89 |
89 } // namespace net | 90 } // namespace net |
90 | 91 |
OLD | NEW |