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

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

Issue 9617039: Change Origin bound certs -> Domain bound certs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rename all the things Created 8 years, 9 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
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_stream.h" 5 #include "net/spdy/spdy_stream.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 delegate_(NULL), 83 delegate_(NULL),
84 request_time_(base::Time::Now()), 84 request_time_(base::Time::Now()),
85 response_(new spdy::SpdyHeaderBlock), 85 response_(new spdy::SpdyHeaderBlock),
86 io_state_(STATE_NONE), 86 io_state_(STATE_NONE),
87 response_status_(OK), 87 response_status_(OK),
88 cancelled_(false), 88 cancelled_(false),
89 has_upload_data_(false), 89 has_upload_data_(false),
90 net_log_(net_log), 90 net_log_(net_log),
91 send_bytes_(0), 91 send_bytes_(0),
92 recv_bytes_(0), 92 recv_bytes_(0),
93 ob_cert_type_(CLIENT_CERT_INVALID_TYPE) { 93 domain_bound_cert_type_(CLIENT_CERT_INVALID_TYPE) {
94 } 94 }
95 95
96 SpdyStream::~SpdyStream() { 96 SpdyStream::~SpdyStream() {
97 UpdateHistograms(); 97 UpdateHistograms();
98 } 98 }
99 99
100 void SpdyStream::SetDelegate(Delegate* delegate) { 100 void SpdyStream::SetDelegate(Delegate* delegate) {
101 CHECK(delegate); 101 CHECK(delegate);
102 delegate_ = delegate; 102 delegate_ = delegate;
103 103
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 // STATE_DONE. However, we still want to return IO_PENDING to mimic non-push 479 // STATE_DONE. However, we still want to return IO_PENDING to mimic non-push
480 // behavior. 480 // behavior.
481 has_upload_data_ = has_upload_data; 481 has_upload_data_ = has_upload_data;
482 if (pushed_) { 482 if (pushed_) {
483 send_time_ = base::TimeTicks::Now(); 483 send_time_ = base::TimeTicks::Now();
484 DCHECK(!has_upload_data_); 484 DCHECK(!has_upload_data_);
485 DCHECK(response_received()); 485 DCHECK(response_received());
486 return ERR_IO_PENDING; 486 return ERR_IO_PENDING;
487 } 487 }
488 CHECK_EQ(STATE_NONE, io_state_); 488 CHECK_EQ(STATE_NONE, io_state_);
489 io_state_ = STATE_GET_ORIGIN_BOUND_CERT; 489 io_state_ = STATE_GET_DOMAIN_BOUND_CERT;
490 return DoLoop(OK); 490 return DoLoop(OK);
491 } 491 }
492 492
493 int SpdyStream::WriteStreamData(IOBuffer* data, int length, 493 int SpdyStream::WriteStreamData(IOBuffer* data, int length,
494 spdy::SpdyDataFlags flags) { 494 spdy::SpdyDataFlags flags) {
495 return session_->WriteStreamData(stream_id_, data, length, flags); 495 return session_->WriteStreamData(stream_id_, data, length, flags);
496 } 496 }
497 497
498 bool SpdyStream::GetSSLInfo(SSLInfo* ssl_info, 498 bool SpdyStream::GetSSLInfo(SSLInfo* ssl_info,
499 bool* was_npn_negotiated, 499 bool* was_npn_negotiated,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 it = request_->find("host"); 536 it = request_->find("host");
537 if (it != (*request_).end()) 537 if (it != (*request_).end())
538 host_port = it->second; 538 host_port = it->second;
539 it = request_->find("path"); 539 it = request_->find("path");
540 if (it != (*request_).end()) 540 if (it != (*request_).end())
541 path = it->second; 541 path = it->second;
542 std::string url = scheme + "://" + host_port + path; 542 std::string url = scheme + "://" + host_port + path;
543 return GURL(url); 543 return GURL(url);
544 } 544 }
545 545
546 void SpdyStream::OnGetOriginBoundCertComplete(int result) { 546 void SpdyStream::OnGetDomainBoundCertComplete(int result) {
547 DCHECK_EQ(STATE_GET_ORIGIN_BOUND_CERT_COMPLETE, io_state_); 547 DCHECK_EQ(STATE_GET_DOMAIN_BOUND_CERT_COMPLETE, io_state_);
548 DoLoop(result); 548 DoLoop(result);
549 } 549 }
550 550
551 int SpdyStream::DoLoop(int result) { 551 int SpdyStream::DoLoop(int result) {
552 do { 552 do {
553 State state = io_state_; 553 State state = io_state_;
554 io_state_ = STATE_NONE; 554 io_state_ = STATE_NONE;
555 switch (state) { 555 switch (state) {
556 // State machine 1: Send headers and body. 556 // State machine 1: Send headers and body.
557 case STATE_GET_ORIGIN_BOUND_CERT: 557 case STATE_GET_DOMAIN_BOUND_CERT:
558 CHECK_EQ(OK, result); 558 CHECK_EQ(OK, result);
559 result = DoGetOriginBoundCert(); 559 result = DoGetDomainBoundCert();
560 break; 560 break;
561 case STATE_GET_ORIGIN_BOUND_CERT_COMPLETE: 561 case STATE_GET_DOMAIN_BOUND_CERT_COMPLETE:
562 result = DoGetOriginBoundCertComplete(result); 562 result = DoGetDomainBoundCertComplete(result);
563 break; 563 break;
564 case STATE_SEND_ORIGIN_BOUND_CERT: 564 case STATE_SEND_DOMAIN_BOUND_CERT:
565 CHECK_EQ(OK, result); 565 CHECK_EQ(OK, result);
566 result = DoSendOriginBoundCert(); 566 result = DoSendDomainBoundCert();
567 break; 567 break;
568 case STATE_SEND_ORIGIN_BOUND_CERT_COMPLETE: 568 case STATE_SEND_DOMAIN_BOUND_CERT_COMPLETE:
569 result = DoSendOriginBoundCertComplete(result); 569 result = DoSendDomainBoundCertComplete(result);
570 break; 570 break;
571 case STATE_SEND_HEADERS: 571 case STATE_SEND_HEADERS:
572 CHECK_EQ(OK, result); 572 CHECK_EQ(OK, result);
573 result = DoSendHeaders(); 573 result = DoSendHeaders();
574 break; 574 break;
575 case STATE_SEND_HEADERS_COMPLETE: 575 case STATE_SEND_HEADERS_COMPLETE:
576 result = DoSendHeadersComplete(result); 576 result = DoSendHeadersComplete(result);
577 break; 577 break;
578 case STATE_SEND_BODY: 578 case STATE_SEND_BODY:
579 CHECK_EQ(OK, result); 579 CHECK_EQ(OK, result);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 default: 612 default:
613 NOTREACHED() << io_state_; 613 NOTREACHED() << io_state_;
614 break; 614 break;
615 } 615 }
616 } while (result != ERR_IO_PENDING && io_state_ != STATE_NONE && 616 } while (result != ERR_IO_PENDING && io_state_ != STATE_NONE &&
617 io_state_ != STATE_OPEN); 617 io_state_ != STATE_OPEN);
618 618
619 return result; 619 return result;
620 } 620 }
621 621
622 int SpdyStream::DoGetOriginBoundCert() { 622 int SpdyStream::DoGetDomainBoundCert() {
623 CHECK(request_.get()); 623 CHECK(request_.get());
624 HostPortPair origin(HostPortPair::FromURL(GetUrl())); 624 HostPortPair origin(HostPortPair::FromURL(GetUrl()));
625 if (!session_->NeedsCredentials(origin)) { 625 if (!session_->NeedsCredentials(origin)) {
626 // Proceed directly to sending headers 626 // Proceed directly to sending headers
627 io_state_ = STATE_SEND_HEADERS; 627 io_state_ = STATE_SEND_HEADERS;
628 return OK; 628 return OK;
629 } 629 }
630 630
631 io_state_ = STATE_GET_ORIGIN_BOUND_CERT_COMPLETE; 631 io_state_ = STATE_GET_DOMAIN_BOUND_CERT_COMPLETE;
632 OriginBoundCertService* obc_service = session_->GetOriginBoundCertService(); 632 ServerBoundCertService* sbc_service = session_->GetServerBoundCertService();
633 DCHECK(obc_service != NULL); 633 DCHECK(sbc_service != NULL);
634 std::vector<uint8> requested_cert_types; 634 std::vector<uint8> requested_cert_types;
635 requested_cert_types.push_back(session_->GetOriginBoundCertType()); 635 requested_cert_types.push_back(session_->GetDomainBoundCertType());
636 int rv = obc_service->GetOriginBoundCert( 636 int rv = sbc_service->GetDomainBoundCert(
637 GetUrl().GetOrigin().spec(), requested_cert_types, &ob_cert_type_, 637 GetUrl().GetOrigin().spec(), requested_cert_types,
638 &ob_private_key_, &ob_cert_, 638 &domain_bound_cert_type_, &domain_bound_private_key_, &domain_bound_cert_,
639 base::Bind(&SpdyStream::OnGetOriginBoundCertComplete, 639 base::Bind(&SpdyStream::OnGetDomainBoundCertComplete,
640 base::Unretained(this)), 640 base::Unretained(this)),
641 &ob_cert_request_handle_); 641 &domain_bound_cert_request_handle_);
642 return rv; 642 return rv;
643 } 643 }
644 644
645 int SpdyStream::DoGetOriginBoundCertComplete(int result) { 645 int SpdyStream::DoGetDomainBoundCertComplete(int result) {
646 if (result != OK) 646 if (result != OK)
647 return result; 647 return result;
648 648
649 io_state_ = STATE_SEND_ORIGIN_BOUND_CERT; 649 io_state_ = STATE_SEND_DOMAIN_BOUND_CERT;
650 return OK; 650 return OK;
651 } 651 }
652 652
653 int SpdyStream::DoSendOriginBoundCert() { 653 int SpdyStream::DoSendDomainBoundCert() {
654 io_state_ = STATE_SEND_ORIGIN_BOUND_CERT_COMPLETE; 654 io_state_ = STATE_SEND_DOMAIN_BOUND_CERT_COMPLETE;
655 CHECK(request_.get()); 655 CHECK(request_.get());
656 std::string origin = GetUrl().GetOrigin().spec(); 656 std::string origin = GetUrl().GetOrigin().spec();
657 origin.erase(origin.length() - 1); // trim trailing slash 657 origin.erase(origin.length() - 1); // trim trailing slash
658 int rv = session_->WriteCredentialFrame( 658 int rv = session_->WriteCredentialFrame(
659 origin, ob_cert_type_, ob_private_key_, ob_cert_, 659 origin, domain_bound_cert_type_, domain_bound_private_key_,
660 static_cast<RequestPriority>(priority_)); 660 domain_bound_cert_, static_cast<RequestPriority>(priority_));
661 if (rv != ERR_IO_PENDING) 661 if (rv != ERR_IO_PENDING)
662 return rv; 662 return rv;
663 return OK; 663 return OK;
664 } 664 }
665 665
666 int SpdyStream::DoSendOriginBoundCertComplete(int result) { 666 int SpdyStream::DoSendDomainBoundCertComplete(int result) {
667 if (result < 0) 667 if (result < 0)
668 return result; 668 return result;
669 669
670 io_state_ = STATE_SEND_HEADERS; 670 io_state_ = STATE_SEND_HEADERS;
671 return OK; 671 return OK;
672 } 672 }
673 673
674 int SpdyStream::DoSendHeaders() { 674 int SpdyStream::DoSendHeaders() {
675 CHECK(!cancelled_); 675 CHECK(!cancelled_);
676 676
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", 758 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime",
759 recv_last_byte_time_ - recv_first_byte_time_); 759 recv_last_byte_time_ - recv_first_byte_time_);
760 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", 760 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime",
761 recv_last_byte_time_ - send_time_); 761 recv_last_byte_time_ - send_time_);
762 762
763 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); 763 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_);
764 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); 764 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_);
765 } 765 }
766 766
767 } // namespace net 767 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698