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

Side by Side Diff: net/spdy/spdy_session.cc

Issue 2031373002: Process HTTP/2 ALTSVC frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re: #3. Created 4 years, 6 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
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_unittest.cc » ('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/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 2467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 headers, response_time, recv_first_byte_time, stream)); 2478 headers, response_time, recv_first_byte_time, stream));
2479 } else { 2479 } else {
2480 int rv = stream->OnAdditionalResponseHeadersReceived(headers); 2480 int rv = stream->OnAdditionalResponseHeadersReceived(headers);
2481 if (rv < 0) { 2481 if (rv < 0) {
2482 DCHECK_NE(rv, ERR_IO_PENDING); 2482 DCHECK_NE(rv, ERR_IO_PENDING);
2483 DCHECK(active_streams_.find(stream_id) == active_streams_.end()); 2483 DCHECK(active_streams_.find(stream_id) == active_streams_.end());
2484 } 2484 }
2485 } 2485 }
2486 } 2486 }
2487 2487
2488 void SpdySession::OnAltSvc(
2489 SpdyStreamId stream_id,
2490 base::StringPiece origin,
2491 const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) {
2492 if (!is_secure_)
2493 return;
2494
2495 url::SchemeHostPort scheme_host_port;
2496 if (stream_id == 0) {
2497 if (origin.empty())
2498 return;
2499 const GURL gurl(origin);
2500 if (!gurl.SchemeIs("https"))
2501 return;
2502 SSLInfo ssl_info;
2503 bool was_npn_negotiated;
2504 NextProto protocol_negotiated = kProtoUnknown;
2505 if (!GetSSLInfo(&ssl_info, &was_npn_negotiated, &protocol_negotiated))
2506 return;
2507 if (!CanPool(transport_security_state_, ssl_info, host_port_pair().host(),
2508 gurl.host())) {
2509 return;
2510 }
2511 scheme_host_port = url::SchemeHostPort(gurl);
2512 } else {
2513 if (!origin.empty())
2514 return;
2515 const ActiveStreamMap::iterator it = active_streams_.find(stream_id);
2516 if (it == active_streams_.end())
2517 return;
2518 const GURL& gurl(it->second.stream->url());
2519 if (!gurl.SchemeIs("https"))
2520 return;
2521 scheme_host_port = url::SchemeHostPort(gurl);
2522 }
2523
2524 AlternativeServiceInfoVector alternative_service_info_vector;
2525 alternative_service_info_vector.reserve(altsvc_vector.size());
2526 const base::Time now(base::Time::Now());
2527 for (const SpdyAltSvcWireFormat::AlternativeService& altsvc : altsvc_vector) {
2528 const AlternateProtocol protocol =
2529 AlternateProtocolFromString(altsvc.protocol_id);
2530 if (protocol == UNINITIALIZED_ALTERNATE_PROTOCOL)
2531 continue;
2532 const AlternativeService alternative_service(protocol, altsvc.host,
2533 altsvc.port);
2534 const base::Time expiration =
2535 now + base::TimeDelta::FromSeconds(altsvc.max_age);
2536 alternative_service_info_vector.push_back(
2537 AlternativeServiceInfo(alternative_service, expiration));
2538 }
2539 http_server_properties_->SetAlternativeServices(
2540 scheme_host_port, alternative_service_info_vector);
2541 }
2542
2488 bool SpdySession::OnUnknownFrame(SpdyStreamId stream_id, int frame_type) { 2543 bool SpdySession::OnUnknownFrame(SpdyStreamId stream_id, int frame_type) {
2489 // Validate stream id. 2544 // Validate stream id.
2490 // Was the frame sent on a stream id that has not been used in this session? 2545 // Was the frame sent on a stream id that has not been used in this session?
2491 if (stream_id % 2 == 1 && stream_id > stream_hi_water_mark_) 2546 if (stream_id % 2 == 1 && stream_id > stream_hi_water_mark_)
2492 return false; 2547 return false;
2493 2548
2494 if (stream_id % 2 == 0 && stream_id > last_accepted_push_stream_id_) 2549 if (stream_id % 2 == 0 && stream_id > last_accepted_push_stream_id_)
2495 return false; 2550 return false;
2496 2551
2497 return true; 2552 return true;
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
3336 if (!queue->empty()) { 3391 if (!queue->empty()) {
3337 SpdyStreamId stream_id = queue->front(); 3392 SpdyStreamId stream_id = queue->front();
3338 queue->pop_front(); 3393 queue->pop_front();
3339 return stream_id; 3394 return stream_id;
3340 } 3395 }
3341 } 3396 }
3342 return 0; 3397 return 0;
3343 } 3398 }
3344 3399
3345 } // namespace net 3400 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698