[email protected] | 1ad77dc | 2012-01-27 03:51:20 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 4 | |
5 | #include "net/http/http_network_layer.h" | ||||
6 | |||||
[email protected] | 0dfc81b | 2008-08-25 03:44:40 | [diff] [blame] | 7 | #include "base/logging.h" |
[email protected] | d93d833 | 2011-01-08 04:21:08 | [diff] [blame] | 8 | #include "base/string_number_conversions.h" |
[email protected] | 85c0ed8 | 2009-12-15 23:14:14 | [diff] [blame] | 9 | #include "base/string_util.h" |
[email protected] | d778e042 | 2013-03-06 18:10:22 | [diff] [blame^] | 10 | #include "base/strings/string_split.h" |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 11 | #include "net/http/http_network_session.h" |
12 | #include "net/http/http_network_transaction.h" | ||||
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 13 | #include "net/http/http_server_properties_impl.h" |
[email protected] | f1e97e9 | 2012-12-16 04:53:25 | [diff] [blame] | 14 | #include "net/http/http_stream_factory_impl_job.h" |
[email protected] | dab9c7d | 2010-02-06 21:44:32 | [diff] [blame] | 15 | #include "net/spdy/spdy_framer.h" |
[email protected] | dab9c7d | 2010-02-06 21:44:32 | [diff] [blame] | 16 | #include "net/spdy/spdy_session.h" |
[email protected] | ea1cc2cd | 2011-02-22 16:47:38 | [diff] [blame] | 17 | #include "net/spdy/spdy_session_pool.h" |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 18 | |
19 | namespace net { | ||||
20 | |||||
21 | //----------------------------------------------------------------------------- | ||||
[email protected] | e7f2964 | 2009-03-02 22:53:18 | [diff] [blame] | 22 | HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session) |
[email protected] | 57cb0f7 | 2011-01-28 06:33:58 | [diff] [blame] | 23 | : session_(session), |
[email protected] | c689457 | 2009-06-16 17:10:10 | [diff] [blame] | 24 | suspended_(false) { |
[email protected] | e7f2964 | 2009-03-02 22:53:18 | [diff] [blame] | 25 | DCHECK(session_.get()); |
26 | } | ||||
27 | |||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 28 | HttpNetworkLayer::~HttpNetworkLayer() { |
29 | } | ||||
30 | |||||
[email protected] | d100e44f | 2011-01-26 22:47:11 | [diff] [blame] | 31 | //----------------------------------------------------------------------------- |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 32 | |
[email protected] | d100e44f | 2011-01-26 22:47:11 | [diff] [blame] | 33 | // static |
34 | HttpTransactionFactory* HttpNetworkLayer::CreateFactory( | ||||
[email protected] | d100e44f | 2011-01-26 22:47:11 | [diff] [blame] | 35 | HttpNetworkSession* session) { |
36 | DCHECK(session); | ||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 37 | |
[email protected] | d100e44f | 2011-01-26 22:47:11 | [diff] [blame] | 38 | return new HttpNetworkLayer(session); |
[email protected] | e7f2964 | 2009-03-02 22:53:18 | [diff] [blame] | 39 | } |
40 | |||||
[email protected] | 7adaccb | 2009-10-13 04:43:21 | [diff] [blame] | 41 | // static |
[email protected] | 443a30ed | 2012-11-30 02:56:46 | [diff] [blame] | 42 | void HttpNetworkLayer::ForceAlternateProtocol() { |
43 | PortAlternateProtocolPair pair; | ||||
44 | pair.port = 443; | ||||
45 | pair.protocol = NPN_SPDY_2; | ||||
46 | HttpServerPropertiesImpl::ForceAlternateProtocol(pair); | ||||
[email protected] | 7adaccb | 2009-10-13 04:43:21 | [diff] [blame] | 47 | } |
[email protected] | d100e44f | 2011-01-26 22:47:11 | [diff] [blame] | 48 | |
49 | //----------------------------------------------------------------------------- | ||||
50 | |||||
[email protected] | 5a07c19 | 2012-07-30 20:18:22 | [diff] [blame] | 51 | int HttpNetworkLayer::CreateTransaction(scoped_ptr<HttpTransaction>* trans, |
52 | HttpTransactionDelegate* delegate) { | ||||
[email protected] | d100e44f | 2011-01-26 22:47:11 | [diff] [blame] | 53 | if (suspended_) |
54 | return ERR_NETWORK_IO_SUSPENDED; | ||||
55 | |||||
56 | trans->reset(new HttpNetworkTransaction(GetSession())); | ||||
57 | return OK; | ||||
58 | } | ||||
59 | |||||
60 | HttpCache* HttpNetworkLayer::GetCache() { | ||||
61 | return NULL; | ||||
62 | } | ||||
63 | |||||
64 | HttpNetworkSession* HttpNetworkLayer::GetSession() { | ||||
[email protected] | d100e44f | 2011-01-26 22:47:11 | [diff] [blame] | 65 | return session_; |
66 | } | ||||
67 | |||||
[email protected] | 8523ba5 | 2011-05-22 19:00:58 | [diff] [blame] | 68 | void HttpNetworkLayer::OnSuspend() { |
69 | suspended_ = true; | ||||
[email protected] | d100e44f | 2011-01-26 22:47:11 | [diff] [blame] | 70 | |
[email protected] | 8523ba5 | 2011-05-22 19:00:58 | [diff] [blame] | 71 | if (session_) |
[email protected] | 102e27c | 2011-02-23 01:01:31 | [diff] [blame] | 72 | session_->CloseIdleConnections(); |
[email protected] | d100e44f | 2011-01-26 22:47:11 | [diff] [blame] | 73 | } |
74 | |||||
[email protected] | 8523ba5 | 2011-05-22 19:00:58 | [diff] [blame] | 75 | void HttpNetworkLayer::OnResume() { |
76 | suspended_ = false; | ||||
77 | } | ||||
78 | |||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 79 | } // namespace net |