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" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/debug/alias.h" | 12 #include "base/debug/alias.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/memory/shared_memory.h" | 14 #include "base/memory/shared_memory.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "content/child/request_extra_data.h" | 18 #include "content/child/request_extra_data.h" |
19 #include "content/child/site_isolation_policy.h" | |
19 #include "content/common/inter_process_time_ticks_converter.h" | 20 #include "content/common/inter_process_time_ticks_converter.h" |
20 #include "content/common/resource_messages.h" | 21 #include "content/common/resource_messages.h" |
21 #include "content/public/child/resource_dispatcher_delegate.h" | 22 #include "content/public/child/resource_dispatcher_delegate.h" |
22 #include "content/public/common/resource_response.h" | 23 #include "content/public/common/resource_response.h" |
23 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
24 #include "net/base/net_util.h" | 25 #include "net/base/net_util.h" |
25 #include "net/base/request_priority.h" | 26 #include "net/base/request_priority.h" |
26 #include "net/http/http_response_headers.h" | 27 #include "net/http/http_response_headers.h" |
27 #include "webkit/common/resource_type.h" | 28 #include "webkit/common/resource_type.h" |
28 | 29 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 // The request to send, created on initialization for modification and | 90 // The request to send, created on initialization for modification and |
90 // appending data. | 91 // appending data. |
91 ResourceHostMsg_Request request_; | 92 ResourceHostMsg_Request request_; |
92 | 93 |
93 // ID for the request, valid once Start()ed, -1 if not valid yet. | 94 // ID for the request, valid once Start()ed, -1 if not valid yet. |
94 int request_id_; | 95 int request_id_; |
95 | 96 |
96 // The routing id used when sending IPC messages. | 97 // The routing id used when sending IPC messages. |
97 int routing_id_; | 98 int routing_id_; |
98 | 99 |
100 // The security origin of the frame that initiates this request. | |
101 WebKit::WebString frame_origin_; | |
102 | |
99 bool is_synchronous_request_; | 103 bool is_synchronous_request_; |
100 }; | 104 }; |
101 | 105 |
102 IPCResourceLoaderBridge::IPCResourceLoaderBridge( | 106 IPCResourceLoaderBridge::IPCResourceLoaderBridge( |
103 ResourceDispatcher* dispatcher, | 107 ResourceDispatcher* dispatcher, |
104 const ResourceLoaderBridge::RequestInfo& request_info) | 108 const ResourceLoaderBridge::RequestInfo& request_info) |
105 : peer_(NULL), | 109 : peer_(NULL), |
106 dispatcher_(dispatcher), | 110 dispatcher_(dispatcher), |
107 request_id_(-1), | 111 request_id_(-1), |
108 routing_id_(request_info.routing_id), | 112 routing_id_(request_info.routing_id), |
(...skipping 19 matching lines...) Expand all Loading... | |
128 request_.is_main_frame = extra_data->is_main_frame(); | 132 request_.is_main_frame = extra_data->is_main_frame(); |
129 request_.frame_id = extra_data->frame_id(); | 133 request_.frame_id = extra_data->frame_id(); |
130 request_.parent_is_main_frame = extra_data->parent_is_main_frame(); | 134 request_.parent_is_main_frame = extra_data->parent_is_main_frame(); |
131 request_.parent_frame_id = extra_data->parent_frame_id(); | 135 request_.parent_frame_id = extra_data->parent_frame_id(); |
132 request_.allow_download = extra_data->allow_download(); | 136 request_.allow_download = extra_data->allow_download(); |
133 request_.transition_type = extra_data->transition_type(); | 137 request_.transition_type = extra_data->transition_type(); |
134 request_.transferred_request_child_id = | 138 request_.transferred_request_child_id = |
135 extra_data->transferred_request_child_id(); | 139 extra_data->transferred_request_child_id(); |
136 request_.transferred_request_request_id = | 140 request_.transferred_request_request_id = |
137 extra_data->transferred_request_request_id(); | 141 extra_data->transferred_request_request_id(); |
142 frame_origin_ = extra_data->frame_origin(); | |
138 } else { | 143 } else { |
144 // TODO(dsjang): Consult the expert when this branch is taken. | |
Charlie Reis
2013/08/19 16:20:06
What are you trying to figure out?
dsjang
2013/08/19 21:37:18
I'm trying to make sure that the lack of request_i
| |
139 request_.is_main_frame = false; | 145 request_.is_main_frame = false; |
140 request_.frame_id = -1; | 146 request_.frame_id = -1; |
141 request_.parent_is_main_frame = false; | 147 request_.parent_is_main_frame = false; |
142 request_.parent_frame_id = -1; | 148 request_.parent_frame_id = -1; |
143 request_.allow_download = true; | 149 request_.allow_download = true; |
144 request_.transition_type = PAGE_TRANSITION_LINK; | 150 request_.transition_type = PAGE_TRANSITION_LINK; |
145 request_.transferred_request_child_id = -1; | 151 request_.transferred_request_child_id = -1; |
146 request_.transferred_request_request_id = -1; | 152 request_.transferred_request_request_id = -1; |
147 } | 153 } |
148 } | 154 } |
(...skipping 19 matching lines...) Expand all Loading... | |
168 request_.request_body = request_body; | 174 request_.request_body = request_body; |
169 } | 175 } |
170 | 176 |
171 // Writes a footer on the message and sends it | 177 // Writes a footer on the message and sends it |
172 bool IPCResourceLoaderBridge::Start(Peer* peer) { | 178 bool IPCResourceLoaderBridge::Start(Peer* peer) { |
173 if (request_id_ != -1) { | 179 if (request_id_ != -1) { |
174 NOTREACHED() << "Starting a request twice"; | 180 NOTREACHED() << "Starting a request twice"; |
175 return false; | 181 return false; |
176 } | 182 } |
177 | 183 |
178 peer_ = peer; | 184 // TODO(dsjang): Figure out when exactly frame_id gets -1 to see if that case |
185 // is security irrelevant. | |
Charlie Reis
2013/08/19 16:20:06
Any luck tracking this down?
dsjang
2013/08/19 21:37:18
Resolved this issue, and added a comment about the
| |
186 if (request_.frame_id >= 0) { | |
187 // SiteIsolationPolicy is refcounted, and it is deallocated when | |
188 // IPCResourceLoaderBridge is freed. | |
189 // This is buggy. | |
Charlie Reis
2013/08/19 16:20:06
You're storing it in a normal pointer. :)
dsjang
2013/08/19 21:37:18
Done.
| |
190 peer_ = new SiteIsolationPolicy(peer, | |
191 frame_origin_, | |
192 request_.url, | |
193 request_id_, | |
194 request_.resource_type); | |
195 } | |
179 | 196 |
180 // generate the request ID, and append it to the message | 197 // generate the request ID, and append it to the message |
181 request_id_ = dispatcher_->AddPendingRequest( | 198 request_id_ = dispatcher_->AddPendingRequest( |
182 peer_, request_.resource_type, request_.url); | 199 peer_, request_.resource_type, request_.url); |
183 | 200 |
184 return dispatcher_->message_sender()->Send( | 201 return dispatcher_->message_sender()->Send( |
185 new ResourceHostMsg_RequestResource(routing_id_, request_id_, request_)); | 202 new ResourceHostMsg_RequestResource(routing_id_, request_id_, request_)); |
186 } | 203 } |
187 | 204 |
188 void IPCResourceLoaderBridge::Cancel() { | 205 void IPCResourceLoaderBridge::Cancel() { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 if (delegate_) { | 356 if (delegate_) { |
340 ResourceLoaderBridge::Peer* new_peer = | 357 ResourceLoaderBridge::Peer* new_peer = |
341 delegate_->OnReceivedResponse( | 358 delegate_->OnReceivedResponse( |
342 request_info->peer, response_head.mime_type, request_info->url); | 359 request_info->peer, response_head.mime_type, request_info->url); |
343 if (new_peer) | 360 if (new_peer) |
344 request_info->peer = new_peer; | 361 request_info->peer = new_peer; |
345 } | 362 } |
346 | 363 |
347 ResourceResponseInfo renderer_response_info; | 364 ResourceResponseInfo renderer_response_info; |
348 ToResourceResponseInfo(*request_info, response_head, &renderer_response_info); | 365 ToResourceResponseInfo(*request_info, response_head, &renderer_response_info); |
366 | |
Charlie Reis
2013/08/19 16:20:06
nit: Remove empty line.
dsjang
2013/08/19 21:37:18
Done.
| |
349 request_info->peer->OnReceivedResponse(renderer_response_info); | 367 request_info->peer->OnReceivedResponse(renderer_response_info); |
350 } | 368 } |
351 | 369 |
352 void ResourceDispatcher::OnReceivedCachedMetadata( | 370 void ResourceDispatcher::OnReceivedCachedMetadata( |
353 int request_id, const std::vector<char>& data) { | 371 int request_id, const std::vector<char>& data) { |
354 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 372 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
355 if (!request_info) | 373 if (!request_info) |
356 return; | 374 return; |
357 | 375 |
358 if (data.size()) | 376 if (data.size()) |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
758 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { | 776 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { |
759 while (!queue->empty()) { | 777 while (!queue->empty()) { |
760 IPC::Message* message = queue->front(); | 778 IPC::Message* message = queue->front(); |
761 ReleaseResourcesInDataMessage(*message); | 779 ReleaseResourcesInDataMessage(*message); |
762 queue->pop_front(); | 780 queue->pop_front(); |
763 delete message; | 781 delete message; |
764 } | 782 } |
765 } | 783 } |
766 | 784 |
767 } // namespace content | 785 } // namespace content |
OLD | NEW |