WebViewGuest: Add missing break statement.
[chromium-blink-merge.git] / net / http / http_stream_factory_impl_request.h
blob55f13b9be2cc1a65755ddb02448c4dc941f41191
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 HttpStream;
20 class SpdySession;
22 class HttpStreamFactoryImpl::Request : public HttpStreamRequest {
23 public:
24 Request(const GURL& url,
25 HttpStreamFactoryImpl* factory,
26 HttpStreamRequest::Delegate* delegate,
27 WebSocketHandshakeStreamBase::CreateHelper*
28 websocket_handshake_stream_create_helper,
29 const BoundNetLog& net_log);
30 virtual ~Request();
32 // The GURL from the HttpRequestInfo the started the Request.
33 const GURL& url() const { return url_; }
35 // Called when the Job determines the appropriate |spdy_session_key| for the
36 // Request. Note that this does not mean that SPDY is necessarily supported
37 // for this SpdySessionKey, since we may need to wait for NPN to complete
38 // before knowing if SPDY is available.
39 void SetSpdySessionKey(const SpdySessionKey& spdy_session_key);
41 // Attaches |job| to this request. Does not mean that Request will use |job|,
42 // but Request will own |job|.
43 void AttachJob(HttpStreamFactoryImpl::Job* job);
45 // Marks completion of the request. Must be called before OnStreamReady().
46 // |job_net_log| is the BoundNetLog of the Job that fulfilled this request.
47 void Complete(bool was_npn_negotiated,
48 NextProto protocol_negotiated,
49 bool using_spdy,
50 const BoundNetLog& job_net_log);
52 // If this Request has a |spdy_session_key_|, remove this session from the
53 // SpdySessionRequestMap.
54 void RemoveRequestFromSpdySessionRequestMap();
56 // Called by an attached Job if it sets up a SpdySession.
57 void OnNewSpdySessionReady(Job* job,
58 scoped_ptr<HttpStream> stream,
59 const base::WeakPtr<SpdySession>& spdy_session,
60 bool direct);
62 WebSocketHandshakeStreamBase::CreateHelper*
63 websocket_handshake_stream_create_helper() {
64 return websocket_handshake_stream_create_helper_;
67 // HttpStreamRequest::Delegate methods which we implement. Note we don't
68 // actually subclass HttpStreamRequest::Delegate.
70 void OnStreamReady(Job* job,
71 const SSLConfig& used_ssl_config,
72 const ProxyInfo& used_proxy_info,
73 HttpStreamBase* stream);
74 void OnWebSocketHandshakeStreamReady(Job* job,
75 const SSLConfig& used_ssl_config,
76 const ProxyInfo& used_proxy_info,
77 WebSocketHandshakeStreamBase* stream);
78 void OnStreamFailed(Job* job, int status, const SSLConfig& used_ssl_config);
79 void OnCertificateError(Job* job,
80 int status,
81 const SSLConfig& used_ssl_config,
82 const SSLInfo& ssl_info);
83 void OnNeedsProxyAuth(Job* job,
84 const HttpResponseInfo& proxy_response,
85 const SSLConfig& used_ssl_config,
86 const ProxyInfo& used_proxy_info,
87 HttpAuthController* auth_controller);
88 void OnNeedsClientAuth(Job* job,
89 const SSLConfig& used_ssl_config,
90 SSLCertRequestInfo* cert_info);
91 void OnHttpsProxyTunnelResponse(
92 Job *job,
93 const HttpResponseInfo& response_info,
94 const SSLConfig& used_ssl_config,
95 const ProxyInfo& used_proxy_info,
96 HttpStreamBase* stream);
98 // HttpStreamRequest methods.
100 virtual int RestartTunnelWithProxyAuth(
101 const AuthCredentials& credentials) OVERRIDE;
102 virtual void SetPriority(RequestPriority priority) OVERRIDE;
103 virtual LoadState GetLoadState() const OVERRIDE;
104 virtual bool was_npn_negotiated() const OVERRIDE;
105 virtual NextProto protocol_negotiated() const OVERRIDE;
106 virtual bool using_spdy() const OVERRIDE;
108 private:
109 // Used to orphan all jobs in |jobs_| other than |job| which becomes "bound"
110 // to the request.
111 void OrphanJobsExcept(Job* job);
113 // Used to orphan all jobs in |jobs_|.
114 void OrphanJobs();
116 // Called when a Job succeeds.
117 void OnJobSucceeded(Job* job);
119 const GURL url_;
120 HttpStreamFactoryImpl* const factory_;
121 WebSocketHandshakeStreamBase::CreateHelper* const
122 websocket_handshake_stream_create_helper_;
123 HttpStreamRequest::Delegate* const delegate_;
124 const BoundNetLog net_log_;
126 // At the point where Job is irrevocably tied to the Request, we set this.
127 scoped_ptr<Job> bound_job_;
128 std::set<HttpStreamFactoryImpl::Job*> jobs_;
129 scoped_ptr<const SpdySessionKey> spdy_session_key_;
131 bool completed_;
132 bool was_npn_negotiated_;
133 // Protocol negotiated with the server.
134 NextProto protocol_negotiated_;
135 bool using_spdy_;
137 DISALLOW_COPY_AND_ASSIGN(Request);
140 } // namespace net
142 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_