Clean up MFYI by adding suppressions for new bugs
[chromium-blink-merge.git] / net / http / http_stream_factory_impl_request.h
blob3d3b2c8bd633b7c762acca271f14c28ba59eef2b
1 // Copyright (c) 2012 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.
5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_
6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_
8 #include <set>
9 #include "base/memory/scoped_ptr.h"
10 #include "net/base/net_log.h"
11 #include "net/http/http_stream_factory_impl.h"
12 #include "net/socket/ssl_client_socket.h"
13 #include "net/spdy/spdy_session_key.h"
14 #include "url/gurl.h"
16 namespace net {
18 class ClientSocketHandle;
19 class SpdySession;
21 class HttpStreamFactoryImpl::Request : public HttpStreamRequest {
22 public:
23 Request(const GURL& url,
24 HttpStreamFactoryImpl* factory,
25 HttpStreamRequest::Delegate* delegate,
26 WebSocketHandshakeStreamBase::CreateHelper*
27 websocket_handshake_stream_create_helper,
28 const BoundNetLog& net_log);
29 virtual ~Request();
31 // The GURL from the HttpRequestInfo the started the Request.
32 const GURL& url() const { return url_; }
34 // Called when the Job determines the appropriate |spdy_session_key| for the
35 // Request. Note that this does not mean that SPDY is necessarily supported
36 // for this SpdySessionKey, since we may need to wait for NPN to complete
37 // before knowing if SPDY is available.
38 void SetSpdySessionKey(const SpdySessionKey& spdy_session_key);
40 // Called when the Job determines the appropriate |http_pipelining_key| for
41 // the Request. Registers this Request with the factory, so that if an
42 // existing pipeline becomes available, this Request can be late bound to it.
43 // Returns true if this is this key was new to the factory.
44 bool SetHttpPipeliningKey(const HttpPipelinedHost::Key& http_pipelining_key);
46 // Attaches |job| to this request. Does not mean that Request will use |job|,
47 // but Request will own |job|.
48 void AttachJob(HttpStreamFactoryImpl::Job* job);
50 // Marks completion of the request. Must be called before OnStreamReady().
51 // |job_net_log| is the BoundNetLog of the Job that fulfilled this request.
52 void Complete(bool was_npn_negotiated,
53 NextProto protocol_negotiated,
54 bool using_spdy,
55 const BoundNetLog& job_net_log);
57 // If this Request has a |spdy_session_key_|, remove this session from the
58 // SpdySessionRequestMap.
59 void RemoveRequestFromSpdySessionRequestMap();
61 // If this Request has a |http_pipelining_key_|, remove this session from the
62 // HttpPipeliningRequestMap.
63 void RemoveRequestFromHttpPipeliningRequestMap();
65 // Called by an attached Job if it sets up a SpdySession.
66 void OnNewSpdySessionReady(Job* job,
67 const base::WeakPtr<SpdySession>& spdy_session,
68 bool direct);
70 WebSocketHandshakeStreamBase::CreateHelper*
71 websocket_handshake_stream_create_helper() {
72 return websocket_handshake_stream_create_helper_;
75 // HttpStreamRequest::Delegate methods which we implement. Note we don't
76 // actually subclass HttpStreamRequest::Delegate.
78 void OnStreamReady(Job* job,
79 const SSLConfig& used_ssl_config,
80 const ProxyInfo& used_proxy_info,
81 HttpStreamBase* stream);
82 void OnWebSocketHandshakeStreamReady(Job* job,
83 const SSLConfig& used_ssl_config,
84 const ProxyInfo& used_proxy_info,
85 WebSocketHandshakeStreamBase* stream);
86 void OnStreamFailed(Job* job, int status, const SSLConfig& used_ssl_config);
87 void OnCertificateError(Job* job,
88 int status,
89 const SSLConfig& used_ssl_config,
90 const SSLInfo& ssl_info);
91 void OnNeedsProxyAuth(Job* job,
92 const HttpResponseInfo& proxy_response,
93 const SSLConfig& used_ssl_config,
94 const ProxyInfo& used_proxy_info,
95 HttpAuthController* auth_controller);
96 void OnNeedsClientAuth(Job* job,
97 const SSLConfig& used_ssl_config,
98 SSLCertRequestInfo* cert_info);
99 void OnHttpsProxyTunnelResponse(
100 Job *job,
101 const HttpResponseInfo& response_info,
102 const SSLConfig& used_ssl_config,
103 const ProxyInfo& used_proxy_info,
104 HttpStreamBase* stream);
106 // HttpStreamRequest methods.
108 virtual int RestartTunnelWithProxyAuth(
109 const AuthCredentials& credentials) OVERRIDE;
110 virtual void SetPriority(RequestPriority priority) OVERRIDE;
111 virtual LoadState GetLoadState() const OVERRIDE;
112 virtual bool was_npn_negotiated() const OVERRIDE;
113 virtual NextProto protocol_negotiated() const OVERRIDE;
114 virtual bool using_spdy() const OVERRIDE;
116 private:
117 // Used to orphan all jobs in |jobs_| other than |job| which becomes "bound"
118 // to the request.
119 void OrphanJobsExcept(Job* job);
121 // Used to orphan all jobs in |jobs_|.
122 void OrphanJobs();
124 // Called when a Job succeeds.
125 void OnJobSucceeded(Job* job);
127 const GURL url_;
128 HttpStreamFactoryImpl* const factory_;
129 WebSocketHandshakeStreamBase::CreateHelper* const
130 websocket_handshake_stream_create_helper_;
131 HttpStreamRequest::Delegate* const delegate_;
132 const BoundNetLog net_log_;
134 // At the point where Job is irrevocably tied to the Request, we set this.
135 scoped_ptr<Job> bound_job_;
136 std::set<HttpStreamFactoryImpl::Job*> jobs_;
137 scoped_ptr<const SpdySessionKey> spdy_session_key_;
138 scoped_ptr<const HttpPipelinedHost::Key> http_pipelining_key_;
140 bool completed_;
141 bool was_npn_negotiated_;
142 // Protocol negotiated with the server.
143 NextProto protocol_negotiated_;
144 bool using_spdy_;
146 DISALLOW_COPY_AND_ASSIGN(Request);
149 } // namespace net
151 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_