| 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/location.h" | 8 #include "base/location.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/profiler/scoped_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 | 331 |
| 332 void ResourceLoader::OnResponseStarted(net::URLRequest* unused) { | 332 void ResourceLoader::OnResponseStarted(net::URLRequest* unused) { |
| 333 DCHECK_EQ(request_.get(), unused); | 333 DCHECK_EQ(request_.get(), unused); |
| 334 | 334 |
| 335 DVLOG(1) << "OnResponseStarted: " << request_->url().spec(); | 335 DVLOG(1) << "OnResponseStarted: " << request_->url().spec(); |
| 336 | 336 |
| 337 progress_timer_.Stop(); | 337 progress_timer_.Stop(); |
| 338 | 338 |
| 339 // The CanLoadPage check should take place after any server redirects have | |
| 340 // finished, at the point in time that we know a page will commit in the | |
| 341 // renderer process. | |
| 342 ResourceRequestInfoImpl* info = GetRequestInfo(); | |
| 343 ChildProcessSecurityPolicyImpl* policy = | |
| 344 ChildProcessSecurityPolicyImpl::GetInstance(); | |
| 345 if (!policy->CanLoadPage(info->GetChildID(), | |
| 346 request_->url(), | |
| 347 info->GetResourceType())) { | |
| 348 Cancel(); | |
| 349 return; | |
| 350 } | |
| 351 | |
| 352 if (!request_->status().is_success()) { | 339 if (!request_->status().is_success()) { |
| 353 ResponseCompleted(); | 340 ResponseCompleted(); |
| 354 return; | 341 return; |
| 355 } | 342 } |
| 356 | 343 |
| 357 // We want to send a final upload progress message prior to sending the | 344 // We want to send a final upload progress message prior to sending the |
| 358 // response complete message even if we're waiting for an ack to to a | 345 // response complete message even if we're waiting for an ack to to a |
| 359 // previous upload progress message. | 346 // previous upload progress message. |
| 347 ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 360 if (info->is_upload_progress_enabled()) { | 348 if (info->is_upload_progress_enabled()) { |
| 361 waiting_for_upload_progress_ack_ = false; | 349 waiting_for_upload_progress_ack_ = false; |
| 362 ReportUploadProgress(); | 350 ReportUploadProgress(); |
| 363 } | 351 } |
| 364 | 352 |
| 365 CompleteResponseStarted(); | 353 CompleteResponseStarted(); |
| 366 | 354 |
| 367 if (is_deferred()) | 355 if (is_deferred()) |
| 368 return; | 356 return; |
| 369 | 357 |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 case net::URLRequestStatus::FAILED: | 755 case net::URLRequestStatus::FAILED: |
| 768 status = STATUS_UNDEFINED; | 756 status = STATUS_UNDEFINED; |
| 769 break; | 757 break; |
| 770 } | 758 } |
| 771 | 759 |
| 772 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); | 760 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); |
| 773 } | 761 } |
| 774 } | 762 } |
| 775 | 763 |
| 776 } // namespace content | 764 } // namespace content |
| OLD | NEW |