| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 <set> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "net/http/http_stream_factory_impl.h" | 12 #include "net/http/http_stream_factory_impl.h" |
| 13 #include "net/log/net_log.h" | 13 #include "net/log/net_log.h" |
| 14 #include "net/net_features.h" | 14 #include "net/net_features.h" |
| 15 #include "net/socket/connection_attempts.h" | 15 #include "net/socket/connection_attempts.h" |
| 16 #include "net/socket/ssl_client_socket.h" | 16 #include "net/socket/ssl_client_socket.h" |
| 17 #include "net/spdy/spdy_session_key.h" | 17 #include "net/spdy/spdy_session_key.h" |
| 18 #include "net/ssl/ssl_failure_state.h" | 18 #include "net/ssl/ssl_failure_state.h" |
| 19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 | 22 |
| 23 class BidirectionalStreamJob; | 23 class BidirectionalStreamJob; |
| 24 class ClientSocketHandle; | 24 class ClientSocketHandle; |
| 25 class HttpStream; | 25 class HttpStream; |
| 26 class SpdySession; | 26 class SpdySession; |
| 27 | 27 |
| 28 class HttpStreamFactoryImpl::Request : public HttpStreamRequest { | 28 class HttpStreamFactoryImpl::Request : public HttpStreamRequest { |
| 29 public: | 29 public: |
| 30 // Indicates which type of stream is requested. |
| 31 enum StreamType { |
| 32 BIDIRECTIONAL_STREAM_SPDY_JOB, |
| 33 HTTP_STREAM, |
| 34 }; |
| 35 |
| 30 Request(const GURL& url, | 36 Request(const GURL& url, |
| 31 HttpStreamFactoryImpl* factory, | 37 HttpStreamFactoryImpl* factory, |
| 32 HttpStreamRequest::Delegate* delegate, | 38 HttpStreamRequest::Delegate* delegate, |
| 33 WebSocketHandshakeStreamBase::CreateHelper* | 39 WebSocketHandshakeStreamBase::CreateHelper* |
| 34 websocket_handshake_stream_create_helper, | 40 websocket_handshake_stream_create_helper, |
| 35 const BoundNetLog& net_log, | 41 const BoundNetLog& net_log, |
| 36 StreamType stream_type); | 42 StreamType stream_type); |
| 37 | 43 |
| 38 ~Request() override; | 44 ~Request() override; |
| 39 | 45 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 56 // Marks completion of the request. Must be called before OnStreamReady(). | 62 // Marks completion of the request. Must be called before OnStreamReady(). |
| 57 void Complete(bool was_npn_negotiated, | 63 void Complete(bool was_npn_negotiated, |
| 58 NextProto protocol_negotiated, | 64 NextProto protocol_negotiated, |
| 59 bool using_spdy); | 65 bool using_spdy); |
| 60 | 66 |
| 61 // If this Request has a |spdy_session_key_|, remove this session from the | 67 // If this Request has a |spdy_session_key_|, remove this session from the |
| 62 // SpdySessionRequestMap. | 68 // SpdySessionRequestMap. |
| 63 void RemoveRequestFromSpdySessionRequestMap(); | 69 void RemoveRequestFromSpdySessionRequestMap(); |
| 64 | 70 |
| 65 // Called by an attached Job if it sets up a SpdySession. | 71 // Called by an attached Job if it sets up a SpdySession. |
| 66 // |stream| is null when |stream_type| is HttpStreamRequest::HTTP_STREAM. | 72 // |stream| is null when |for_bidirectional| is true. |
| 67 // |bidirectional_stream_spdy_job| is null when |stream_type| is | 73 // |bidirectional_stream_spdy_job| is null when |for_bidirectional| is false. |
| 68 // HttpStreamRequest::BIDIRECTIONAL_STREAM. | |
| 69 void OnNewSpdySessionReady( | 74 void OnNewSpdySessionReady( |
| 70 Job* job, | 75 Job* job, |
| 71 scoped_ptr<HttpStream> stream, | 76 scoped_ptr<HttpStream> stream, |
| 72 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) | 77 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) |
| 73 scoped_ptr<BidirectionalStreamJob> bidirectional_stream_spdy_job, | 78 scoped_ptr<BidirectionalStreamJob> bidirectional_stream_spdy_job, |
| 74 #else | 79 #else |
| 75 void* unused, | 80 void* unused, |
| 76 #endif | 81 #endif |
| 77 const base::WeakPtr<SpdySession>& spdy_session, | 82 const base::WeakPtr<SpdySession>& spdy_session, |
| 78 bool direct); | 83 bool direct); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 132 |
| 128 // HttpStreamRequest methods. | 133 // HttpStreamRequest methods. |
| 129 | 134 |
| 130 int RestartTunnelWithProxyAuth(const AuthCredentials& credentials) override; | 135 int RestartTunnelWithProxyAuth(const AuthCredentials& credentials) override; |
| 131 void SetPriority(RequestPriority priority) override; | 136 void SetPriority(RequestPriority priority) override; |
| 132 LoadState GetLoadState() const override; | 137 LoadState GetLoadState() const override; |
| 133 bool was_npn_negotiated() const override; | 138 bool was_npn_negotiated() const override; |
| 134 NextProto protocol_negotiated() const override; | 139 NextProto protocol_negotiated() const override; |
| 135 bool using_spdy() const override; | 140 bool using_spdy() const override; |
| 136 const ConnectionAttempts& connection_attempts() const override; | 141 const ConnectionAttempts& connection_attempts() const override; |
| 137 HttpStreamRequest::StreamType stream_type() const { return stream_type_; } | 142 bool for_bidirectional() const { return for_bidirectional_; } |
| 138 | 143 |
| 139 private: | 144 private: |
| 140 // Used to bind |job| to the request and orphan all other jobs in |jobs_|. | 145 // Used to bind |job| to the request and orphan all other jobs in |jobs_|. |
| 141 void BindJob(Job* job); | 146 void BindJob(Job* job); |
| 142 | 147 |
| 143 // Used to orphan all jobs in |jobs_|. | 148 // Used to orphan all jobs in |jobs_|. |
| 144 void OrphanJobs(); | 149 void OrphanJobs(); |
| 145 | 150 |
| 146 // Used to cancel all jobs in |jobs_|. | 151 // Used to cancel all jobs in |jobs_|. |
| 147 void CancelJobs(); | 152 void CancelJobs(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 161 std::set<HttpStreamFactoryImpl::Job*> jobs_; | 166 std::set<HttpStreamFactoryImpl::Job*> jobs_; |
| 162 scoped_ptr<const SpdySessionKey> spdy_session_key_; | 167 scoped_ptr<const SpdySessionKey> spdy_session_key_; |
| 163 | 168 |
| 164 bool completed_; | 169 bool completed_; |
| 165 bool was_npn_negotiated_; | 170 bool was_npn_negotiated_; |
| 166 // Protocol negotiated with the server. | 171 // Protocol negotiated with the server. |
| 167 NextProto protocol_negotiated_; | 172 NextProto protocol_negotiated_; |
| 168 bool using_spdy_; | 173 bool using_spdy_; |
| 169 ConnectionAttempts connection_attempts_; | 174 ConnectionAttempts connection_attempts_; |
| 170 | 175 |
| 171 const HttpStreamRequest::StreamType stream_type_; | 176 const bool for_bidirectional_; |
| 172 DISALLOW_COPY_AND_ASSIGN(Request); | 177 DISALLOW_COPY_AND_ASSIGN(Request); |
| 173 }; | 178 }; |
| 174 | 179 |
| 175 } // namespace net | 180 } // namespace net |
| 176 | 181 |
| 177 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_ | 182 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_ |
| OLD | NEW |