| 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_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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 void PreconnectStreams(int num_streams, const HttpRequestInfo& info) override; | 62 void PreconnectStreams(int num_streams, const HttpRequestInfo& info) override; |
| 63 const HostMappingRules* GetHostMappingRules() const override; | 63 const HostMappingRules* GetHostMappingRules() const override; |
| 64 | 64 |
| 65 enum JobType { | 65 enum JobType { |
| 66 MAIN, | 66 MAIN, |
| 67 ALTERNATIVE, | 67 ALTERNATIVE, |
| 68 PRECONNECT, | 68 PRECONNECT, |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 enum State { |
| 72 STATE_START, |
| 73 STATE_RESOLVE_PROXY, |
| 74 STATE_RESOLVE_PROXY_COMPLETE, |
| 75 |
| 76 // Note that when Alternate-Protocol says we can connect to an alternate |
| 77 // port using a different protocol, we have the choice of communicating over |
| 78 // the original protocol, or speaking the alternate protocol (currently, |
| 79 // only npn-spdy) over an alternate port. For a cold page load, the http |
| 80 // connection that delivers the http response that has the |
| 81 // Alternate-Protocol header will already be warm. So, blocking the next |
| 82 // http request on establishing a new npn-spdy connection would incur extra |
| 83 // latency. Even if the http connection was not reused, establishing a new |
| 84 // http connection is typically faster than npn-spdy, since npn-spdy |
| 85 // requires a SSL handshake. Therefore, we start both the http and the |
| 86 // npn-spdy jobs in parallel. In order not to unnecessarily waste sockets, |
| 87 // we have the http job block on the npn-spdy job after proxy resolution. |
| 88 // The npn-spdy job will Resume() the http job if, in |
| 89 // STATE_INIT_CONNECTION_COMPLETE, it detects an error or does not find an |
| 90 // existing SpdySession. In that case, the http and npn-spdy jobs will race. |
| 91 // When QUIC protocol is used by the npn-spdy job, then http job will wait |
| 92 // for |wait_time_| when the http job was resumed. |
| 93 STATE_WAIT_FOR_JOB, |
| 94 STATE_WAIT_FOR_JOB_COMPLETE, |
| 95 |
| 96 STATE_INIT_CONNECTION, |
| 97 STATE_INIT_CONNECTION_COMPLETE, |
| 98 STATE_WAITING_USER_ACTION, |
| 99 STATE_RESTART_TUNNEL_AUTH, |
| 100 STATE_RESTART_TUNNEL_AUTH_COMPLETE, |
| 101 STATE_CREATE_STREAM, |
| 102 STATE_CREATE_STREAM_COMPLETE, |
| 103 STATE_DRAIN_BODY_FOR_AUTH_RESTART, |
| 104 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, |
| 105 STATE_DONE, |
| 106 STATE_NONE |
| 107 }; |
| 108 |
| 71 private: | 109 private: |
| 72 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority); | 110 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority); |
| 73 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); | 111 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); |
| 74 | 112 |
| 75 class NET_EXPORT_PRIVATE Request; | 113 class NET_EXPORT_PRIVATE Request; |
| 76 class NET_EXPORT_PRIVATE Job; | 114 class NET_EXPORT_PRIVATE Job; |
| 77 class NET_EXPORT_PRIVATE JobController; | 115 class NET_EXPORT_PRIVATE JobController; |
| 78 | 116 |
| 79 typedef std::set<Request*> RequestSet; | 117 typedef std::set<Request*> RequestSet; |
| 80 typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap; | 118 typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 163 |
| 126 SpdySessionRequestMap spdy_session_request_map_; | 164 SpdySessionRequestMap spdy_session_request_map_; |
| 127 | 165 |
| 128 const bool for_websockets_; | 166 const bool for_websockets_; |
| 129 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); | 167 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); |
| 130 }; | 168 }; |
| 131 | 169 |
| 132 } // namespace net | 170 } // namespace net |
| 133 | 171 |
| 134 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ | 172 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ |
| OLD | NEW |