| 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
| 6 | 6 |
| 7 #include "content/child/resource_dispatcher.h" | 7 #include "content/child/resource_dispatcher.h" |
| 8 | 8 |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/bind.h" | 9 #include "base/bind.h" |
| 11 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 12 #include "base/debug/alias.h" | 11 #include "base/debug/alias.h" |
| 13 #include "base/debug/dump_without_crashing.h" | 12 #include "base/debug/dump_without_crashing.h" |
| 14 #include "base/debug/stack_trace.h" | 13 #include "base/debug/stack_trace.h" |
| 15 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 16 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
| 17 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 18 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 19 #include "base/rand_util.h" | 18 #include "base/rand_util.h" |
| 20 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "build/build_config.h" |
| 21 #include "content/child/request_extra_data.h" | 21 #include "content/child/request_extra_data.h" |
| 22 #include "content/child/request_info.h" | 22 #include "content/child/request_info.h" |
| 23 #include "content/child/resource_scheduling_filter.h" | 23 #include "content/child/resource_scheduling_filter.h" |
| 24 #include "content/child/shared_memory_received_data_factory.h" | 24 #include "content/child/shared_memory_received_data_factory.h" |
| 25 #include "content/child/site_isolation_stats_gatherer.h" | 25 #include "content/child/site_isolation_stats_gatherer.h" |
| 26 #include "content/child/sync_load_response.h" | 26 #include "content/child/sync_load_response.h" |
| 27 #include "content/child/threaded_data_provider.h" | 27 #include "content/child/threaded_data_provider.h" |
| 28 #include "content/common/inter_process_time_ticks_converter.h" | 28 #include "content/common/inter_process_time_ticks_converter.h" |
| 29 #include "content/common/navigation_params.h" | 29 #include "content/common/navigation_params.h" |
| 30 #include "content/common/resource_messages.h" | 30 #include "content/common/resource_messages.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 ResourceDispatcher::PendingRequestInfo* | 128 ResourceDispatcher::PendingRequestInfo* |
| 129 ResourceDispatcher::GetPendingRequestInfo(int request_id) { | 129 ResourceDispatcher::GetPendingRequestInfo(int request_id) { |
| 130 PendingRequestList::iterator it = pending_requests_.find(request_id); | 130 PendingRequestList::iterator it = pending_requests_.find(request_id); |
| 131 if (it == pending_requests_.end()) { | 131 if (it == pending_requests_.end()) { |
| 132 // This might happen for kill()ed requests on the webkit end. | 132 // This might happen for kill()ed requests on the webkit end. |
| 133 return NULL; | 133 return NULL; |
| 134 } | 134 } |
| 135 return &(it->second); | 135 return &(it->second); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void ResourceDispatcher::OnUploadProgress(int request_id, int64 position, | 138 void ResourceDispatcher::OnUploadProgress(int request_id, |
| 139 int64 size) { | 139 int64_t position, |
| 140 int64_t size) { |
| 140 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 141 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 141 if (!request_info) | 142 if (!request_info) |
| 142 return; | 143 return; |
| 143 | 144 |
| 144 request_info->peer->OnUploadProgress(position, size); | 145 request_info->peer->OnUploadProgress(position, size); |
| 145 | 146 |
| 146 // Acknowledge receipt | 147 // Acknowledge receipt |
| 147 message_sender_->Send(new ResourceHostMsg_UploadProgress_ACK(request_id)); | 148 message_sender_->Send(new ResourceHostMsg_UploadProgress_ACK(request_id)); |
| 148 } | 149 } |
| 149 | 150 |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 const PendingRequestInfo& request_info, | 717 const PendingRequestInfo& request_info, |
| 717 const base::TimeTicks& browser_completion_time) const { | 718 const base::TimeTicks& browser_completion_time) const { |
| 718 if (request_info.completion_time.is_null()) { | 719 if (request_info.completion_time.is_null()) { |
| 719 return browser_completion_time; | 720 return browser_completion_time; |
| 720 } | 721 } |
| 721 | 722 |
| 722 // TODO(simonjam): The optimal lower bound should be the most recent value of | 723 // TODO(simonjam): The optimal lower bound should be the most recent value of |
| 723 // TimeTicks::Now() returned to WebKit. Is it worth trying to cache that? | 724 // TimeTicks::Now() returned to WebKit. Is it worth trying to cache that? |
| 724 // Until then, |response_start| is used as it is the most recent value | 725 // Until then, |response_start| is used as it is the most recent value |
| 725 // returned for this request. | 726 // returned for this request. |
| 726 int64 result = std::max(browser_completion_time.ToInternalValue(), | 727 int64_t result = std::max(browser_completion_time.ToInternalValue(), |
| 727 request_info.response_start.ToInternalValue()); | 728 request_info.response_start.ToInternalValue()); |
| 728 result = std::min(result, request_info.completion_time.ToInternalValue()); | 729 result = std::min(result, request_info.completion_time.ToInternalValue()); |
| 729 return base::TimeTicks::FromInternalValue(result); | 730 return base::TimeTicks::FromInternalValue(result); |
| 730 } | 731 } |
| 731 | 732 |
| 732 base::TimeTicks ResourceDispatcher::ConsumeIOTimestamp() { | 733 base::TimeTicks ResourceDispatcher::ConsumeIOTimestamp() { |
| 733 if (io_timestamp_ == base::TimeTicks()) | 734 if (io_timestamp_ == base::TimeTicks()) |
| 734 return base::TimeTicks::Now(); | 735 return base::TimeTicks::Now(); |
| 735 base::TimeTicks result = io_timestamp_; | 736 base::TimeTicks result = io_timestamp_; |
| 736 io_timestamp_ = base::TimeTicks(); | 737 io_timestamp_ = base::TimeTicks(); |
| 737 return result; | 738 return result; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 *frame_origin = extra_data->frame_origin(); | 862 *frame_origin = extra_data->frame_origin(); |
| 862 return request.Pass(); | 863 return request.Pass(); |
| 863 } | 864 } |
| 864 | 865 |
| 865 void ResourceDispatcher::SetResourceSchedulingFilter( | 866 void ResourceDispatcher::SetResourceSchedulingFilter( |
| 866 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { | 867 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { |
| 867 resource_scheduling_filter_ = resource_scheduling_filter; | 868 resource_scheduling_filter_ = resource_scheduling_filter; |
| 868 } | 869 } |
| 869 | 870 |
| 870 } // namespace content | 871 } // namespace content |
| OLD | NEW |