blob: 9d6e1335ef0530dbaae08b182755c249a70e99e1 [file] [log] [blame]
[email protected]7f28a8df2011-02-25 22:26:031// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]102e27c2011-02-23 01:01:312// 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_STREAM_FACTORY_IMPL_H_
6#define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_
7
8#include <map>
9#include <set>
10#include <string>
11
[email protected]7f28a8df2011-02-25 22:26:0312#include "base/ref_counted.h"
[email protected]102e27c2011-02-23 01:01:3113#include "net/http/http_stream_factory.h"
[email protected]7f28a8df2011-02-25 22:26:0314#include "net/proxy/proxy_server.h"
[email protected]102e27c2011-02-23 01:01:3115
16namespace net {
17
18class HttpNetworkSession;
[email protected]7f28a8df2011-02-25 22:26:0319class SpdySession;
[email protected]102e27c2011-02-23 01:01:3120
21class HttpStreamFactoryImpl : public HttpStreamFactory {
22 public:
23 explicit HttpStreamFactoryImpl(HttpNetworkSession* session);
24 virtual ~HttpStreamFactoryImpl();
25
26 // HttpStreamFactory Interface
27 virtual HttpStreamRequest* RequestStream(
28 const HttpRequestInfo& info,
29 const SSLConfig& ssl_config,
30 HttpStreamRequest::Delegate* delegate,
31 const BoundNetLog& net_log);
32
33 virtual void PreconnectStreams(int num_streams,
34 const HttpRequestInfo& info,
35 const SSLConfig& ssl_config,
36 const BoundNetLog& net_log);
37 virtual void AddTLSIntolerantServer(const GURL& url);
38 virtual bool IsTLSIntolerantServer(const GURL& url) const;
39
40 private:
41 class Request;
42 class Job;
43
[email protected]7f28a8df2011-02-25 22:26:0344 typedef std::set<Request*> RequestSet;
45 typedef std::map<HostPortProxyPair, RequestSet> SpdySessionRequestMap;
46
[email protected]102e27c2011-02-23 01:01:3147 LoadState GetLoadState(const Request& request) const;
48
[email protected]7f28a8df2011-02-25 22:26:0349 // Called when a SpdySession is ready. It will find appropriate Requests and
50 // fulfill them. |direct| indicates whether or not |spdy_session| uses a
51 // proxy.
52 void OnSpdySessionReady(const Job* job,
53 scoped_refptr<SpdySession> spdy_session,
54 bool direct);
[email protected]102e27c2011-02-23 01:01:3155
[email protected]7f28a8df2011-02-25 22:26:0356 // Called when the Job detects that the endpoint indicated by the
57 // Alternate-Protocol does not work. Lets the factory update
58 // HttpAlternateProtocols with the failure and resets the SPDY session key.
59 void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin);
60
61 // Invoked when the Job finishes preconnecting sockets.
[email protected]102e27c2011-02-23 01:01:3162 void OnPreconnectsComplete(const Job* job);
63
64 // Called when the Preconnect completes. Used for testing.
65 virtual void OnPreconnectsCompleteInternal() {}
66
67 HttpNetworkSession* const session_;
68
69 std::set<std::string> tls_intolerant_servers_;
70
71 // All Requests are handed out to clients. By the time HttpStreamFactoryImpl
72 // is destroyed, all Requests should be deleted (which should remove them from
[email protected]7f28a8df2011-02-25 22:26:0373 // |request_map_|. The Requests will delete the corresponding job.
[email protected]102e27c2011-02-23 01:01:3174 std::map<const Job*, Request*> request_map_;
75
[email protected]7f28a8df2011-02-25 22:26:0376 SpdySessionRequestMap spdy_session_request_map_;
77
[email protected]102e27c2011-02-23 01:01:3178 // These jobs correspond to preconnect requests and have no associated Request
79 // object. They're owned by HttpStreamFactoryImpl. Leftover jobs will be
80 // deleted when the factory is destroyed.
81 std::set<const Job*> preconnect_job_set_;
82
83 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl);
84};
85
86} // namespace net
87
88#endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_