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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 } | 920 } |
923 } | 921 } |
924 | 922 |
925 ResourceContext* resource_context = filter_->resource_context(); | 923 ResourceContext* resource_context = filter_->resource_context(); |
926 // http://crbug.com/90971 | 924 // http://crbug.com/90971 |
927 CHECK(ContainsKey(active_resource_contexts_, resource_context)); | 925 CHECK(ContainsKey(active_resource_contexts_, resource_context)); |
928 | 926 |
929 if (is_shutdown_ || | 927 if (is_shutdown_ || |
930 !ShouldServiceRequest(process_type, child_id, request_data, | 928 !ShouldServiceRequest(process_type, child_id, request_data, |
931 filter_->file_system_context())) { | 929 filter_->file_system_context())) { |
932 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); | 930 AbortRequestBeforeItStarts(filter_, sync_result, request_id); |
933 return; | 931 return; |
934 } | 932 } |
935 | 933 |
936 const Referrer referrer(request_data.referrer, request_data.referrer_policy); | 934 const Referrer referrer(request_data.referrer, request_data.referrer_policy); |
937 | 935 |
938 // Allow the observer to block/handle the request. | 936 // Allow the observer to block/handle the request. |
939 if (delegate_ && !delegate_->ShouldBeginRequest(child_id, | 937 if (delegate_ && !delegate_->ShouldBeginRequest(child_id, |
940 route_id, | 938 route_id, |
941 request_data.method, | 939 request_data.method, |
942 request_data.url, | 940 request_data.url, |
943 request_data.resource_type, | 941 request_data.resource_type, |
944 resource_context)) { | 942 resource_context)) { |
945 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); | 943 AbortRequestBeforeItStarts(filter_, sync_result, request_id); |
946 return; | 944 return; |
947 } | 945 } |
948 | 946 |
949 bool is_sync_load = sync_result != NULL; | 947 bool is_sync_load = sync_result != NULL; |
950 int load_flags = | 948 int load_flags = |
951 BuildLoadFlagsForRequest(request_data, child_id, is_sync_load); | 949 BuildLoadFlagsForRequest(request_data, child_id, is_sync_load); |
952 | 950 |
953 GlobalRoutingID id(child_id, route_id); | 951 GlobalRoutingID id(child_id, route_id); |
954 if (!offline_policy_map_[id]) | 952 if (!offline_policy_map_[id]) |
955 offline_policy_map_[id] = new OfflinePolicy(); | 953 offline_policy_map_[id] = new OfflinePolicy(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 appcache::AppCacheInterceptor::SetExtraRequestInfo( | 1032 appcache::AppCacheInterceptor::SetExtraRequestInfo( |
1035 request, filter_->appcache_service(), child_id, | 1033 request, filter_->appcache_service(), child_id, |
1036 request_data.appcache_host_id, request_data.resource_type); | 1034 request_data.appcache_host_id, request_data.resource_type); |
1037 | 1035 |
1038 // Construct the IPC resource handler. | 1036 // Construct the IPC resource handler. |
1039 scoped_ptr<ResourceHandler> handler; | 1037 scoped_ptr<ResourceHandler> handler; |
1040 if (sync_result) { | 1038 if (sync_result) { |
1041 handler.reset(new SyncResourceHandler( | 1039 handler.reset(new SyncResourceHandler( |
1042 filter_, request, sync_result, this)); | 1040 filter_, request, sync_result, this)); |
1043 } else { | 1041 } else { |
1044 handler.reset(new AsyncResourceHandler( | 1042 handler.reset(new AsyncResourceHandler(filter_, request, this)); |
1045 filter_, route_id, request, this)); | |
1046 } | 1043 } |
1047 | 1044 |
1048 // The RedirectToFileResourceHandler depends on being next in the chain. | 1045 // The RedirectToFileResourceHandler depends on being next in the chain. |
1049 if (request_data.download_to_file) { | 1046 if (request_data.download_to_file) { |
1050 handler.reset( | 1047 handler.reset( |
1051 new RedirectToFileResourceHandler(handler.Pass(), child_id, this)); | 1048 new RedirectToFileResourceHandler(handler.Pass(), child_id, this)); |
1052 } | 1049 } |
1053 | 1050 |
1054 // Install a CrossSiteResourceHandler if this request is coming from a | 1051 // Install a CrossSiteResourceHandler if this request is coming from a |
1055 // RenderViewHost with a pending cross-site request. We only check this for | 1052 // 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) | 1876 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) |
1880 && !policy->CanReadRawCookies(child_id)) { | 1877 && !policy->CanReadRawCookies(child_id)) { |
1881 VLOG(1) << "Denied unauthorized request for raw headers"; | 1878 VLOG(1) << "Denied unauthorized request for raw headers"; |
1882 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; | 1879 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; |
1883 } | 1880 } |
1884 | 1881 |
1885 return load_flags; | 1882 return load_flags; |
1886 } | 1883 } |
1887 | 1884 |
1888 } // namespace content | 1885 } // namespace content |
OLD | NEW |