| 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> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "net/base/host_port_pair.h" | 17 #include "net/base/host_port_pair.h" |
| 18 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
| 19 #include "net/base/privacy_mode.h" |
| 19 #include "net/base/request_priority.h" | 20 #include "net/base/request_priority.h" |
| 20 #include "net/http/http_stream_factory.h" | 21 #include "net/http/http_stream_factory.h" |
| 21 #include "net/proxy/proxy_server.h" | 22 #include "net/proxy/proxy_server.h" |
| 22 #include "net/socket/ssl_client_socket.h" | 23 #include "net/socket/ssl_client_socket.h" |
| 23 #include "net/spdy/spdy_session_key.h" | 24 #include "net/spdy/spdy_session_key.h" |
| 24 | 25 |
| 25 namespace net { | 26 namespace net { |
| 26 | 27 |
| 27 class HttpNetworkSession; | 28 class HttpNetworkSession; |
| 28 class ProxyInfo; | 29 class ProxyInfo; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 private: | 79 private: |
| 79 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority); | 80 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority); |
| 80 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); | 81 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); |
| 81 | 82 |
| 82 friend class HttpStreamFactoryImplPeer; | 83 friend class HttpStreamFactoryImplPeer; |
| 83 | 84 |
| 84 typedef std::set<Request*> RequestSet; | 85 typedef std::set<Request*> RequestSet; |
| 85 typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap; | 86 typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap; |
| 86 typedef std::set<std::unique_ptr<JobController>> JobControllerSet; | 87 typedef std::set<std::unique_ptr<JobController>> JobControllerSet; |
| 87 | 88 |
| 89 // |PreconnectingProxyServer| holds information of a connection to a single |
| 90 // proxy server. |
| 91 struct PreconnectingProxyServer { |
| 92 PreconnectingProxyServer(ProxyServer proxy_server, |
| 93 PrivacyMode privacy_mode); |
| 94 |
| 95 // Needed to be an element of std::set. |
| 96 bool operator<(const PreconnectingProxyServer& other) const; |
| 97 bool operator==(const PreconnectingProxyServer& other) const; |
| 98 |
| 99 const ProxyServer proxy_server; |
| 100 const PrivacyMode privacy_mode; |
| 101 }; |
| 102 |
| 88 // Values must not be changed or reused. Keep in sync with identically named | 103 // Values must not be changed or reused. Keep in sync with identically named |
| 89 // enum in histograms.xml. | 104 // enum in histograms.xml. |
| 90 enum AlternativeServiceType { | 105 enum AlternativeServiceType { |
| 91 NO_ALTERNATIVE_SERVICE = 0, | 106 NO_ALTERNATIVE_SERVICE = 0, |
| 92 QUIC_SAME_DESTINATION = 1, | 107 QUIC_SAME_DESTINATION = 1, |
| 93 QUIC_DIFFERENT_DESTINATION = 2, | 108 QUIC_DIFFERENT_DESTINATION = 2, |
| 94 NOT_QUIC_SAME_DESTINATION = 3, | 109 NOT_QUIC_SAME_DESTINATION = 3, |
| 95 NOT_QUIC_DIFFERENT_DESTINATION = 4, | 110 NOT_QUIC_DIFFERENT_DESTINATION = 4, |
| 96 MAX_ALTERNATIVE_SERVICE_TYPE | 111 MAX_ALTERNATIVE_SERVICE_TYPE |
| 97 }; | 112 }; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 124 void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin); | 139 void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin); |
| 125 | 140 |
| 126 // Called when the Preconnect completes. Used for testing. | 141 // Called when the Preconnect completes. Used for testing. |
| 127 virtual void OnPreconnectsCompleteInternal() {} | 142 virtual void OnPreconnectsCompleteInternal() {} |
| 128 | 143 |
| 129 // Called when the JobController finishes service. Delete the JobController | 144 // Called when the JobController finishes service. Delete the JobController |
| 130 // from |job_controller_set_|. | 145 // from |job_controller_set_|. |
| 131 void OnJobControllerComplete(JobController* controller); | 146 void OnJobControllerComplete(JobController* controller); |
| 132 | 147 |
| 133 // Returns true if a connection to the proxy server contained in |proxy_info| | 148 // Returns true if a connection to the proxy server contained in |proxy_info| |
| 134 // can be skipped by a job controlled by |controller|. | 149 // that has privacy mode |privacy_mode| can be skipped by a job controlled by |
| 150 // |controller|. |
| 135 bool OnInitConnection(const JobController& controller, | 151 bool OnInitConnection(const JobController& controller, |
| 136 const ProxyInfo& proxy_info); | 152 const ProxyInfo& proxy_info, |
| 153 PrivacyMode privacy_mode); |
| 137 | 154 |
| 138 // Notifies |this| that a stream to the proxy server contained in |proxy_info| | 155 // Notifies |this| that a stream to the proxy server contained in |proxy_info| |
| 139 // is ready. | 156 // with privacy mode |privacy_mode| is ready. |
| 140 void OnStreamReady(const ProxyInfo& proxy_info); | 157 void OnStreamReady(const ProxyInfo& proxy_info, PrivacyMode privacy_mode); |
| 141 | 158 |
| 142 // Returns true if |proxy_info| contains a proxy server that supports request | 159 // Returns true if |proxy_info| contains a proxy server that supports request |
| 143 // priorities. | 160 // priorities. |
| 144 bool ProxyServerSupportsPriorities(const ProxyInfo& proxy_info) const; | 161 bool ProxyServerSupportsPriorities(const ProxyInfo& proxy_info) const; |
| 145 | 162 |
| 146 HttpNetworkSession* const session_; | 163 HttpNetworkSession* const session_; |
| 147 | 164 |
| 148 // All Requests are handed out to clients. By the time HttpStreamFactoryImpl | 165 // All Requests are handed out to clients. By the time HttpStreamFactoryImpl |
| 149 // is destroyed, all Requests should be deleted (which should remove them from | 166 // is destroyed, all Requests should be deleted (which should remove them from |
| 150 // |request_map_|. The Requests will delete the corresponding job. | 167 // |request_map_|. The Requests will delete the corresponding job. |
| 151 std::map<const Job*, Request*> request_map_; | 168 std::map<const Job*, Request*> request_map_; |
| 152 | 169 |
| 153 // All Requests/Preconnects are assigned with a JobController to manage | 170 // All Requests/Preconnects are assigned with a JobController to manage |
| 154 // serving Job(s). JobController might outlive Request when Request | 171 // serving Job(s). JobController might outlive Request when Request |
| 155 // is served while there's some working Job left. JobController will be | 172 // is served while there's some working Job left. JobController will be |
| 156 // deleted from |job_controller_set_| when it determines the completion of | 173 // deleted from |job_controller_set_| when it determines the completion of |
| 157 // its work. | 174 // its work. |
| 158 JobControllerSet job_controller_set_; | 175 JobControllerSet job_controller_set_; |
| 159 | 176 |
| 160 // Factory used by job controllers for creating jobs. | 177 // Factory used by job controllers for creating jobs. |
| 161 std::unique_ptr<JobFactory> job_factory_; | 178 std::unique_ptr<JobFactory> job_factory_; |
| 162 | 179 |
| 163 // Set of proxy servers that support request priorities to which subsequent | 180 // Set of proxy servers that support request priorities to which subsequent |
| 164 // preconnects should be skipped. | 181 // preconnects should be skipped. |
| 165 std::set<ProxyServer> preconnecting_proxy_servers_; | 182 std::set<PreconnectingProxyServer> preconnecting_proxy_servers_; |
| 166 | 183 |
| 167 SpdySessionRequestMap spdy_session_request_map_; | 184 SpdySessionRequestMap spdy_session_request_map_; |
| 168 | 185 |
| 169 const bool for_websockets_; | 186 const bool for_websockets_; |
| 170 | 187 |
| 171 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); | 188 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); |
| 172 }; | 189 }; |
| 173 | 190 |
| 174 } // namespace net | 191 } // namespace net |
| 175 | 192 |
| 176 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ | 193 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ |
| OLD | NEW |