Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: net/http/http_stream_factory_impl.h

Issue 6591030: Add HttpStreamFactory Job orphaning semantics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add tests. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/http/http_stream_factory_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ 5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_
6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ 6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 #include "net/http/http_stream_factory.h" 13 #include "net/http/http_stream_factory.h"
14 #include "net/base/net_log.h"
14 #include "net/proxy/proxy_server.h" 15 #include "net/proxy/proxy_server.h"
15 16
16 namespace net { 17 namespace net {
17 18
18 class HttpNetworkSession; 19 class HttpNetworkSession;
19 class SpdySession; 20 class SpdySession;
20 21
21 class HttpStreamFactoryImpl : public HttpStreamFactory { 22 class HttpStreamFactoryImpl : public HttpStreamFactory {
22 public: 23 public:
23 explicit HttpStreamFactoryImpl(HttpNetworkSession* session); 24 explicit HttpStreamFactoryImpl(HttpNetworkSession* session);
(...skipping 13 matching lines...) Expand all
37 virtual void AddTLSIntolerantServer(const GURL& url); 38 virtual void AddTLSIntolerantServer(const GURL& url);
38 virtual bool IsTLSIntolerantServer(const GURL& url) const; 39 virtual bool IsTLSIntolerantServer(const GURL& url) const;
39 40
40 private: 41 private:
41 class Request; 42 class Request;
42 class Job; 43 class Job;
43 44
44 typedef std::set<Request*> RequestSet; 45 typedef std::set<Request*> RequestSet;
45 typedef std::map<HostPortProxyPair, RequestSet> SpdySessionRequestMap; 46 typedef std::map<HostPortProxyPair, RequestSet> SpdySessionRequestMap;
46 47
47 LoadState GetLoadState(const Request& request) const; 48 // Detaches |job| from |request|.
49 void OrphanJob(Job* job, const Request* request);
48 50
49 // Called when a SpdySession is ready. It will find appropriate Requests and 51 // Called when a SpdySession is ready. It will find appropriate Requests and
50 // fulfill them. |direct| indicates whether or not |spdy_session| uses a 52 // fulfill them. |direct| indicates whether or not |spdy_session| uses a
51 // proxy. 53 // proxy.
52 void OnSpdySessionReady(const Job* job, 54 void OnSpdySessionReady(scoped_refptr<SpdySession> spdy_session,
53 scoped_refptr<SpdySession> spdy_session, 55 bool direct,
54 bool direct); 56 const SSLConfig& used_ssl_config,
57 const ProxyInfo& used_proxy_info,
58 bool was_alternate_protocol_available,
59 bool was_npn_negotiated,
60 bool using_spdy,
61 const NetLog::Source& source);
55 62
56 // Called when the Job detects that the endpoint indicated by the 63 // Called when the Job detects that the endpoint indicated by the
57 // Alternate-Protocol does not work. Lets the factory update 64 // Alternate-Protocol does not work. Lets the factory update
58 // HttpAlternateProtocols with the failure and resets the SPDY session key. 65 // HttpAlternateProtocols with the failure and resets the SPDY session key.
59 void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin); 66 void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin);
60 67
68 // Invoked when an orphaned Job finishes.
69 void OnOrphanedJobComplete(const Job* job);
70
61 // Invoked when the Job finishes preconnecting sockets. 71 // Invoked when the Job finishes preconnecting sockets.
62 void OnPreconnectsComplete(const Job* job); 72 void OnPreconnectsComplete(const Job* job);
63 73
64 // Called when the Preconnect completes. Used for testing. 74 // Called when the Preconnect completes. Used for testing.
65 virtual void OnPreconnectsCompleteInternal() {} 75 virtual void OnPreconnectsCompleteInternal() {}
66 76
67 HttpNetworkSession* const session_; 77 HttpNetworkSession* const session_;
68 78
69 std::set<std::string> tls_intolerant_servers_; 79 std::set<std::string> tls_intolerant_servers_;
70 80
71 // All Requests are handed out to clients. By the time HttpStreamFactoryImpl 81 // All Requests are handed out to clients. By the time HttpStreamFactoryImpl
72 // is destroyed, all Requests should be deleted (which should remove them from 82 // is destroyed, all Requests should be deleted (which should remove them from
73 // |request_map_|. The Requests will delete the corresponding job. 83 // |request_map_|. The Requests will delete the corresponding job.
74 std::map<const Job*, Request*> request_map_; 84 std::map<const Job*, Request*> request_map_;
75 85
76 SpdySessionRequestMap spdy_session_request_map_; 86 SpdySessionRequestMap spdy_session_request_map_;
77 87
88 // These jobs correspond to jobs orphaned by requests and now owned by
89 // HttpStreamFactoryImpl. Leftover jobs will be deleted when the factory is
90 // destroyed.
Mike Belshe 2011/03/01 17:09:19 "...deleted when the factory is destroyed." sounds
willchan no longer on Chromium 2011/03/01 17:48:27 Oh, I'll clarify this comment. What I mean is that
91 std::set<const Job*> orphaned_job_set_;
92
78 // These jobs correspond to preconnect requests and have no associated Request 93 // These jobs correspond to preconnect requests and have no associated Request
79 // object. They're owned by HttpStreamFactoryImpl. Leftover jobs will be 94 // object. They're owned by HttpStreamFactoryImpl. Leftover jobs will be
80 // deleted when the factory is destroyed. 95 // deleted when the factory is destroyed.
81 std::set<const Job*> preconnect_job_set_; 96 std::set<const Job*> preconnect_job_set_;
82 97
83 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); 98 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl);
84 }; 99 };
85 100
86 } // namespace net 101 } // namespace net
87 102
88 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ 103 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | net/http/http_stream_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698