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

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

Issue 6591030: Add HttpStreamFactory Job orphaning semantics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment. 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 | « net/http/http_stream_factory_impl_job.cc ('k') | net/http/http_stream_factory_impl_request.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_REQUEST_H_ 5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_
6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_ 6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_
7 7
8 #include <set>
8 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
9 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
10 #include "net/base/net_log.h" 11 #include "net/base/net_log.h"
11 #include "net/http/http_stream_factory_impl.h" 12 #include "net/http/http_stream_factory_impl.h"
12 13
13 namespace net { 14 namespace net {
14 15
15 class HttpStreamFactoryImpl::Request : public HttpStreamRequest { 16 class HttpStreamFactoryImpl::Request : public HttpStreamRequest {
16 public: 17 public:
17 Request(const GURL& url, 18 Request(const GURL& url,
18 HttpStreamFactoryImpl* factory, 19 HttpStreamFactoryImpl* factory,
19 HttpStreamRequest::Delegate* delegate, 20 HttpStreamRequest::Delegate* delegate,
20 const BoundNetLog& net_log); 21 const BoundNetLog& net_log);
21 virtual ~Request(); 22 virtual ~Request();
22 23
23 // Returns the Job that the Request started up.
24 Job* job() const { return job_; }
25
26 // The GURL from the HttpRequestInfo the started the Request. 24 // The GURL from the HttpRequestInfo the started the Request.
27 const GURL& url() const { return url_; } 25 const GURL& url() const { return url_; }
28 26
29 // Called when the Job determines the appropriate |spdy_session_key| for the 27 // Called when the Job determines the appropriate |spdy_session_key| for the
30 // Request. Note that this does not mean that SPDY is necessarily supported 28 // Request. Note that this does not mean that SPDY is necessarily supported
31 // for this HostPortProxyPair, since we may need to wait for NPN to complete 29 // for this HostPortProxyPair, since we may need to wait for NPN to complete
32 // before knowing if SPDY is available. 30 // before knowing if SPDY is available.
33 void SetSpdySessionKey(const HostPortProxyPair& spdy_session_key); 31 void SetSpdySessionKey(const HostPortProxyPair& spdy_session_key);
34 32
35 // Binds |job| to this request. 33 // Attaches |job| to this request. Does not mean that Request will use |job|,
36 void BindJob(HttpStreamFactoryImpl::Job* job); 34 // but Request will own |job|.
35 void AttachJob(HttpStreamFactoryImpl::Job* job);
37 36
38 // Marks completion of the request. Must be called before OnStreamReady(). 37 // Marks completion of the request. Must be called before OnStreamReady().
39 // |source| is the NetLog::Source generated by the Job that fulfilled this 38 // |source| is the NetLog::Source generated by the Job that fulfilled this
40 // request. 39 // request.
41 void Complete(bool was_alternate_protocol_available, 40 void Complete(bool was_alternate_protocol_available,
42 bool was_npn_negotiated, 41 bool was_npn_negotiated,
43 bool using_spdy, 42 bool using_spdy,
44 const NetLog::Source& source); 43 const NetLog::Source& source);
45 44
46 // If this Request has a spdy_session_key, remove this session from the 45 // If this Request has a spdy_session_key, remove this session from the
47 // SpdySessionRequestMap. 46 // SpdySessionRequestMap.
48 void RemoveRequestFromSpdySessionRequestMap(); 47 void RemoveRequestFromSpdySessionRequestMap();
49 48
49 // Called by an attached Job if it sets up a SpdySession.
50 void OnSpdySessionReady(Job* job,
51 scoped_refptr<SpdySession> spdy_session,
52 bool direct);
53
50 // HttpStreamRequest::Delegate methods which we implement. Note we don't 54 // HttpStreamRequest::Delegate methods which we implement. Note we don't
51 // actually subclass HttpStreamRequest::Delegate. 55 // actually subclass HttpStreamRequest::Delegate.
52 56
53 void OnStreamReady(const SSLConfig& used_ssl_config, 57 void OnStreamReady(Job* job,
58 const SSLConfig& used_ssl_config,
54 const ProxyInfo& used_proxy_info, 59 const ProxyInfo& used_proxy_info,
55 HttpStream* stream); 60 HttpStream* stream);
56 void OnStreamFailed(int status, const SSLConfig& used_ssl_config); 61 void OnStreamFailed(Job* job, int status, const SSLConfig& used_ssl_config);
57 void OnCertificateError(int status, 62 void OnCertificateError(Job* job,
63 int status,
58 const SSLConfig& used_ssl_config, 64 const SSLConfig& used_ssl_config,
59 const SSLInfo& ssl_info); 65 const SSLInfo& ssl_info);
60 void OnNeedsProxyAuth(const HttpResponseInfo& proxy_response, 66 void OnNeedsProxyAuth(Job* job,
67 const HttpResponseInfo& proxy_response,
61 const SSLConfig& used_ssl_config, 68 const SSLConfig& used_ssl_config,
62 const ProxyInfo& used_proxy_info, 69 const ProxyInfo& used_proxy_info,
63 HttpAuthController* auth_controller); 70 HttpAuthController* auth_controller);
64 void OnNeedsClientAuth(const SSLConfig& used_ssl_config, 71 void OnNeedsClientAuth(Job* job,
72 const SSLConfig& used_ssl_config,
65 SSLCertRequestInfo* cert_info); 73 SSLCertRequestInfo* cert_info);
66 void OnHttpsProxyTunnelResponse( 74 void OnHttpsProxyTunnelResponse(
75 Job *job,
67 const HttpResponseInfo& response_info, 76 const HttpResponseInfo& response_info,
68 const SSLConfig& used_ssl_config, 77 const SSLConfig& used_ssl_config,
69 const ProxyInfo& used_proxy_info, 78 const ProxyInfo& used_proxy_info,
70 HttpStream* stream); 79 HttpStream* stream);
71 80
72 // HttpStreamRequest methods. 81 // HttpStreamRequest methods.
73 82
74 virtual int RestartTunnelWithProxyAuth(const string16& username, 83 virtual int RestartTunnelWithProxyAuth(const string16& username,
75 const string16& password); 84 const string16& password);
76 virtual LoadState GetLoadState() const; 85 virtual LoadState GetLoadState() const;
77 virtual bool was_alternate_protocol_available() const; 86 virtual bool was_alternate_protocol_available() const;
78 virtual bool was_npn_negotiated() const; 87 virtual bool was_npn_negotiated() const;
79 virtual bool using_spdy() const; 88 virtual bool using_spdy() const;
80 89
81 private: 90 private:
91 // Used to orphan all jobs in |jobs_| other than |job| which becomes "bound"
92 // to the request.
93 void OrphanJobsExcept(Job* job);
94
95 // Used to orphan all jobs in |jobs_|.
96 void OrphanJobs();
97
82 const GURL url_; 98 const GURL url_;
83 HttpStreamFactoryImpl* const factory_; 99 HttpStreamFactoryImpl* const factory_;
84 HttpStreamRequest::Delegate* const delegate_; 100 HttpStreamRequest::Delegate* const delegate_;
85 const BoundNetLog net_log_; 101 const BoundNetLog net_log_;
86 102
87 // The |job_| that this request is tied to. 103 // At the point where Job is irrevocably tied to the Request, we set this.
88 HttpStreamFactoryImpl::Job* job_; 104 scoped_ptr<Job> bound_job_;
105 std::set<HttpStreamFactoryImpl::Job*> jobs_;
89 scoped_ptr<const HostPortProxyPair> spdy_session_key_; 106 scoped_ptr<const HostPortProxyPair> spdy_session_key_;
90 107
91 bool completed_; 108 bool completed_;
92 bool was_alternate_protocol_available_; 109 bool was_alternate_protocol_available_;
93 bool was_npn_negotiated_; 110 bool was_npn_negotiated_;
94 bool using_spdy_; 111 bool using_spdy_;
95 112
96 DISALLOW_COPY_AND_ASSIGN(Request); 113 DISALLOW_COPY_AND_ASSIGN(Request);
97 }; 114 };
98 115
99 } // namespace net 116 } // namespace net
100 117
101 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ 118 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_job.cc ('k') | net/http/http_stream_factory_impl_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698