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

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

Issue 18546008: [SPDY] Use WeakPtr<SpdySession> everywhere but SpdySessionPool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test, other minor formatting/comment changes Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_stream_factory_impl.h ('k') | net/http/http_stream_factory_impl_job.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "net/http/http_stream_factory_impl.h" 5 #include "net/http/http_stream_factory_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 DCHECK_EQ(request_map_[job], request); 256 DCHECK_EQ(request_map_[job], request);
257 DCHECK(!ContainsKey(orphaned_job_set_, job)); 257 DCHECK(!ContainsKey(orphaned_job_set_, job));
258 258
259 request_map_.erase(job); 259 request_map_.erase(job);
260 260
261 orphaned_job_set_.insert(job); 261 orphaned_job_set_.insert(job);
262 job->Orphan(request); 262 job->Orphan(request);
263 } 263 }
264 264
265 void HttpStreamFactoryImpl::OnNewSpdySessionReady( 265 void HttpStreamFactoryImpl::OnNewSpdySessionReady(
266 scoped_refptr<SpdySession> spdy_session, 266 const base::WeakPtr<SpdySession>& spdy_session,
267 bool direct, 267 bool direct,
268 const SSLConfig& used_ssl_config, 268 const SSLConfig& used_ssl_config,
269 const ProxyInfo& used_proxy_info, 269 const ProxyInfo& used_proxy_info,
270 bool was_npn_negotiated, 270 bool was_npn_negotiated,
271 NextProto protocol_negotiated, 271 NextProto protocol_negotiated,
272 bool using_spdy, 272 bool using_spdy,
273 const BoundNetLog& net_log) { 273 const BoundNetLog& net_log) {
274 const SpdySessionKey& spdy_session_key = 274 while (true) {
275 spdy_session->spdy_session_key(); 275 if (!spdy_session)
276 while (!spdy_session->IsClosed()) { 276 break;
277 // Each iteration may empty out the RequestSet for |spdy_session_key_ in 277 const SpdySessionKey& spdy_session_key = spdy_session->spdy_session_key();
278 // Each iteration may empty out the RequestSet for |spdy_session_key| in
278 // |spdy_session_request_map_|. So each time, check for RequestSet and use 279 // |spdy_session_request_map_|. So each time, check for RequestSet and use
279 // the first one. 280 // the first one.
280 // 281 //
281 // TODO(willchan): If it's important, switch RequestSet out for a FIFO 282 // TODO(willchan): If it's important, switch RequestSet out for a FIFO
282 // pqueue (Order by priority first, then FIFO within same priority). Unclear 283 // queue (Order by priority first, then FIFO within same priority). Unclear
283 // that it matters here. 284 // that it matters here.
284 if (!ContainsKey(spdy_session_request_map_, spdy_session_key)) 285 if (!ContainsKey(spdy_session_request_map_, spdy_session_key))
285 break; 286 break;
286 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); 287 Request* request = *spdy_session_request_map_[spdy_session_key].begin();
287 request->Complete(was_npn_negotiated, 288 request->Complete(was_npn_negotiated,
288 protocol_negotiated, 289 protocol_negotiated,
289 using_spdy, 290 using_spdy,
290 net_log); 291 net_log);
291 if (for_websockets_) { 292 if (for_websockets_) {
292 WebSocketStreamBase::Factory* factory = 293 WebSocketStreamBase::Factory* factory =
293 request->websocket_stream_factory(); 294 request->websocket_stream_factory();
294 DCHECK(factory); 295 DCHECK(factory);
295 bool use_relative_url = direct || request->url().SchemeIs("wss"); 296 bool use_relative_url = direct || request->url().SchemeIs("wss");
296 request->OnWebSocketStreamReady( 297 request->OnWebSocketStreamReady(
297 NULL, 298 NULL,
298 used_ssl_config, 299 used_ssl_config,
299 used_proxy_info, 300 used_proxy_info,
300 factory->CreateSpdyStream(spdy_session.get(), use_relative_url)); 301 factory->CreateSpdyStream(spdy_session, use_relative_url));
301 } else { 302 } else {
302 bool use_relative_url = direct || request->url().SchemeIs("https"); 303 bool use_relative_url = direct || request->url().SchemeIs("https");
303 request->OnStreamReady( 304 request->OnStreamReady(
304 NULL, 305 NULL,
305 used_ssl_config, 306 used_ssl_config,
306 used_proxy_info, 307 used_proxy_info,
307 new SpdyHttpStream(spdy_session.get(), use_relative_url)); 308 new SpdyHttpStream(spdy_session, use_relative_url));
308 } 309 }
309 } 310 }
310 // TODO(mbelshe): Alert other valid requests. 311 // TODO(mbelshe): Alert other valid requests.
311 } 312 }
312 313
313 void HttpStreamFactoryImpl::OnOrphanedJobComplete(const Job* job) { 314 void HttpStreamFactoryImpl::OnOrphanedJobComplete(const Job* job) {
314 orphaned_job_set_.erase(job); 315 orphaned_job_set_.erase(job);
315 delete job; 316 delete job;
316 } 317 }
317 318
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 it != requests_to_fail.end(); ++it) { 352 it != requests_to_fail.end(); ++it) {
352 Request* request = *it; 353 Request* request = *it;
353 if (request == request_map_[job]) { 354 if (request == request_map_[job]) {
354 continue; 355 continue;
355 } 356 }
356 request->OnStreamFailed(NULL, status, used_ssl_config); 357 request->OnStreamFailed(NULL, status, used_ssl_config);
357 } 358 }
358 } 359 }
359 360
360 } // namespace net 361 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl.h ('k') | net/http/http_stream_factory_impl_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698