Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: net/http/http_stream_factory_impl.h

Issue 1941083002: JobController 1: Adding a new class HttpStreamFactoryImpl::JobController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 const HttpRequestInfo& info, 55 const HttpRequestInfo& info,
56 RequestPriority priority, 56 RequestPriority priority,
57 const SSLConfig& server_ssl_config, 57 const SSLConfig& server_ssl_config,
58 const SSLConfig& proxy_ssl_config, 58 const SSLConfig& proxy_ssl_config,
59 HttpStreamRequest::Delegate* delegate, 59 HttpStreamRequest::Delegate* delegate,
60 const BoundNetLog& net_log) override; 60 const BoundNetLog& net_log) override;
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 size_t num_orphaned_jobs() const { return orphaned_job_set_.size(); }
66
67 private: 65 private:
68 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority); 66 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority);
69 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); 67 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob);
70 68
71 class NET_EXPORT_PRIVATE Request; 69 class NET_EXPORT_PRIVATE Request;
72 class NET_EXPORT_PRIVATE Job; 70 class NET_EXPORT_PRIVATE Job;
71 class NET_EXPORT_PRIVATE JobController;
73 72
74 typedef std::set<Request*> RequestSet; 73 typedef std::set<Request*> RequestSet;
75 typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap; 74 typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap;
75 typedef std::set<JobController*> JobControllerSet;
Ryan Hamilton 2016/05/06 20:49:01 Since the controllers are owned by the factory, th
Zhongyi Shi 2016/05/12 07:26:23 Done.
76 76
77 HttpStreamRequest* RequestStreamInternal( 77 HttpStreamRequest* RequestStreamInternal(
78 const HttpRequestInfo& info, 78 const HttpRequestInfo& info,
79 RequestPriority priority, 79 RequestPriority priority,
80 const SSLConfig& server_ssl_config, 80 const SSLConfig& server_ssl_config,
81 const SSLConfig& proxy_ssl_config, 81 const SSLConfig& proxy_ssl_config,
82 HttpStreamRequest::Delegate* delegate, 82 HttpStreamRequest::Delegate* delegate,
83 WebSocketHandshakeStreamBase::CreateHelper* create_helper, 83 WebSocketHandshakeStreamBase::CreateHelper* create_helper,
84 HttpStreamRequest::StreamType stream_type, 84 HttpStreamRequest::StreamType stream_type,
85 const BoundNetLog& net_log); 85 const BoundNetLog& net_log);
86 86
87 AlternativeService GetAlternativeServiceFor( 87 AlternativeService GetAlternativeServiceFor(
88 const HttpRequestInfo& request_info, 88 const HttpRequestInfo& request_info,
89 HttpStreamRequest::Delegate* delegate, 89 HttpStreamRequest::Delegate* delegate,
90 HttpStreamRequest::StreamType stream_type); 90 HttpStreamRequest::StreamType stream_type);
91 91
92 // Detaches |job| from |request|.
93 void OrphanJob(Job* job, const Request* request);
94
95 // Called when a SpdySession is ready. It will find appropriate Requests and 92 // Called when a SpdySession is ready. It will find appropriate Requests and
96 // fulfill them. |direct| indicates whether or not |spdy_session| uses a 93 // fulfill them. |direct| indicates whether or not |spdy_session| uses a
97 // proxy. 94 // proxy.
98 void OnNewSpdySessionReady(const base::WeakPtr<SpdySession>& spdy_session, 95 void OnNewSpdySessionReady(const base::WeakPtr<SpdySession>& spdy_session,
99 bool direct, 96 bool direct,
100 const SSLConfig& used_ssl_config, 97 const SSLConfig& used_ssl_config,
101 const ProxyInfo& used_proxy_info, 98 const ProxyInfo& used_proxy_info,
102 bool was_npn_negotiated, 99 bool was_npn_negotiated,
103 NextProto protocol_negotiated, 100 NextProto protocol_negotiated,
104 bool using_spdy, 101 bool using_spdy,
105 const BoundNetLog& net_log); 102 const BoundNetLog& net_log);
106 103
107 // Called when the Job detects that the endpoint indicated by the 104 // Called when the Job detects that the endpoint indicated by the
108 // Alternate-Protocol does not work. Lets the factory update 105 // Alternate-Protocol does not work. Lets the factory update
109 // HttpAlternateProtocols with the failure and resets the SPDY session key. 106 // HttpAlternateProtocols with the failure and resets the SPDY session key.
110 void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin); 107 void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin);
111 108
112 // Invoked when an orphaned Job finishes.
113 void OnOrphanedJobComplete(const Job* job);
114
115 // Invoked when the Job finishes preconnecting sockets.
116 void OnPreconnectsComplete(const Job* job);
117
118 // Called when the Preconnect completes. Used for testing. 109 // Called when the Preconnect completes. Used for testing.
119 virtual void OnPreconnectsCompleteInternal() {} 110 virtual void OnPreconnectsCompleteInternal() {}
120 111
112 // Called when the JobController finishes service. Delete the JobController
113 // from |job_controller_set_|.
114 void OnJobControllerComplete(JobController* controller);
115
121 // Returns true if QUIC is whitelisted for |host|. 116 // Returns true if QUIC is whitelisted for |host|.
122 bool IsQuicWhitelistedForHost(const std::string& host); 117 bool IsQuicWhitelistedForHost(const std::string& host);
123 118
124 HttpNetworkSession* const session_; 119 HttpNetworkSession* const session_;
125 120
126 // All Requests are handed out to clients. By the time HttpStreamFactoryImpl 121 // All Requests are handed out to clients. By the time HttpStreamFactoryImpl
127 // is destroyed, all Requests should be deleted (which should remove them from 122 // is destroyed, all Requests should be deleted (which should remove them from
128 // |request_map_|. The Requests will delete the corresponding job. 123 // |request_map_|. The Requests will delete the corresponding job.
129 std::map<const Job*, Request*> request_map_; 124 std::map<const Job*, Request*> request_map_;
130 125
126 JobControllerSet job_controller_set_;
127
131 SpdySessionRequestMap spdy_session_request_map_; 128 SpdySessionRequestMap spdy_session_request_map_;
132 129
133 // These jobs correspond to jobs orphaned by Requests and now owned by
134 // HttpStreamFactoryImpl. Since they are no longer tied to Requests, they will
135 // not be canceled when Requests are canceled. Therefore, in
136 // ~HttpStreamFactoryImpl, it is possible for some jobs to still exist in this
137 // set. Leftover jobs will be deleted when the factory is destroyed.
138 std::set<const Job*> orphaned_job_set_;
139
140 // These jobs correspond to preconnect requests and have no associated Request
141 // object. They're owned by HttpStreamFactoryImpl. Leftover jobs will be
142 // deleted when the factory is destroyed.
143 std::set<const Job*> preconnect_job_set_;
144
145 const bool for_websockets_; 130 const bool for_websockets_;
146 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); 131 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl);
147 }; 132 };
148 133
149 } // namespace net 134 } // namespace net
150 135
151 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ 136 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | net/http/http_stream_factory_impl.cc » ('j') | net/http/http_stream_factory_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698