blob: 6c06c948cdf4bb54e60dc1a7f4358356a1f06b10 [file] [log] [blame]
[email protected]1ad77dc2012-01-27 03:51:201// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit586acc5fe2008-07-26 22:42:524
5#include "net/http/http_network_layer.h"
6
[email protected]0dfc81b2008-08-25 03:44:407#include "base/logging.h"
[email protected]d93d8332011-01-08 04:21:088#include "base/string_number_conversions.h"
[email protected]85c0ed82009-12-15 23:14:149#include "base/string_util.h"
[email protected]d778e0422013-03-06 18:10:2210#include "base/strings/string_split.h"
initial.commit586acc5fe2008-07-26 22:42:5211#include "net/http/http_network_session.h"
12#include "net/http/http_network_transaction.h"
[email protected]17291a022011-10-10 07:32:5313#include "net/http/http_server_properties_impl.h"
[email protected]f1e97e92012-12-16 04:53:2514#include "net/http/http_stream_factory_impl_job.h"
[email protected]dab9c7d2010-02-06 21:44:3215#include "net/spdy/spdy_framer.h"
[email protected]dab9c7d2010-02-06 21:44:3216#include "net/spdy/spdy_session.h"
[email protected]ea1cc2cd2011-02-22 16:47:3817#include "net/spdy/spdy_session_pool.h"
initial.commit586acc5fe2008-07-26 22:42:5218
19namespace net {
20
21//-----------------------------------------------------------------------------
[email protected]e7f29642009-03-02 22:53:1822HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session)
[email protected]57cb0f72011-01-28 06:33:5823 : session_(session),
[email protected]c6894572009-06-16 17:10:1024 suspended_(false) {
[email protected]e7f29642009-03-02 22:53:1825 DCHECK(session_.get());
26}
27
initial.commit586acc5fe2008-07-26 22:42:5228HttpNetworkLayer::~HttpNetworkLayer() {
29}
30
[email protected]d100e44f2011-01-26 22:47:1131//-----------------------------------------------------------------------------
initial.commit586acc5fe2008-07-26 22:42:5232
[email protected]d100e44f2011-01-26 22:47:1133// static
34HttpTransactionFactory* HttpNetworkLayer::CreateFactory(
[email protected]d100e44f2011-01-26 22:47:1135 HttpNetworkSession* session) {
36 DCHECK(session);
initial.commit586acc5fe2008-07-26 22:42:5237
[email protected]d100e44f2011-01-26 22:47:1138 return new HttpNetworkLayer(session);
[email protected]e7f29642009-03-02 22:53:1839}
40
[email protected]7adaccb2009-10-13 04:43:2141// static
[email protected]443a30ed2012-11-30 02:56:4642void HttpNetworkLayer::ForceAlternateProtocol() {
43 PortAlternateProtocolPair pair;
44 pair.port = 443;
45 pair.protocol = NPN_SPDY_2;
46 HttpServerPropertiesImpl::ForceAlternateProtocol(pair);
[email protected]7adaccb2009-10-13 04:43:2147}
[email protected]d100e44f2011-01-26 22:47:1148
49//-----------------------------------------------------------------------------
50
[email protected]5a07c192012-07-30 20:18:2251int HttpNetworkLayer::CreateTransaction(scoped_ptr<HttpTransaction>* trans,
52 HttpTransactionDelegate* delegate) {
[email protected]d100e44f2011-01-26 22:47:1153 if (suspended_)
54 return ERR_NETWORK_IO_SUSPENDED;
55
56 trans->reset(new HttpNetworkTransaction(GetSession()));
57 return OK;
58}
59
60HttpCache* HttpNetworkLayer::GetCache() {
61 return NULL;
62}
63
64HttpNetworkSession* HttpNetworkLayer::GetSession() {
[email protected]d100e44f2011-01-26 22:47:1165 return session_;
66}
67
[email protected]8523ba52011-05-22 19:00:5868void HttpNetworkLayer::OnSuspend() {
69 suspended_ = true;
[email protected]d100e44f2011-01-26 22:47:1170
[email protected]8523ba52011-05-22 19:00:5871 if (session_)
[email protected]102e27c2011-02-23 01:01:3172 session_->CloseIdleConnections();
[email protected]d100e44f2011-01-26 22:47:1173}
74
[email protected]8523ba52011-05-22 19:00:5875void HttpNetworkLayer::OnResume() {
76 suspended_ = false;
77}
78
initial.commit586acc5fe2008-07-26 22:42:5279} // namespace net