Chromium Code Reviews| 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/browser/loader/resource_dispatcher_host_impl.h" | 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 // are all positive (since histograms expect positive sample values). | 131 // are all positive (since histograms expect positive sample values). |
| 132 const int kAllNetErrorCodes[] = { | 132 const int kAllNetErrorCodes[] = { |
| 133 #define NET_ERROR(label, value) -(value), | 133 #define NET_ERROR(label, value) -(value), |
| 134 #include "net/base/net_error_list.h" | 134 #include "net/base/net_error_list.h" |
| 135 #undef NET_ERROR | 135 #undef NET_ERROR |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 // Aborts a request before an URLRequest has actually been created. | 138 // Aborts a request before an URLRequest has actually been created. |
| 139 void AbortRequestBeforeItStarts(ResourceMessageFilter* filter, | 139 void AbortRequestBeforeItStarts(ResourceMessageFilter* filter, |
| 140 IPC::Message* sync_result, | 140 IPC::Message* sync_result, |
| 141 int route_id, | |
| 142 int request_id) { | 141 int request_id) { |
| 143 if (sync_result) { | 142 if (sync_result) { |
| 144 SyncLoadResult result; | 143 SyncLoadResult result; |
| 145 result.error_code = net::ERR_ABORTED; | 144 result.error_code = net::ERR_ABORTED; |
| 146 ResourceHostMsg_SyncLoad::WriteReplyParams(sync_result, result); | 145 ResourceHostMsg_SyncLoad::WriteReplyParams(sync_result, result); |
| 147 filter->Send(sync_result); | 146 filter->Send(sync_result); |
| 148 } else { | 147 } else { |
| 149 // Tell the renderer that this request was disallowed. | 148 // Tell the renderer that this request was disallowed. |
| 150 filter->Send(new ResourceMsg_RequestComplete( | 149 filter->Send(new ResourceMsg_RequestComplete( |
| 151 route_id, | |
| 152 request_id, | 150 request_id, |
| 153 net::ERR_ABORTED, | 151 net::ERR_ABORTED, |
| 154 false, | 152 false, |
| 155 std::string(), // No security info needed, connection not established. | 153 std::string(), // No security info needed, connection not established. |
| 156 base::TimeTicks())); | 154 base::TimeTicks())); |
| 157 } | 155 } |
| 158 } | 156 } |
| 159 | 157 |
| 160 void SetReferrerForRequest(net::URLRequest* request, const Referrer& referrer) { | 158 void SetReferrerForRequest(net::URLRequest* request, const Referrer& referrer) { |
| 161 if (!referrer.url.is_valid() || | 159 if (!referrer.url.is_valid() || |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 837 DCHECK(ok); | 835 DCHECK(ok); |
| 838 GlobalRequestID id(filter_->child_id(), request_id); | 836 GlobalRequestID id(filter_->child_id(), request_id); |
| 839 DelegateMap::iterator it = delegate_map_.find(id); | 837 DelegateMap::iterator it = delegate_map_.find(id); |
| 840 if (it != delegate_map_.end()) { | 838 if (it != delegate_map_.end()) { |
| 841 ObserverList<ResourceMessageDelegate>::Iterator del_it(*it->second); | 839 ObserverList<ResourceMessageDelegate>::Iterator del_it(*it->second); |
| 842 ResourceMessageDelegate* delegate; | 840 ResourceMessageDelegate* delegate; |
| 843 while (!handled && (delegate = del_it.GetNext()) != NULL) { | 841 while (!handled && (delegate = del_it.GetNext()) != NULL) { |
| 844 handled = delegate->OnMessageReceived(message, message_was_ok); | 842 handled = delegate->OnMessageReceived(message, message_was_ok); |
| 845 } | 843 } |
| 846 } | 844 } |
| 845 | |
| 846 // There could be race conditions in receiving ACKs after a request is | |
| 847 // removed. If the control IPC isn't handled here, an assert will fire in | |
| 848 // RenderProcessHostImpl::OnMessageReceived. | |
| 849 handled = true; | |
|
awong
2013/09/06 17:04:11
If I read this correctly, any ResourceHostMsg will
jam
2013/09/06 17:12:04
right
jam
2013/09/06 17:22:17
btw I've uploaded a new patchset that does this no
awong
2013/09/06 17:37:34
It's consistent now so that bit is better.
Howeve
jam
2013/09/06 18:00:20
Given the asynchronous nature of our code base, I
| |
| 847 } | 850 } |
| 848 | 851 |
| 849 if (message.type() == ViewHostMsg_DidLoadResourceFromMemoryCache::ID) { | 852 if (message.type() == ViewHostMsg_DidLoadResourceFromMemoryCache::ID) { |
| 850 // We just needed to peek at this message. We still want it to reach its | 853 // We just needed to peek at this message. We still want it to reach its |
| 851 // normal destination. | 854 // normal destination. |
| 852 handled = false; | 855 handled = false; |
| 853 } | 856 } |
| 854 | 857 |
| 855 filter_ = NULL; | 858 filter_ = NULL; |
| 856 return handled; | 859 return handled; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 } | 925 } |
| 923 } | 926 } |
| 924 | 927 |
| 925 ResourceContext* resource_context = filter_->resource_context(); | 928 ResourceContext* resource_context = filter_->resource_context(); |
| 926 // http://crbug.com/90971 | 929 // http://crbug.com/90971 |
| 927 CHECK(ContainsKey(active_resource_contexts_, resource_context)); | 930 CHECK(ContainsKey(active_resource_contexts_, resource_context)); |
| 928 | 931 |
| 929 if (is_shutdown_ || | 932 if (is_shutdown_ || |
| 930 !ShouldServiceRequest(process_type, child_id, request_data, | 933 !ShouldServiceRequest(process_type, child_id, request_data, |
| 931 filter_->file_system_context())) { | 934 filter_->file_system_context())) { |
| 932 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); | 935 AbortRequestBeforeItStarts(filter_, sync_result, request_id); |
| 933 return; | 936 return; |
| 934 } | 937 } |
| 935 | 938 |
| 936 const Referrer referrer(request_data.referrer, request_data.referrer_policy); | 939 const Referrer referrer(request_data.referrer, request_data.referrer_policy); |
| 937 | 940 |
| 938 // Allow the observer to block/handle the request. | 941 // Allow the observer to block/handle the request. |
| 939 if (delegate_ && !delegate_->ShouldBeginRequest(child_id, | 942 if (delegate_ && !delegate_->ShouldBeginRequest(child_id, |
| 940 route_id, | 943 route_id, |
| 941 request_data.method, | 944 request_data.method, |
| 942 request_data.url, | 945 request_data.url, |
| 943 request_data.resource_type, | 946 request_data.resource_type, |
| 944 resource_context)) { | 947 resource_context)) { |
| 945 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); | 948 AbortRequestBeforeItStarts(filter_, sync_result, request_id); |
| 946 return; | 949 return; |
| 947 } | 950 } |
| 948 | 951 |
| 949 bool is_sync_load = sync_result != NULL; | 952 bool is_sync_load = sync_result != NULL; |
| 950 int load_flags = | 953 int load_flags = |
| 951 BuildLoadFlagsForRequest(request_data, child_id, is_sync_load); | 954 BuildLoadFlagsForRequest(request_data, child_id, is_sync_load); |
| 952 | 955 |
| 953 GlobalRoutingID id(child_id, route_id); | 956 GlobalRoutingID id(child_id, route_id); |
| 954 if (!offline_policy_map_[id]) | 957 if (!offline_policy_map_[id]) |
| 955 offline_policy_map_[id] = new OfflinePolicy(); | 958 offline_policy_map_[id] = new OfflinePolicy(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1034 appcache::AppCacheInterceptor::SetExtraRequestInfo( | 1037 appcache::AppCacheInterceptor::SetExtraRequestInfo( |
| 1035 request, filter_->appcache_service(), child_id, | 1038 request, filter_->appcache_service(), child_id, |
| 1036 request_data.appcache_host_id, request_data.resource_type); | 1039 request_data.appcache_host_id, request_data.resource_type); |
| 1037 | 1040 |
| 1038 // Construct the IPC resource handler. | 1041 // Construct the IPC resource handler. |
| 1039 scoped_ptr<ResourceHandler> handler; | 1042 scoped_ptr<ResourceHandler> handler; |
| 1040 if (sync_result) { | 1043 if (sync_result) { |
| 1041 handler.reset(new SyncResourceHandler( | 1044 handler.reset(new SyncResourceHandler( |
| 1042 filter_, request, sync_result, this)); | 1045 filter_, request, sync_result, this)); |
| 1043 } else { | 1046 } else { |
| 1044 handler.reset(new AsyncResourceHandler( | 1047 handler.reset(new AsyncResourceHandler(filter_, request, this)); |
| 1045 filter_, route_id, request, this)); | |
| 1046 } | 1048 } |
| 1047 | 1049 |
| 1048 // The RedirectToFileResourceHandler depends on being next in the chain. | 1050 // The RedirectToFileResourceHandler depends on being next in the chain. |
| 1049 if (request_data.download_to_file) { | 1051 if (request_data.download_to_file) { |
| 1050 handler.reset( | 1052 handler.reset( |
| 1051 new RedirectToFileResourceHandler(handler.Pass(), child_id, this)); | 1053 new RedirectToFileResourceHandler(handler.Pass(), child_id, this)); |
| 1052 } | 1054 } |
| 1053 | 1055 |
| 1054 // Install a CrossSiteResourceHandler if this request is coming from a | 1056 // Install a CrossSiteResourceHandler if this request is coming from a |
| 1055 // RenderViewHost with a pending cross-site request. We only check this for | 1057 // RenderViewHost with a pending cross-site request. We only check this for |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1879 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) | 1881 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) |
| 1880 && !policy->CanReadRawCookies(child_id)) { | 1882 && !policy->CanReadRawCookies(child_id)) { |
| 1881 VLOG(1) << "Denied unauthorized request for raw headers"; | 1883 VLOG(1) << "Denied unauthorized request for raw headers"; |
| 1882 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; | 1884 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; |
| 1883 } | 1885 } |
| 1884 | 1886 |
| 1885 return load_flags; | 1887 return load_flags; |
| 1886 } | 1888 } |
| 1887 | 1889 |
| 1888 } // namespace content | 1890 } // namespace content |
| OLD | NEW |