| 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/network_change_notifier.h" |
| 19 #include "net/base/privacy_mode.h" | 20 #include "net/base/privacy_mode.h" |
| 20 #include "net/base/request_priority.h" | 21 #include "net/base/request_priority.h" |
| 21 #include "net/http/http_stream_factory.h" | 22 #include "net/http/http_stream_factory.h" |
| 22 #include "net/log/net_log_source.h" | 23 #include "net/log/net_log_source.h" |
| 23 #include "net/proxy/proxy_server.h" | 24 #include "net/proxy/proxy_server.h" |
| 24 #include "net/socket/ssl_client_socket.h" | 25 #include "net/socket/ssl_client_socket.h" |
| 25 #include "net/spdy/spdy_session_key.h" | 26 #include "net/spdy/spdy_session_key.h" |
| 26 | 27 |
| 27 namespace net { | 28 namespace net { |
| 28 | 29 |
| 29 class HttpNetworkSession; | 30 class HttpNetworkSession; |
| 30 class ProxyInfo; | 31 class ProxyInfo; |
| 31 class SpdySession; | 32 class SpdySession; |
| 32 class NetLogWithSource; | 33 class NetLogWithSource; |
| 33 | 34 |
| 34 class NET_EXPORT_PRIVATE HttpStreamFactoryImpl : public HttpStreamFactory { | 35 class NET_EXPORT_PRIVATE HttpStreamFactoryImpl |
| 36 : public HttpStreamFactory, |
| 37 NetworkChangeNotifier::MetricsObserver { |
| 35 public: | 38 public: |
| 36 class NET_EXPORT_PRIVATE Job; | 39 class NET_EXPORT_PRIVATE Job; |
| 37 class NET_EXPORT_PRIVATE JobController; | 40 class NET_EXPORT_PRIVATE JobController; |
| 38 class NET_EXPORT_PRIVATE JobFactory; | 41 class NET_EXPORT_PRIVATE JobFactory; |
| 39 class NET_EXPORT_PRIVATE Request; | 42 class NET_EXPORT_PRIVATE Request; |
| 40 // RequestStream may only be called if |for_websockets| is false. | 43 // RequestStream may only be called if |for_websockets| is false. |
| 41 // RequestWebSocketHandshakeStream may only be called if |for_websockets| | 44 // RequestWebSocketHandshakeStream may only be called if |for_websockets| |
| 42 // is true. | 45 // is true. |
| 43 HttpStreamFactoryImpl(HttpNetworkSession* session, bool for_websockets); | 46 HttpStreamFactoryImpl(HttpNetworkSession* session, bool for_websockets); |
| 44 ~HttpStreamFactoryImpl() override; | 47 ~HttpStreamFactoryImpl() override; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 const HostMappingRules* GetHostMappingRules() const override; | 81 const HostMappingRules* GetHostMappingRules() const override; |
| 79 void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd, | 82 void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd, |
| 80 const std::string& parent_absolute_name) const override; | 83 const std::string& parent_absolute_name) const override; |
| 81 | 84 |
| 82 enum JobType { | 85 enum JobType { |
| 83 MAIN, | 86 MAIN, |
| 84 ALTERNATIVE, | 87 ALTERNATIVE, |
| 85 PRECONNECT, | 88 PRECONNECT, |
| 86 }; | 89 }; |
| 87 | 90 |
| 91 // NetworkChangeNotifier::MetricsObserver implementation. |
| 92 void OnMetricsFinalize() override; |
| 93 |
| 88 private: | 94 private: |
| 89 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority); | 95 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority); |
| 90 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); | 96 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); |
| 91 | 97 |
| 92 friend class HttpStreamFactoryImplPeer; | 98 friend class HttpStreamFactoryImplPeer; |
| 93 | 99 |
| 94 typedef std::set<Request*> RequestSet; | 100 typedef std::set<Request*> RequestSet; |
| 95 typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap; | 101 typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap; |
| 96 typedef std::set<std::unique_ptr<JobController>> JobControllerSet; | 102 typedef std::set<std::unique_ptr<JobController>> JobControllerSet; |
| 97 | 103 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 std::unique_ptr<JobFactory> job_factory_; | 190 std::unique_ptr<JobFactory> job_factory_; |
| 185 | 191 |
| 186 // Set of proxy servers that support request priorities to which subsequent | 192 // Set of proxy servers that support request priorities to which subsequent |
| 187 // preconnects should be skipped. | 193 // preconnects should be skipped. |
| 188 std::set<PreconnectingProxyServer> preconnecting_proxy_servers_; | 194 std::set<PreconnectingProxyServer> preconnecting_proxy_servers_; |
| 189 | 195 |
| 190 SpdySessionRequestMap spdy_session_request_map_; | 196 SpdySessionRequestMap spdy_session_request_map_; |
| 191 | 197 |
| 192 const bool for_websockets_; | 198 const bool for_websockets_; |
| 193 | 199 |
| 200 base::ThreadChecker thread_checker_; |
| 201 |
| 194 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); | 202 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); |
| 195 }; | 203 }; |
| 196 | 204 |
| 197 } // namespace net | 205 } // namespace net |
| 198 | 206 |
| 199 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ | 207 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ |
| OLD | NEW |