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

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: address rdsmith's comments 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(); } 65 enum JobType {
66 MAIN,
67 ALTERNATIVE,
68 PRECONNECT,
69 };
66 70
67 private: 71 private:
68 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority); 72 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority);
69 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); 73 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob);
70 74
71 class NET_EXPORT_PRIVATE Request; 75 class NET_EXPORT_PRIVATE Request;
72 class NET_EXPORT_PRIVATE Job; 76 class NET_EXPORT_PRIVATE Job;
77 class NET_EXPORT_PRIVATE JobController;
73 78
74 typedef std::set<Request*> RequestSet; 79 typedef std::set<Request*> RequestSet;
75 typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap; 80 typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap;
81 typedef std::set<std::unique_ptr<JobController>> JobControllerSet;
76 82
77 HttpStreamRequest* RequestStreamInternal( 83 HttpStreamRequest* RequestStreamInternal(
78 const HttpRequestInfo& info, 84 const HttpRequestInfo& info,
79 RequestPriority priority, 85 RequestPriority priority,
80 const SSLConfig& server_ssl_config, 86 const SSLConfig& server_ssl_config,
81 const SSLConfig& proxy_ssl_config, 87 const SSLConfig& proxy_ssl_config,
82 HttpStreamRequest::Delegate* delegate, 88 HttpStreamRequest::Delegate* delegate,
83 WebSocketHandshakeStreamBase::CreateHelper* create_helper, 89 WebSocketHandshakeStreamBase::CreateHelper* create_helper,
84 HttpStreamRequest::StreamType stream_type, 90 HttpStreamRequest::StreamType stream_type,
85 const BoundNetLog& net_log); 91 const BoundNetLog& net_log);
86 92
87 AlternativeService GetAlternativeServiceFor(
88 const HttpRequestInfo& request_info,
89 HttpStreamRequest::Delegate* delegate,
90 HttpStreamRequest::StreamType stream_type);
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 93 // Called when a SpdySession is ready. It will find appropriate Requests and
96 // fulfill them. |direct| indicates whether or not |spdy_session| uses a 94 // fulfill them. |direct| indicates whether or not |spdy_session| uses a
97 // proxy. 95 // proxy.
98 void OnNewSpdySessionReady(const base::WeakPtr<SpdySession>& spdy_session, 96 void OnNewSpdySessionReady(const base::WeakPtr<SpdySession>& spdy_session,
99 bool direct, 97 bool direct,
100 const SSLConfig& used_ssl_config, 98 const SSLConfig& used_ssl_config,
101 const ProxyInfo& used_proxy_info, 99 const ProxyInfo& used_proxy_info,
102 bool was_npn_negotiated, 100 bool was_npn_negotiated,
103 NextProto protocol_negotiated, 101 NextProto protocol_negotiated,
104 bool using_spdy, 102 bool using_spdy,
105 const BoundNetLog& net_log); 103 const BoundNetLog& net_log);
106 104
107 // Called when the Job detects that the endpoint indicated by the 105 // Called when the Job detects that the endpoint indicated by the
108 // Alternate-Protocol does not work. Lets the factory update 106 // Alternate-Protocol does not work. Lets the factory update
109 // HttpAlternateProtocols with the failure and resets the SPDY session key. 107 // HttpAlternateProtocols with the failure and resets the SPDY session key.
110 void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin); 108 void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin);
111 109
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. 110 // Called when the Preconnect completes. Used for testing.
119 virtual void OnPreconnectsCompleteInternal() {} 111 virtual void OnPreconnectsCompleteInternal() {}
120 112
121 // Returns true if QUIC is whitelisted for |host|. 113 // Called when the JobController finishes service. Delete the JobController
122 bool IsQuicWhitelistedForHost(const std::string& host); 114 // from |job_controller_set_|.
115 void OnJobControllerComplete(JobController* controller);
123 116
124 HttpNetworkSession* const session_; 117 HttpNetworkSession* const session_;
125 118
126 // All Requests are handed out to clients. By the time HttpStreamFactoryImpl 119 // All Requests are handed out to clients. By the time HttpStreamFactoryImpl
127 // is destroyed, all Requests should be deleted (which should remove them from 120 // is destroyed, all Requests should be deleted (which should remove them from
128 // |request_map_|. The Requests will delete the corresponding job. 121 // |request_map_|. The Requests will delete the corresponding job.
129 std::map<const Job*, Request*> request_map_; 122 std::map<const Job*, Request*> request_map_;
130 123
124 JobControllerSet job_controller_set_;
Ryan Hamilton 2016/05/17 17:02:16 nit: Can you add a comment here?
125
131 SpdySessionRequestMap spdy_session_request_map_; 126 SpdySessionRequestMap spdy_session_request_map_;
132 127
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_; 128 const bool for_websockets_;
146 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); 129 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl);
147 }; 130 };
148 131
149 } // namespace net 132 } // namespace net
150 133
151 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ 134 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698