| 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" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 if (request_->load_flags() & net::LOAD_ENABLE_UPLOAD_PROGRESS) { | 158 if (request_->load_flags() & net::LOAD_ENABLE_UPLOAD_PROGRESS) { |
| 159 handler_->OnUploadProgress(progress.position(), progress.size()); | 159 handler_->OnUploadProgress(progress.position(), progress.size()); |
| 160 waiting_for_upload_progress_ack_ = true; | 160 waiting_for_upload_progress_ack_ = true; |
| 161 } | 161 } |
| 162 last_upload_ticks_ = TimeTicks::Now(); | 162 last_upload_ticks_ = TimeTicks::Now(); |
| 163 last_upload_position_ = progress.position(); | 163 last_upload_position_ = progress.position(); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 void ResourceLoader::MarkAsTransferring() { | 167 void ResourceLoader::MarkAsTransferring() { |
| 168 CHECK(ResourceType::IsFrame(GetRequestInfo()->GetResourceType())) | 168 CHECK(IsResourceTypeFrame(GetRequestInfo()->GetResourceType())) |
| 169 << "Can only transfer for navigations"; | 169 << "Can only transfer for navigations"; |
| 170 is_transferring_ = true; | 170 is_transferring_ = true; |
| 171 } | 171 } |
| 172 | 172 |
| 173 void ResourceLoader::CompleteTransfer() { | 173 void ResourceLoader::CompleteTransfer() { |
| 174 // Although CrossSiteResourceHandler defers at OnResponseStarted | 174 // Although CrossSiteResourceHandler defers at OnResponseStarted |
| 175 // (DEFERRED_READ), it may be seeing a replay of events via | 175 // (DEFERRED_READ), it may be seeing a replay of events via |
| 176 // BufferedResourceHandler, and so the request itself is actually deferred at | 176 // BufferedResourceHandler, and so the request itself is actually deferred at |
| 177 // a later read stage. | 177 // a later read stage. |
| 178 DCHECK(DEFERRED_READ == deferred_stage_ || | 178 DCHECK(DEFERRED_READ == deferred_stage_ || |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 } | 672 } |
| 673 } | 673 } |
| 674 | 674 |
| 675 void ResourceLoader::CallDidFinishLoading() { | 675 void ResourceLoader::CallDidFinishLoading() { |
| 676 delegate_->DidFinishLoading(this); | 676 delegate_->DidFinishLoading(this); |
| 677 } | 677 } |
| 678 | 678 |
| 679 void ResourceLoader::RecordHistograms() { | 679 void ResourceLoader::RecordHistograms() { |
| 680 ResourceRequestInfoImpl* info = GetRequestInfo(); | 680 ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 681 | 681 |
| 682 if (info->GetResourceType() == ResourceType::PREFETCH) { | 682 if (info->GetResourceType() == RESOURCE_TYPE_PREFETCH) { |
| 683 PrefetchStatus status = STATUS_UNDEFINED; | 683 PrefetchStatus status = STATUS_UNDEFINED; |
| 684 TimeDelta total_time = base::TimeTicks::Now() - request_->creation_time(); | 684 TimeDelta total_time = base::TimeTicks::Now() - request_->creation_time(); |
| 685 | 685 |
| 686 switch (request_->status().status()) { | 686 switch (request_->status().status()) { |
| 687 case net::URLRequestStatus::SUCCESS: | 687 case net::URLRequestStatus::SUCCESS: |
| 688 if (request_->was_cached()) { | 688 if (request_->was_cached()) { |
| 689 status = STATUS_SUCCESS_FROM_CACHE; | 689 status = STATUS_SUCCESS_FROM_CACHE; |
| 690 UMA_HISTOGRAM_TIMES("Net.Prefetch.TimeSpentPrefetchingFromCache", | 690 UMA_HISTOGRAM_TIMES("Net.Prefetch.TimeSpentPrefetchingFromCache", |
| 691 total_time); | 691 total_time); |
| 692 } else { | 692 } else { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 703 case net::URLRequestStatus::FAILED: | 703 case net::URLRequestStatus::FAILED: |
| 704 status = STATUS_UNDEFINED; | 704 status = STATUS_UNDEFINED; |
| 705 break; | 705 break; |
| 706 } | 706 } |
| 707 | 707 |
| 708 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); | 708 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); |
| 709 } | 709 } |
| 710 } | 710 } |
| 711 | 711 |
| 712 } // namespace content | 712 } // namespace content |
| OLD | NEW |