| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 scoped_refptr<ResourceResponse> response = new ResourceResponse(); | 635 scoped_refptr<ResourceResponse> response = new ResourceResponse(); |
| 636 PopulateResourceResponse(info, request_.get(), response.get()); | 636 PopulateResourceResponse(info, request_.get(), response.get()); |
| 637 | 637 |
| 638 delegate_->DidReceiveResponse(this); | 638 delegate_->DidReceiveResponse(this); |
| 639 | 639 |
| 640 // TODO(darin): Remove ScopedTracker below once crbug.com/475761 is fixed. | 640 // TODO(darin): Remove ScopedTracker below once crbug.com/475761 is fixed. |
| 641 tracked_objects::ScopedTracker tracking_profile( | 641 tracked_objects::ScopedTracker tracking_profile( |
| 642 FROM_HERE_WITH_EXPLICIT_FUNCTION("475761 OnResponseStarted()")); | 642 FROM_HERE_WITH_EXPLICIT_FUNCTION("475761 OnResponseStarted()")); |
| 643 | 643 |
| 644 read_deferral_start_time_ = base::TimeTicks::Now(); | 644 read_deferral_start_time_ = base::TimeTicks::Now(); |
| 645 ScopedDeferral scoped_deferral(this, DEFERRED_READ); | 645 // Using a ScopedDeferral here would result in calling ReadMore(true) on sync |
| 646 // success. Calling ReadMore(false) here instead allows small responses to be |
| 647 // handled completely synchronously, if no ResourceHandler defers handling of |
| 648 // the response. |
| 649 deferred_stage_ = DEFERRED_SYNC; |
| 646 handler_->OnResponseStarted(response.get(), | 650 handler_->OnResponseStarted(response.get(), |
| 647 base::MakeUnique<Controller>(this)); | 651 base::MakeUnique<Controller>(this)); |
| 652 if (is_deferred()) { |
| 653 deferred_stage_ = DEFERRED_READ; |
| 654 } else { |
| 655 ReadMore(false); |
| 656 } |
| 648 } | 657 } |
| 649 | 658 |
| 650 void ResourceLoader::ReadMore(bool handle_result_async) { | 659 void ResourceLoader::ReadMore(bool handle_result_async) { |
| 651 TRACE_EVENT_WITH_FLOW0("loading", "ResourceLoader::ReadMore", this, | 660 TRACE_EVENT_WITH_FLOW0("loading", "ResourceLoader::ReadMore", this, |
| 652 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); | 661 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); |
| 653 DCHECK(!is_deferred()); | 662 DCHECK(!is_deferred()); |
| 654 | 663 |
| 655 // Make sure we track the buffer in at least one place. This ensures it gets | 664 // Make sure we track the buffer in at least one place. This ensures it gets |
| 656 // deleted even in the case the request has already finished its job and | 665 // deleted even in the case the request has already finished its job and |
| 657 // doesn't use the buffer. | 666 // doesn't use the buffer. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", prefetch_status, | 811 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", prefetch_status, |
| 803 STATUS_MAX); | 812 STATUS_MAX); |
| 804 } | 813 } |
| 805 } else if (request_->response_info().unused_since_prefetch) { | 814 } else if (request_->response_info().unused_since_prefetch) { |
| 806 TimeDelta total_time = base::TimeTicks::Now() - request_->creation_time(); | 815 TimeDelta total_time = base::TimeTicks::Now() - request_->creation_time(); |
| 807 UMA_HISTOGRAM_TIMES("Net.Prefetch.TimeSpentOnPrefetchHit", total_time); | 816 UMA_HISTOGRAM_TIMES("Net.Prefetch.TimeSpentOnPrefetchHit", total_time); |
| 808 } | 817 } |
| 809 } | 818 } |
| 810 | 819 |
| 811 } // namespace content | 820 } // namespace content |
| OLD | NEW |