Chromium Code Reviews| Index: net/http/http_stream_factory_impl.h |
| diff --git a/net/http/http_stream_factory_impl.h b/net/http/http_stream_factory_impl.h |
| index 0f1a68b31a4bc579eca1c8335b9339b25288fba6..fbe9af4827072a448406bbacc0fc71a2c0c7ab4a 100644 |
| --- a/net/http/http_stream_factory_impl.h |
| +++ b/net/http/http_stream_factory_impl.h |
| @@ -28,6 +28,10 @@ class SpdySession; |
| class NET_EXPORT_PRIVATE HttpStreamFactoryImpl : public HttpStreamFactory { |
| public: |
| + class NET_EXPORT_PRIVATE Job; |
| + class NET_EXPORT_PRIVATE JobController; |
| + class NET_EXPORT_PRIVATE JobFactory; |
| + class NET_EXPORT_PRIVATE Request; |
| // RequestStream may only be called if |for_websockets| is false. |
| // RequestWebSocketHandshakeStream may only be called if |for_websockets| |
| // is true. |
| @@ -62,17 +66,21 @@ class NET_EXPORT_PRIVATE HttpStreamFactoryImpl : public HttpStreamFactory { |
| void PreconnectStreams(int num_streams, const HttpRequestInfo& info) override; |
| const HostMappingRules* GetHostMappingRules() const override; |
| - size_t num_orphaned_jobs() const { return orphaned_job_set_.size(); } |
| + enum JobType { |
| + MAIN, |
| + ALTERNATIVE, |
| + PRECONNECT, |
| + }; |
| private: |
| FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority); |
| FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); |
| - class NET_EXPORT_PRIVATE Request; |
| - class NET_EXPORT_PRIVATE Job; |
| + friend class HttpStreamFactoryImplPeer; |
| typedef std::set<Request*> RequestSet; |
| typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap; |
| + typedef std::set<std::unique_ptr<JobController>> JobControllerSet; |
| // Values must not be changed or reused. Keep in sync with identically named |
| // enum in histograms.xml. |
| @@ -95,19 +103,6 @@ class NET_EXPORT_PRIVATE HttpStreamFactoryImpl : public HttpStreamFactory { |
| HttpStreamRequest::StreamType stream_type, |
| const BoundNetLog& net_log); |
| - AlternativeService GetAlternativeServiceFor( |
| - const HttpRequestInfo& request_info, |
| - HttpStreamRequest::Delegate* delegate, |
| - HttpStreamRequest::StreamType stream_type); |
| - |
| - AlternativeService GetAlternativeServiceForInternal( |
| - const HttpRequestInfo& request_info, |
| - HttpStreamRequest::Delegate* delegate, |
| - HttpStreamRequest::StreamType stream_type); |
| - |
| - // Detaches |job| from |request|. |
| - void OrphanJob(Job* job, const Request* request); |
| - |
| // Called when a SpdySession is ready. It will find appropriate Requests and |
| // fulfill them. |direct| indicates whether or not |spdy_session| uses a |
| // proxy. |
| @@ -125,17 +120,12 @@ class NET_EXPORT_PRIVATE HttpStreamFactoryImpl : public HttpStreamFactory { |
| // HttpAlternateProtocols with the failure and resets the SPDY session key. |
| void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin); |
| - // Invoked when an orphaned Job finishes. |
| - void OnOrphanedJobComplete(const Job* job); |
| - |
| - // Invoked when the Job finishes preconnecting sockets. |
| - void OnPreconnectsComplete(const Job* job); |
| - |
| // Called when the Preconnect completes. Used for testing. |
| virtual void OnPreconnectsCompleteInternal() {} |
| - // Returns true if QUIC is whitelisted for |host|. |
| - bool IsQuicWhitelistedForHost(const std::string& host); |
| + // Called when the JobController finishes service. Delete the JobController |
| + // from |job_controller_set_|. |
| + void OnJobControllerComplete(JobController* controller); |
| HttpNetworkSession* const session_; |
| @@ -144,19 +134,18 @@ class NET_EXPORT_PRIVATE HttpStreamFactoryImpl : public HttpStreamFactory { |
| // |request_map_|. The Requests will delete the corresponding job. |
| std::map<const Job*, Request*> request_map_; |
| - SpdySessionRequestMap spdy_session_request_map_; |
| + // All Requests/Preconnects are assigned with a JobController to manage |
| + // serving Job(s). JobController might outlive Request when Request |
| + // is served while there's some working Job left. JobController will be |
| + // deleted from |job_controller_set_| when it determines the completion of |
| + // its work. |
| + JobControllerSet job_controller_set_; |
| + |
| + // Owned by this. Reference will be passed to JobContoller to help create |
| + // Jobs. |
|
Ryan Hamilton
2016/06/15 23:34:20
nit: // Factory used by the controller for creatin
Zhongyi Shi
2016/06/16 00:02:31
Done.
|
| + std::unique_ptr<JobFactory> job_factory_; |
| - // These jobs correspond to jobs orphaned by Requests and now owned by |
| - // HttpStreamFactoryImpl. Since they are no longer tied to Requests, they will |
| - // not be canceled when Requests are canceled. Therefore, in |
| - // ~HttpStreamFactoryImpl, it is possible for some jobs to still exist in this |
| - // set. Leftover jobs will be deleted when the factory is destroyed. |
| - std::set<const Job*> orphaned_job_set_; |
| - |
| - // These jobs correspond to preconnect requests and have no associated Request |
| - // object. They're owned by HttpStreamFactoryImpl. Leftover jobs will be |
| - // deleted when the factory is destroyed. |
| - std::set<const Job*> preconnect_job_set_; |
| + SpdySessionRequestMap spdy_session_request_map_; |
| const bool for_websockets_; |
| DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); |