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* | |
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 | |
503 signed_certificate_timestamp_ids; | |
504 StoreSignedCertificateTimestamps( | |
505 request_->ssl_info().signed_certificate_timestamps, info->GetChildID(), | |
Eran M. (Google)
2013/11/26 21:33:22
Nit: Put each parameter in a line of its own, see:
alcutter
2013/11/26 23:00:05
I think this is what clang-format came up with, I'
| |
506 &signed_certificate_timestamp_ids); | |
507 | |
485 response->head.security_info = SerializeSecurityInfo( | 508 response->head.security_info = SerializeSecurityInfo( |
486 cert_id, | 509 cert_id, |
487 request_->ssl_info().cert_status, | 510 request_->ssl_info().cert_status, |
488 request_->ssl_info().security_bits, | 511 request_->ssl_info().security_bits, |
489 request_->ssl_info().connection_status); | 512 request_->ssl_info().connection_status, |
513 signed_certificate_timestamp_ids); | |
490 } else { | 514 } else { |
491 // We should not have any SSL state. | 515 // We should not have any SSL state. |
492 DCHECK(!request_->ssl_info().cert_status && | 516 DCHECK(!request_->ssl_info().cert_status && |
493 request_->ssl_info().security_bits == -1 && | 517 request_->ssl_info().security_bits == -1 && |
494 !request_->ssl_info().connection_status); | 518 !request_->ssl_info().connection_status); |
495 } | 519 } |
496 | 520 |
497 delegate_->DidReceiveResponse(this); | 521 delegate_->DidReceiveResponse(this); |
498 | 522 |
499 bool defer = false; | 523 bool defer = false; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
583 void ResourceLoader::ResponseCompleted() { | 607 void ResourceLoader::ResponseCompleted() { |
584 VLOG(1) << "ResponseCompleted: " << request_->url().spec(); | 608 VLOG(1) << "ResponseCompleted: " << request_->url().spec(); |
585 RecordHistograms(); | 609 RecordHistograms(); |
586 ResourceRequestInfoImpl* info = GetRequestInfo(); | 610 ResourceRequestInfoImpl* info = GetRequestInfo(); |
587 | 611 |
588 std::string security_info; | 612 std::string security_info; |
589 const net::SSLInfo& ssl_info = request_->ssl_info(); | 613 const net::SSLInfo& ssl_info = request_->ssl_info(); |
590 if (ssl_info.cert.get() != NULL) { | 614 if (ssl_info.cert.get() != NULL) { |
591 int cert_id = CertStore::GetInstance()->StoreCert(ssl_info.cert.get(), | 615 int cert_id = CertStore::GetInstance()->StoreCert(ssl_info.cert.get(), |
592 info->GetChildID()); | 616 info->GetChildID()); |
617 content::SignedCertificateTimestampIDStatusList | |
618 signed_certificate_timestamp_ids; | |
619 StoreSignedCertificateTimestamps(ssl_info.signed_certificate_timestamps, | |
620 info->GetChildID(), &signed_certificate_timestamp_ids); | |
621 | |
593 security_info = SerializeSecurityInfo( | 622 security_info = SerializeSecurityInfo( |
594 cert_id, ssl_info.cert_status, ssl_info.security_bits, | 623 cert_id, ssl_info.cert_status, ssl_info.security_bits, |
595 ssl_info.connection_status); | 624 ssl_info.connection_status, signed_certificate_timestamp_ids); |
596 } | 625 } |
597 | 626 |
598 bool defer = false; | 627 bool defer = false; |
599 handler_->OnResponseCompleted(info->GetRequestID(), request_->status(), | 628 handler_->OnResponseCompleted(info->GetRequestID(), request_->status(), |
600 security_info, &defer); | 629 security_info, &defer); |
601 if (defer) { | 630 if (defer) { |
602 // The handler is not ready to die yet. We will call DidFinishLoading when | 631 // The handler is not ready to die yet. We will call DidFinishLoading when |
603 // we resume. | 632 // we resume. |
604 deferred_stage_ = DEFERRED_FINISH; | 633 deferred_stage_ = DEFERRED_FINISH; |
605 } else { | 634 } else { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
639 case net::URLRequestStatus::FAILED: | 668 case net::URLRequestStatus::FAILED: |
640 status = STATUS_UNDEFINED; | 669 status = STATUS_UNDEFINED; |
641 break; | 670 break; |
642 } | 671 } |
643 | 672 |
644 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); | 673 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); |
645 } | 674 } |
646 } | 675 } |
647 | 676 |
648 } // namespace content | 677 } // namespace content |
OLD | NEW |