Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_JOB_CONTROLLER_H_ | 5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_ |
| 6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_ | 6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "net/http/http_stream_factory_impl.h" | 8 #include "net/http/http_stream_factory_impl.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 std::unique_ptr<BidirectionalStreamImpl> bidirectional_stream_impl, | 110 std::unique_ptr<BidirectionalStreamImpl> bidirectional_stream_impl, |
| 111 const base::WeakPtr<SpdySession>& spdy_session, | 111 const base::WeakPtr<SpdySession>& spdy_session, |
| 112 bool direct); | 112 bool direct); |
| 113 | 113 |
| 114 // Invoked when the Job finishes pre-connecting sockets. | 114 // Invoked when the Job finishes pre-connecting sockets. |
| 115 void OnPreconnectsComplete(Job* job); | 115 void OnPreconnectsComplete(Job* job); |
| 116 | 116 |
| 117 // Invoked when an orphaned Job finishes. | 117 // Invoked when an orphaned Job finishes. |
| 118 void OnOrphanedJobComplete(const Job* job); | 118 void OnOrphanedJobComplete(const Job* job); |
| 119 | 119 |
| 120 // Removes cached reference to |job|. | |
| 121 void OnJobDeletion(Job* job); | |
| 122 | |
| 120 // Called by an attached Job to record connection attempts made by the socket | 123 // Called by an attached Job to record connection attempts made by the socket |
| 121 // layer to |request_|. | 124 // layer to |request_|. |
| 122 void AddConnectionAttemptsToRequest(const ConnectionAttempts& attempts); | 125 void AddConnectionAttemptsToRequest(const ConnectionAttempts& attempts); |
| 123 | 126 |
| 124 // Called when Job determines the appropriate |spdy_session_key| for the | 127 // Called when Job determines the appropriate |spdy_session_key| for the |
| 125 // Request. Note that this does not mean that SPDY is necessarily supported | 128 // Request. Note that this does not mean that SPDY is necessarily supported |
| 126 // for this SpdySessionKey, since we may need to wait for NPN to complete | 129 // for this SpdySessionKey, since we may need to wait for NPN to complete |
| 127 // before knowing if SPDY is available. | 130 // before knowing if SPDY is available. |
| 128 void SetSpdySessionKey(const SpdySessionKey& spdy_session_key); | 131 void SetSpdySessionKey(const SpdySessionKey& spdy_session_key); |
| 129 | 132 |
| 130 // Remove session from the SpdySessionRequestMap. | 133 // Remove session from the SpdySessionRequestMap. |
| 131 void RemoveRequestFromSpdySessionRequestMap(); | 134 void RemoveRequestFromSpdySessionRequestMap(); |
| 132 | 135 |
| 133 void MaybeNotifyFactoryOfCompletion(); | 136 void MaybeNotifyFactoryOfCompletion(); |
| 134 | 137 |
| 138 void MaybeResumeOtherJob(Job* job, const base::TimeDelta& delay); | |
| 139 | |
| 135 const BoundNetLog& GetNetLogFromRequest() const; | 140 const BoundNetLog& GetNetLogFromRequest() const; |
| 136 | 141 |
| 137 SpdySessionRequestMap& GetSpdySessionRequestMap() { | 142 SpdySessionRequestMap& GetSpdySessionRequestMap() { |
| 138 return factory_->spdy_session_request_map_; | 143 return factory_->spdy_session_request_map_; |
| 139 } | 144 } |
| 140 | 145 |
| 141 bool for_websockets() { return factory_->for_websockets_; } | 146 bool for_websockets() { return factory_->for_websockets_; } |
| 142 | 147 |
| 148 bool racing() { return racing_; } | |
| 149 | |
| 143 WebSocketHandshakeStreamBase::CreateHelper* | 150 WebSocketHandshakeStreamBase::CreateHelper* |
| 144 websocket_handshake_stream_create_helper(); | 151 websocket_handshake_stream_create_helper(); |
| 145 | 152 |
| 146 private: | 153 private: |
| 147 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority); | 154 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority); |
| 148 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); | 155 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); |
| 149 | 156 |
| 150 // Creates Job(s) for |request_|. Jobs will be owned by |this|. | 157 // Creates Job(s) for |request_|. Jobs will be owned by |this|. |
| 151 void CreateJobs(); | 158 void CreateJobs(); |
| 152 | 159 |
| 153 // Attaches |job| to |request_|. Does not mean that |request_| will use |job|. | 160 // Attaches |job| to |request_|. Does not mean that |request_| will use |job|. |
| 154 void AttachJob(Job* job); | 161 void AttachJob(Job* job); |
| 155 | 162 |
| 156 HttpStreamFactoryImpl* factory_; | 163 HttpStreamFactoryImpl* factory_; |
| 157 | 164 |
| 158 // Request will be handed out to factory once created. This just keeps an | 165 // Request will be handed out to factory once created. This just keeps an |
| 159 // reference. It will be set to NULL once the request is completed. | 166 // reference. It will be set to NULL once the request is completed. |
| 160 Request* request_; | 167 Request* request_; |
| 161 | 168 |
| 162 std::set<Job*> jobs_; | 169 std::set<Job*> jobs_; |
| 163 | 170 |
| 164 // |main_job_| is a job waiting to see if |alternative_job_| can reuse a | 171 // |main_job_| is a job waiting to see if |alternative_job_| can reuse a |
| 165 // connection. If |alternative_job_| is unable to do so, |this| will notify | 172 // connection. If |alternative_job_| is unable to do so, |this| will notify |
| 166 // |main_job_| to proceed and then race the two jobs. | 173 // |main_job_| to proceed and then race the two jobs. |
| 167 Job* main_job_; | 174 Job* main_job_; |
| 168 Job* alternative_job_; | 175 Job* alternative_job_; |
| 169 | 176 |
| 177 // True if the |main_job_| has to wait for |alternative_job_|; | |
| 178 bool racing_; | |
|
Ryan Hamilton
2016/05/06 21:33:14
If this is about the alt job blocking the main job
Zhongyi Shi
2016/05/13 00:31:25
Done.
| |
| 179 | |
| 170 // At the point where a Job is irrevocably tied to |request_|, we set this. | 180 // At the point where a Job is irrevocably tied to |request_|, we set this. |
| 171 std::unique_ptr<Job> bound_job_; | 181 std::unique_ptr<Job> bound_job_; |
| 172 | 182 |
| 173 // These jobs correspond to jobs orphaned by |request_|. Since they are no | 183 // These jobs correspond to jobs orphaned by |request_|. Since they are no |
| 174 // longer tied to Requests, they will not be canceled when |request_| is | 184 // longer tied to Requests, they will not be canceled when |request_| is |
| 175 // canceled. Therefore, in ~JobController, it is possible for some jobs to | 185 // canceled. Therefore, in ~JobController, it is possible for some jobs to |
| 176 // still exist in this set. Leftover jobs will be deleted when the | 186 // still exist in this set. Leftover jobs will be deleted when the |
| 177 // JobController is destroyed. | 187 // JobController is destroyed. |
| 178 std::set<const Job*> orphaned_job_set_; | 188 std::set<const Job*> orphaned_job_set_; |
| 179 }; | 189 }; |
| 180 | 190 |
| 181 } // namespace net | 191 } // namespace net |
| 182 | 192 |
| 183 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_ | 193 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_ |
| OLD | NEW |