| 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/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 handler_->OnUploadProgress( | 165 handler_->OnUploadProgress( |
| 166 info->GetRequestID(), progress.position(), progress.size()); | 166 info->GetRequestID(), progress.position(), progress.size()); |
| 167 waiting_for_upload_progress_ack_ = true; | 167 waiting_for_upload_progress_ack_ = true; |
| 168 } | 168 } |
| 169 last_upload_ticks_ = TimeTicks::Now(); | 169 last_upload_ticks_ = TimeTicks::Now(); |
| 170 last_upload_position_ = progress.position(); | 170 last_upload_position_ = progress.position(); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 void ResourceLoader::MarkAsTransferring(const GURL& target_url) { | 174 void ResourceLoader::MarkAsTransferring(const GURL& target_url) { |
| 175 CHECK_EQ(GetRequestInfo()->GetResourceType(), ResourceType::MAIN_FRAME) | 175 // TODO(creis): Why was this check here? Is it a problem for cookies? |
| 176 << "Cannot transfer non-main frame navigations"; | 176 CHECK(GetRequestInfo()->GetResourceType() == ResourceType::MAIN_FRAME || |
| 177 GetRequestInfo()->GetResourceType() == ResourceType::SUB_FRAME) |
| 178 << "Can only transfer navigations"; |
| 177 is_transferring_ = true; | 179 is_transferring_ = true; |
| 178 | 180 |
| 179 // When transferring a request to another process, the renderer doesn't get | 181 // When transferring a request to another process, the renderer doesn't get |
| 180 // a chance to update the cookie policy URL. Do it here instead. | 182 // a chance to update the cookie policy URL. Do it here instead. |
| 181 request()->set_first_party_for_cookies(target_url); | 183 request()->set_first_party_for_cookies(target_url); |
| 182 } | 184 } |
| 183 | 185 |
| 184 void ResourceLoader::CompleteTransfer() { | 186 void ResourceLoader::CompleteTransfer() { |
| 185 DCHECK_EQ(DEFERRED_READ, deferred_stage_); | 187 DCHECK_EQ(DEFERRED_READ, deferred_stage_); |
| 186 | 188 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 weak_ptr_factory_.GetWeakPtr())); | 495 weak_ptr_factory_.GetWeakPtr())); |
| 494 } | 496 } |
| 495 } | 497 } |
| 496 | 498 |
| 497 void ResourceLoader::CompleteResponseStarted() { | 499 void ResourceLoader::CompleteResponseStarted() { |
| 498 ResourceRequestInfoImpl* info = GetRequestInfo(); | 500 ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 499 | 501 |
| 500 scoped_refptr<ResourceResponse> response(new ResourceResponse()); | 502 scoped_refptr<ResourceResponse> response(new ResourceResponse()); |
| 501 PopulateResourceResponse(request_.get(), response.get()); | 503 PopulateResourceResponse(request_.get(), response.get()); |
| 502 | 504 |
| 503 // The --site-per-process flag enables an out-of-process iframes | |
| 504 // prototype. It works by changing the MIME type of cross-site subframe | |
| 505 // responses to a Chrome specific one. This new type causes the subframe | |
| 506 // to be replaced by a <webview> tag with the same URL, which results in | |
| 507 // using a renderer in a different process. | |
| 508 // | |
| 509 // For prototyping purposes, we will use a small hack to ensure same site | |
| 510 // iframes are not changed. We can compare the URL for the subframe | |
| 511 // request with the referrer. If the two don't match, then it should be a | |
| 512 // cross-site iframe. | |
| 513 // Also, we don't do the MIME type change for chrome:// URLs, as those | |
| 514 // require different privileges and are not allowed in regular renderers. | |
| 515 // | |
| 516 // The usage of SiteInstance::IsSameWebSite is safe on the IO thread, | |
| 517 // if the browser_context parameter is NULL. This does not work for hosted | |
| 518 // apps, but should be fine for prototyping. | |
| 519 // TODO(nasko): Once the SiteInstance check is fixed, ensure we do the | |
| 520 // right thing here. http://crbug.com/160576 | |
| 521 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 522 if (command_line.HasSwitch(switches::kSitePerProcess) && | |
| 523 GetRequestInfo()->GetResourceType() == ResourceType::SUB_FRAME && | |
| 524 response->head.mime_type == "text/html" && | |
| 525 !request_->url().SchemeIs(chrome::kChromeUIScheme) && | |
| 526 !SiteInstance::IsSameWebSite(NULL, request_->url(), | |
| 527 GURL(request_->referrer()))) { | |
| 528 response->head.mime_type = "application/browser-plugin"; | |
| 529 } | |
| 530 | |
| 531 if (request_->ssl_info().cert.get()) { | 505 if (request_->ssl_info().cert.get()) { |
| 532 int cert_id = CertStore::GetInstance()->StoreCert( | 506 int cert_id = CertStore::GetInstance()->StoreCert( |
| 533 request_->ssl_info().cert.get(), info->GetChildID()); | 507 request_->ssl_info().cert.get(), info->GetChildID()); |
| 534 response->head.security_info = SerializeSecurityInfo( | 508 response->head.security_info = SerializeSecurityInfo( |
| 535 cert_id, | 509 cert_id, |
| 536 request_->ssl_info().cert_status, | 510 request_->ssl_info().cert_status, |
| 537 request_->ssl_info().security_bits, | 511 request_->ssl_info().security_bits, |
| 538 request_->ssl_info().connection_status); | 512 request_->ssl_info().connection_status); |
| 539 } else { | 513 } else { |
| 540 // We should not have any SSL state. | 514 // We should not have any SSL state. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 case net::URLRequestStatus::FAILED: | 660 case net::URLRequestStatus::FAILED: |
| 687 status = STATUS_UNDEFINED; | 661 status = STATUS_UNDEFINED; |
| 688 break; | 662 break; |
| 689 } | 663 } |
| 690 | 664 |
| 691 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); | 665 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); |
| 692 } | 666 } |
| 693 } | 667 } |
| 694 | 668 |
| 695 } // namespace content | 669 } // namespace content |
| OLD | NEW |