Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "content/browser/loader/resource_loader.h" | 5 #include "content/browser/loader/resource_loader.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "content/browser/child_process_security_policy_impl.h" | 11 #include "content/browser/child_process_security_policy_impl.h" |
| 12 #include "content/browser/loader/cross_site_resource_handler.h" | 12 #include "content/browser/loader/cross_site_resource_handler.h" |
| 13 #include "content/browser/loader/detachable_resource_handler.h" | 13 #include "content/browser/loader/detachable_resource_handler.h" |
| 14 #include "content/browser/loader/resource_loader_delegate.h" | 14 #include "content/browser/loader/resource_loader_delegate.h" |
| 15 #include "content/browser/loader/resource_request_info_impl.h" | 15 #include "content/browser/loader/resource_request_info_impl.h" |
| 16 #include "content/browser/ssl/ssl_client_auth_handler.h" | 16 #include "content/browser/ssl/ssl_client_auth_handler.h" |
| 17 #include "content/browser/ssl/ssl_manager.h" | 17 #include "content/browser/ssl/ssl_manager.h" |
| 18 #include "content/common/ssl_status_serialization.h" | 18 #include "content/common/ssl_status_serialization.h" |
| 19 #include "content/public/browser/cert_store.h" | 19 #include "content/public/browser/cert_store.h" |
| 20 #include "content/public/browser/resource_context.h" | 20 #include "content/public/browser/resource_context.h" |
| 21 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" | 21 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" |
| 22 #include "content/public/browser/signed_certificate_timestamp_store.h" | |
| 22 #include "content/public/common/content_client.h" | 23 #include "content/public/common/content_client.h" |
| 23 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
| 24 #include "content/public/common/process_type.h" | 25 #include "content/public/common/process_type.h" |
| 25 #include "content/public/common/resource_response.h" | 26 #include "content/public/common/resource_response.h" |
| 26 #include "net/base/io_buffer.h" | 27 #include "net/base/io_buffer.h" |
| 27 #include "net/base/load_flags.h" | 28 #include "net/base/load_flags.h" |
| 28 #include "net/http/http_response_headers.h" | 29 #include "net/http/http_response_headers.h" |
| 29 #include "net/ssl/client_cert_store.h" | 30 #include "net/ssl/client_cert_store.h" |
| 30 #include "net/url_request/url_request_status.h" | 31 #include "net/url_request/url_request_status.h" |
| 31 #include "webkit/browser/appcache/appcache_interceptor.h" | 32 #include "webkit/browser/appcache/appcache_interceptor.h" |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 // If the request isn't in flight, then we won't get an asynchronous | 467 // If the request isn't in flight, then we won't get an asynchronous |
| 467 // notification from the request, so we have to signal ourselves to finish | 468 // notification from the request, so we have to signal ourselves to finish |
| 468 // this request. | 469 // this request. |
| 469 base::MessageLoop::current()->PostTask( | 470 base::MessageLoop::current()->PostTask( |
| 470 FROM_HERE, | 471 FROM_HERE, |
| 471 base::Bind(&ResourceLoader::ResponseCompleted, | 472 base::Bind(&ResourceLoader::ResponseCompleted, |
| 472 weak_ptr_factory_.GetWeakPtr())); | 473 weak_ptr_factory_.GetWeakPtr())); |
| 473 } | 474 } |
| 474 } | 475 } |
| 475 | 476 |
| 477 void ResourceLoader::StoreSignedCertificateTimestamps( | |
| 478 const net::SignedCertificateTimestampAndStatusList& sct_list, | |
| 479 int process_id, content::SignedCertificateTimestampIDStatusList* | |
|
jam
2013/11/27 01:07:50
ditto
alcutter
2013/11/27 12:17:56
Done.
| |
| 480 signed_certificate_timestamp_ids) { | |
| 481 SignedCertificateTimestampStore* sct_store( | |
| 482 SignedCertificateTimestampStore::GetInstance()); | |
| 483 | |
| 484 for (net::SignedCertificateTimestampAndStatusList::const_iterator iter = | |
| 485 sct_list.begin(); iter != sct_list.end(); ++iter) { | |
| 486 const int sct_id(sct_store->Store(iter->sct_, process_id)); | |
| 487 signed_certificate_timestamp_ids->push_back( | |
| 488 content::SignedCertificateTimestampIDAndStatus(sct_id, iter->status_)); | |
| 489 } | |
| 490 } | |
| 491 | |
| 476 void ResourceLoader::CompleteResponseStarted() { | 492 void ResourceLoader::CompleteResponseStarted() { |
| 477 ResourceRequestInfoImpl* info = GetRequestInfo(); | 493 ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 478 | 494 |
| 479 scoped_refptr<ResourceResponse> response(new ResourceResponse()); | 495 scoped_refptr<ResourceResponse> response(new ResourceResponse()); |
| 480 PopulateResourceResponse(request_.get(), response.get()); | 496 PopulateResourceResponse(request_.get(), response.get()); |
| 481 | 497 |
| 482 if (request_->ssl_info().cert.get()) { | 498 if (request_->ssl_info().cert.get()) { |
| 483 int cert_id = CertStore::GetInstance()->StoreCert( | 499 int cert_id = CertStore::GetInstance()->StoreCert( |
| 484 request_->ssl_info().cert.get(), info->GetChildID()); | 500 request_->ssl_info().cert.get(), info->GetChildID()); |
| 501 | |
| 502 content::SignedCertificateTimestampIDStatusList | |
|
jam
2013/11/27 01:07:50
no content::
alcutter
2013/11/27 12:17:56
D'oh, sorry.
Removed.
| |
| 503 signed_certificate_timestamp_ids; | |
| 504 StoreSignedCertificateTimestamps( | |
| 505 request_->ssl_info().signed_certificate_timestamps, | |
| 506 info->GetChildID(), | |
| 507 &signed_certificate_timestamp_ids); | |
| 508 | |
| 485 response->head.security_info = SerializeSecurityInfo( | 509 response->head.security_info = SerializeSecurityInfo( |
| 486 cert_id, | 510 cert_id, |
| 487 request_->ssl_info().cert_status, | 511 request_->ssl_info().cert_status, |
| 488 request_->ssl_info().security_bits, | 512 request_->ssl_info().security_bits, |
| 489 request_->ssl_info().connection_status); | 513 request_->ssl_info().connection_status, |
| 514 signed_certificate_timestamp_ids); | |
| 490 } else { | 515 } else { |
| 491 // We should not have any SSL state. | 516 // We should not have any SSL state. |
| 492 DCHECK(!request_->ssl_info().cert_status && | 517 DCHECK(!request_->ssl_info().cert_status && |
| 493 request_->ssl_info().security_bits == -1 && | 518 request_->ssl_info().security_bits == -1 && |
| 494 !request_->ssl_info().connection_status); | 519 !request_->ssl_info().connection_status); |
| 495 } | 520 } |
| 496 | 521 |
| 497 delegate_->DidReceiveResponse(this); | 522 delegate_->DidReceiveResponse(this); |
| 498 | 523 |
| 499 bool defer = false; | 524 bool defer = false; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 void ResourceLoader::ResponseCompleted() { | 608 void ResourceLoader::ResponseCompleted() { |
| 584 VLOG(1) << "ResponseCompleted: " << request_->url().spec(); | 609 VLOG(1) << "ResponseCompleted: " << request_->url().spec(); |
| 585 RecordHistograms(); | 610 RecordHistograms(); |
| 586 ResourceRequestInfoImpl* info = GetRequestInfo(); | 611 ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 587 | 612 |
| 588 std::string security_info; | 613 std::string security_info; |
| 589 const net::SSLInfo& ssl_info = request_->ssl_info(); | 614 const net::SSLInfo& ssl_info = request_->ssl_info(); |
| 590 if (ssl_info.cert.get() != NULL) { | 615 if (ssl_info.cert.get() != NULL) { |
| 591 int cert_id = CertStore::GetInstance()->StoreCert(ssl_info.cert.get(), | 616 int cert_id = CertStore::GetInstance()->StoreCert(ssl_info.cert.get(), |
| 592 info->GetChildID()); | 617 info->GetChildID()); |
| 618 content::SignedCertificateTimestampIDStatusList | |
|
jam
2013/11/27 01:07:50
ditto
alcutter
2013/11/27 12:17:56
Done.
| |
| 619 signed_certificate_timestamp_ids; | |
| 620 StoreSignedCertificateTimestamps(ssl_info.signed_certificate_timestamps, | |
| 621 info->GetChildID(), | |
| 622 &signed_certificate_timestamp_ids); | |
| 623 | |
| 593 security_info = SerializeSecurityInfo( | 624 security_info = SerializeSecurityInfo( |
| 594 cert_id, ssl_info.cert_status, ssl_info.security_bits, | 625 cert_id, ssl_info.cert_status, ssl_info.security_bits, |
| 595 ssl_info.connection_status); | 626 ssl_info.connection_status, signed_certificate_timestamp_ids); |
| 596 } | 627 } |
| 597 | 628 |
| 598 bool defer = false; | 629 bool defer = false; |
| 599 handler_->OnResponseCompleted(info->GetRequestID(), request_->status(), | 630 handler_->OnResponseCompleted(info->GetRequestID(), request_->status(), |
| 600 security_info, &defer); | 631 security_info, &defer); |
| 601 if (defer) { | 632 if (defer) { |
| 602 // The handler is not ready to die yet. We will call DidFinishLoading when | 633 // The handler is not ready to die yet. We will call DidFinishLoading when |
| 603 // we resume. | 634 // we resume. |
| 604 deferred_stage_ = DEFERRED_FINISH; | 635 deferred_stage_ = DEFERRED_FINISH; |
| 605 } else { | 636 } else { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 639 case net::URLRequestStatus::FAILED: | 670 case net::URLRequestStatus::FAILED: |
| 640 status = STATUS_UNDEFINED; | 671 status = STATUS_UNDEFINED; |
| 641 break; | 672 break; |
| 642 } | 673 } |
| 643 | 674 |
| 644 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); | 675 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); |
| 645 } | 676 } |
| 646 } | 677 } |
| 647 | 678 |
| 648 } // namespace content | 679 } // namespace content |
| OLD | NEW |