blob: b4b430fd34cec9f6deec2cb3b5fd3807b03b3025 [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// 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
3// found in the LICENSE file.
initial.commit586acc5fe2008-07-26 22:42:524
5#ifndef NET_HTTP_HTTP_NETWORK_LAYER_H_
6#define NET_HTTP_HTTP_NETWORK_LAYER_H_
7
8#include "base/ref_counted.h"
[email protected]a3b006eea2008-10-22 21:23:089#include "base/scoped_ptr.h"
initial.commit586acc5fe2008-07-26 22:42:5210#include "net/http/http_transaction_factory.h"
11
12namespace net {
13
[email protected]c6894572009-06-16 17:10:1014class ClientSocketFactory;
[email protected]8a00f00a2009-06-12 00:49:3815class HostResolver;
initial.commit586acc5fe2008-07-26 22:42:5216class HttpNetworkSession;
[email protected]928fb582008-08-11 15:40:2317class ProxyInfo;
[email protected]63de95b2008-12-10 04:11:2718class ProxyService;
initial.commit586acc5fe2008-07-26 22:42:5219
20class HttpNetworkLayer : public HttpTransactionFactory {
21 public:
[email protected]c6894572009-06-16 17:10:1022 // |socket_factory|, |proxy_service| and |host_resolver| must remain valid
23 // for the lifetime of HttpNetworkLayer.
24 HttpNetworkLayer(ClientSocketFactory* socket_factory,
25 HostResolver* host_resolver, ProxyService* proxy_service);
[email protected]e7f29642009-03-02 22:53:1826 // Construct a HttpNetworkLayer with an existing HttpNetworkSession which
27 // contains a valid ProxyService.
28 explicit HttpNetworkLayer(HttpNetworkSession* session);
[email protected]7b822b2b2008-08-05 00:15:4529 ~HttpNetworkLayer();
30
initial.commit586acc5fe2008-07-26 22:42:5231 // This function hides the details of how a network layer gets instantiated
32 // and allows other implementations to be substituted.
[email protected]8a00f00a2009-06-12 00:49:3833 static HttpTransactionFactory* CreateFactory(HostResolver* host_resolver,
34 ProxyService* proxy_service);
[email protected]e7f29642009-03-02 22:53:1835 // Create a transaction factory that instantiate a network layer over an
36 // existing network session. Network session contains some valuable
37 // information (e.g. authentication data) that we want to share across
38 // multiple network layers. This method exposes the implementation details
39 // of a network layer, use this method with an existing network layer only
40 // when network session is shared.
41 static HttpTransactionFactory* CreateFactory(HttpNetworkSession* session);
initial.commit586acc5fe2008-07-26 22:42:5242
initial.commit586acc5fe2008-07-26 22:42:5243 // HttpTransactionFactory methods:
44 virtual HttpTransaction* CreateTransaction();
45 virtual HttpCache* GetCache();
initial.commit586acc5fe2008-07-26 22:42:5246 virtual void Suspend(bool suspend);
47
[email protected]e7f29642009-03-02 22:53:1848 HttpNetworkSession* GetSession();
49
initial.commit586acc5fe2008-07-26 22:42:5250 private:
[email protected]c6894572009-06-16 17:10:1051 // The factory we will use to create network sockets.
52 ClientSocketFactory* socket_factory_;
53
[email protected]8a00f00a2009-06-12 00:49:3854 // The host resolver being used for the session.
[email protected]94a0d3d92009-06-27 01:50:1455 scoped_refptr<HostResolver> host_resolver_;
[email protected]8a00f00a2009-06-12 00:49:3856
[email protected]63de95b2008-12-10 04:11:2757 // The proxy service being used for the session.
[email protected]db8f44c2008-12-13 04:52:0158 ProxyService* proxy_service_;
[email protected]a3b006eea2008-10-22 21:23:0859
initial.commit586acc5fe2008-07-26 22:42:5260 scoped_refptr<HttpNetworkSession> session_;
61 bool suspended_;
62};
63
64} // namespace net
65
66#endif // NET_HTTP_HTTP_NETWORK_LAYER_H_