1// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef NET_HTTP_HTTP_NETWORK_LAYER_H_
6#define NET_HTTP_HTTP_NETWORK_LAYER_H_
7#pragma once
8
9#include <string>
10
11#include "base/memory/ref_counted.h"
12#include "base/memory/scoped_ptr.h"
13#include "base/threading/non_thread_safe.h"
14#include "net/base/net_export.h"
15#include "net/http/http_transaction_factory.h"
16
17namespace net {
18
19class CertVerifier;
20class ClientSocketFactory;
21class DnsCertProvenanceChecker;
22class DnsRRResolver;
23class HostResolver;
24class HttpAuthHandlerFactory;
25class HttpNetworkSession;
26class NetLog;
27class NetworkDelegate;
28class ProxyService;
29class SpdySessionPool;
30class SSLConfigService;
31class SSLHostInfoFactory;
32
33class NET_EXPORT HttpNetworkLayer : public HttpTransactionFactory,
34                                    public base::NonThreadSafe {
35 public:
36  // Construct a HttpNetworkLayer with an existing HttpNetworkSession which
37  // contains a valid ProxyService.
38  explicit HttpNetworkLayer(HttpNetworkSession* session);
39  virtual ~HttpNetworkLayer();
40
41  // Create a transaction factory that instantiate a network layer over an
42  // existing network session. Network session contains some valuable
43  // information (e.g. authentication data) that we want to share across
44  // multiple network layers. This method exposes the implementation details
45  // of a network layer, use this method with an existing network layer only
46  // when network session is shared.
47  static HttpTransactionFactory* CreateFactory(HttpNetworkSession* session);
48
49  // Enable the spdy protocol.
50  // Without calling this function, SPDY is disabled.  The mode can be:
51  //   ""            : (default) SSL and compression are enabled, flow
52  //                   control disabled.
53  //   "no-ssl"      : disables SSL.
54  //   "no-compress" : disables compression.
55  //   "flow-control": enables flow control.
56  //   "none"        : disables both SSL and compression.
57  static void EnableSpdy(const std::string& mode);
58
59  // HttpTransactionFactory methods:
60  virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans);
61  virtual HttpCache* GetCache();
62  virtual HttpNetworkSession* GetSession();
63  virtual void Suspend(bool suspend);
64
65 private:
66  const scoped_refptr<HttpNetworkSession> session_;
67  bool suspended_;
68};
69
70}  // namespace net
71
72#endif  // NET_HTTP_HTTP_NETWORK_LAYER_H_
73