| 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/resource_loader_delegate.h" | 13 #include "content/browser/loader/resource_loader_delegate.h" |
| 14 #include "content/browser/loader/resource_request_info_impl.h" | 14 #include "content/browser/loader/resource_request_info_impl.h" |
| 15 #include "content/browser/ssl/ssl_client_auth_handler.h" | 15 #include "content/browser/ssl/ssl_client_auth_handler.h" |
| 16 #include "content/browser/ssl/ssl_manager.h" | 16 #include "content/browser/ssl/ssl_manager.h" |
| 17 #include "content/common/ssl_status_serialization.h" | 17 #include "content/common/ssl_status_serialization.h" |
| 18 #include "content/public/browser/cert_store.h" | 18 #include "content/public/browser/cert_store.h" |
| 19 #include "content/public/browser/resource_context.h" | 19 #include "content/public/browser/resource_context.h" |
| 20 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" | 20 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" |
| 21 #include "content/public/browser/sct_store.h" |
| 21 #include "content/public/common/content_client.h" | 22 #include "content/public/common/content_client.h" |
| 22 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 23 #include "content/public/common/process_type.h" | 24 #include "content/public/common/process_type.h" |
| 24 #include "content/public/common/resource_response.h" | 25 #include "content/public/common/resource_response.h" |
| 25 #include "net/base/io_buffer.h" | 26 #include "net/base/io_buffer.h" |
| 26 #include "net/base/load_flags.h" | 27 #include "net/base/load_flags.h" |
| 27 #include "net/http/http_response_headers.h" | 28 #include "net/http/http_response_headers.h" |
| 28 #include "net/ssl/client_cert_store.h" | 29 #include "net/ssl/client_cert_store.h" |
| 29 #include "net/url_request/url_request_status.h" | 30 #include "net/url_request/url_request_status.h" |
| 30 #include "webkit/browser/appcache/appcache_interceptor.h" | 31 #include "webkit/browser/appcache/appcache_interceptor.h" |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 | 468 |
| 468 void ResourceLoader::CompleteResponseStarted() { | 469 void ResourceLoader::CompleteResponseStarted() { |
| 469 ResourceRequestInfoImpl* info = GetRequestInfo(); | 470 ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 470 | 471 |
| 471 scoped_refptr<ResourceResponse> response(new ResourceResponse()); | 472 scoped_refptr<ResourceResponse> response(new ResourceResponse()); |
| 472 PopulateResourceResponse(request_.get(), response.get()); | 473 PopulateResourceResponse(request_.get(), response.get()); |
| 473 | 474 |
| 474 if (request_->ssl_info().cert.get()) { | 475 if (request_->ssl_info().cert.get()) { |
| 475 int cert_id = CertStore::GetInstance()->StoreCert( | 476 int cert_id = CertStore::GetInstance()->StoreCert( |
| 476 request_->ssl_info().cert.get(), info->GetChildID()); | 477 request_->ssl_info().cert.get(), info->GetChildID()); |
| 477 // XXX(rsleevi): Wire up sending the SCT to the child | 478 content::SCTIdStatusList signed_certificate_timestamp_ids; |
| 478 int signed_certificate_timestamp_id = 0; | 479 SignedCertificateTimestampStore* sct_store( |
| 480 SignedCertificateTimestampStore::GetInstance()); |
| 481 |
| 482 for (net::SCTStatusList::const_iterator iter = |
| 483 request_->ssl_info().scts.begin(); |
| 484 iter != request_->ssl_info().scts.end(); ++iter) { |
| 485 const int sct_id(sct_store->StoreSignedCertificateTimestamp( |
| 486 iter->first, info->GetChildID())); |
| 487 signed_certificate_timestamp_ids.push_back( |
| 488 std::make_pair(sct_id, iter->second)); |
| 489 } |
| 479 response->head.security_info = SerializeSecurityInfo( | 490 response->head.security_info = SerializeSecurityInfo( |
| 480 cert_id, | 491 cert_id, |
| 481 request_->ssl_info().cert_status, | 492 request_->ssl_info().cert_status, |
| 482 request_->ssl_info().security_bits, | 493 request_->ssl_info().security_bits, |
| 483 request_->ssl_info().connection_status, | 494 request_->ssl_info().connection_status, |
| 484 signed_certificate_timestamp_id); | 495 signed_certificate_timestamp_ids); |
| 485 } else { | 496 } else { |
| 486 // We should not have any SSL state. | 497 // We should not have any SSL state. |
| 487 DCHECK(!request_->ssl_info().cert_status && | 498 DCHECK(!request_->ssl_info().cert_status && |
| 488 request_->ssl_info().security_bits == -1 && | 499 request_->ssl_info().security_bits == -1 && |
| 489 !request_->ssl_info().connection_status); | 500 !request_->ssl_info().connection_status); |
| 490 } | 501 } |
| 491 | 502 |
| 492 delegate_->DidReceiveResponse(this); | 503 delegate_->DidReceiveResponse(this); |
| 493 | 504 |
| 494 bool defer = false; | 505 bool defer = false; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 void ResourceLoader::ResponseCompleted() { | 589 void ResourceLoader::ResponseCompleted() { |
| 579 VLOG(1) << "ResponseCompleted: " << request_->url().spec(); | 590 VLOG(1) << "ResponseCompleted: " << request_->url().spec(); |
| 580 RecordHistograms(); | 591 RecordHistograms(); |
| 581 ResourceRequestInfoImpl* info = GetRequestInfo(); | 592 ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 582 | 593 |
| 583 std::string security_info; | 594 std::string security_info; |
| 584 const net::SSLInfo& ssl_info = request_->ssl_info(); | 595 const net::SSLInfo& ssl_info = request_->ssl_info(); |
| 585 if (ssl_info.cert.get() != NULL) { | 596 if (ssl_info.cert.get() != NULL) { |
| 586 int cert_id = CertStore::GetInstance()->StoreCert(ssl_info.cert.get(), | 597 int cert_id = CertStore::GetInstance()->StoreCert(ssl_info.cert.get(), |
| 587 info->GetChildID()); | 598 info->GetChildID()); |
| 588 // XXX(rsleevi): Wire up the SCTStore | 599 content::SCTIdStatusList signed_certificate_timestamp_ids; |
| 589 int sct_id = 0; | 600 SignedCertificateTimestampStore* sct_store( |
| 601 SignedCertificateTimestampStore::GetInstance()); |
| 602 |
| 603 for (net::SCTStatusList::const_iterator iter = |
| 604 request_->ssl_info().scts.begin(); |
| 605 iter != request_->ssl_info().scts.end(); ++iter) { |
| 606 const int sct_id(sct_store->StoreSignedCertificateTimestamp( |
| 607 iter->first, info->GetChildID())); |
| 608 signed_certificate_timestamp_ids.push_back( |
| 609 std::make_pair(sct_id, iter->second)); |
| 610 } |
| 590 security_info = SerializeSecurityInfo( | 611 security_info = SerializeSecurityInfo( |
| 591 cert_id, ssl_info.cert_status, ssl_info.security_bits, | 612 cert_id, ssl_info.cert_status, ssl_info.security_bits, |
| 592 ssl_info.connection_status, sct_id); | 613 ssl_info.connection_status, signed_certificate_timestamp_ids); |
| 593 } | 614 } |
| 594 | 615 |
| 595 if (handler_->OnResponseCompleted(info->GetRequestID(), request_->status(), | 616 if (handler_->OnResponseCompleted(info->GetRequestID(), request_->status(), |
| 596 security_info)) { | 617 security_info)) { |
| 597 // This will result in our destruction. | 618 // This will result in our destruction. |
| 598 CallDidFinishLoading(); | 619 CallDidFinishLoading(); |
| 599 } else { | 620 } else { |
| 600 // The handler is not ready to die yet. We will call DidFinishLoading when | 621 // The handler is not ready to die yet. We will call DidFinishLoading when |
| 601 // we resume. | 622 // we resume. |
| 602 deferred_stage_ = DEFERRED_FINISH; | 623 deferred_stage_ = DEFERRED_FINISH; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 case net::URLRequestStatus::FAILED: | 655 case net::URLRequestStatus::FAILED: |
| 635 status = STATUS_UNDEFINED; | 656 status = STATUS_UNDEFINED; |
| 636 break; | 657 break; |
| 637 } | 658 } |
| 638 | 659 |
| 639 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); | 660 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); |
| 640 } | 661 } |
| 641 } | 662 } |
| 642 | 663 |
| 643 } // namespace content | 664 } // namespace content |
| OLD | NEW |