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/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" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "content/child/sync_load_response.h" | 21 #include "content/child/sync_load_response.h" |
| 22 #include "content/common/inter_process_time_ticks_converter.h" | 22 #include "content/common/inter_process_time_ticks_converter.h" |
| 23 #include "content/common/resource_messages.h" | 23 #include "content/common/resource_messages.h" |
| 24 #include "content/public/child/request_peer.h" | 24 #include "content/public/child/request_peer.h" |
| 25 #include "content/public/child/resource_dispatcher_delegate.h" | 25 #include "content/public/child/resource_dispatcher_delegate.h" |
| 26 #include "content/public/common/resource_response.h" | 26 #include "content/public/common/resource_response.h" |
| 27 #include "net/base/net_errors.h" | 27 #include "net/base/net_errors.h" |
| 28 #include "net/base/net_util.h" | 28 #include "net/base/net_util.h" |
| 29 #include "net/base/request_priority.h" | 29 #include "net/base/request_priority.h" |
| 30 #include "net/http/http_response_headers.h" | 30 #include "net/http/http_response_headers.h" |
| 31 #include "webkit/child/resource_loader_bridge.h" | |
| 32 #include "webkit/common/resource_type.h" | 31 #include "webkit/common/resource_type.h" |
| 33 | 32 |
| 34 using webkit_glue::ResourceLoaderBridge; | 33 using webkit_glue::ResourceLoaderBridge; |
| 35 using webkit_glue::ResourceResponseInfo; | 34 using webkit_glue::ResourceResponseInfo; |
| 36 | 35 |
| 37 namespace content { | 36 namespace content { |
| 38 | 37 |
| 39 namespace { | 38 namespace { |
| 40 | 39 |
| 41 // Converts |time| from a remote to local TimeTicks, overwriting the original | 40 // Converts |time| from a remote to local TimeTicks, overwriting the original |
| 42 // value. | 41 // value. |
| 43 void RemoteToLocalTimeTicks( | 42 void RemoteToLocalTimeTicks( |
| 44 const InterProcessTimeTicksConverter& converter, | 43 const InterProcessTimeTicksConverter& converter, |
| 45 base::TimeTicks* time) { | 44 base::TimeTicks* time) { |
| 46 RemoteTimeTicks remote_time = RemoteTimeTicks::FromTimeTicks(*time); | 45 RemoteTimeTicks remote_time = RemoteTimeTicks::FromTimeTicks(*time); |
| 47 *time = converter.ToLocalTimeTicks(remote_time).ToTimeTicks(); | 46 *time = converter.ToLocalTimeTicks(remote_time).ToTimeTicks(); |
| 48 } | 47 } |
| 49 | 48 |
| 50 | 49 void CrashOnMapFailure() { |
| 51 } // namespace | |
| 52 | |
| 53 static void CrashOnMapFailure() { | |
| 54 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
| 55 DWORD last_err = GetLastError(); | 51 DWORD last_err = GetLastError(); |
| 56 base::debug::Alias(&last_err); | 52 base::debug::Alias(&last_err); |
| 57 #endif | 53 #endif |
| 58 CHECK(false); | 54 CHECK(false); |
| 59 } | 55 } |
| 60 | 56 |
| 61 // Each resource request is assigned an ID scoped to this process. | 57 // Each resource request is assigned an ID scoped to this process. |
| 62 static int MakeRequestID() { | 58 int MakeRequestID() { |
| 63 // NOTE: The resource_dispatcher_host also needs probably unique | 59 // NOTE: The resource_dispatcher_host also needs probably unique |
| 64 // request_ids, so they count down from -2 (-1 is a special we're | 60 // request_ids, so they count down from -2 (-1 is a special we're |
| 65 // screwed value), while the renderer process counts up. | 61 // screwed value), while the renderer process counts up. |
| 66 static int next_request_id = 0; | 62 static int next_request_id = 0; |
| 67 return next_request_id++; | 63 return next_request_id++; |
| 68 } | 64 } |
| 69 | 65 |
| 70 // ResourceLoaderBridge implementation ---------------------------------------- | 66 } // namespace |
| 71 | |
| 72 class IPCResourceLoaderBridge : public ResourceLoaderBridge { | |
| 73 public: | |
| 74 IPCResourceLoaderBridge(ResourceDispatcher* dispatcher, | |
| 75 const RequestInfo& request_info); | |
| 76 virtual ~IPCResourceLoaderBridge(); | |
| 77 | |
| 78 // ResourceLoaderBridge | |
| 79 virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE; | |
| 80 virtual bool Start(RequestPeer* peer) OVERRIDE; | |
| 81 virtual void Cancel() OVERRIDE; | |
| 82 virtual void SetDefersLoading(bool value) OVERRIDE; | |
| 83 virtual void DidChangePriority(net::RequestPriority new_priority, | |
| 84 int intra_priority_value) OVERRIDE; | |
| 85 virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE; | |
| 86 | |
| 87 private: | |
| 88 RequestPeer* peer_; | |
| 89 | |
| 90 // The resource dispatcher for this loader. The bridge doesn't own it, but | |
| 91 // it's guaranteed to outlive the bridge. | |
| 92 ResourceDispatcher* dispatcher_; | |
| 93 | |
| 94 // The request to send, created on initialization for modification and | |
| 95 // appending data. | |
| 96 ResourceHostMsg_Request request_; | |
| 97 | |
| 98 // ID for the request, valid once Start()ed, -1 if not valid yet. | |
| 99 int request_id_; | |
| 100 | |
| 101 // The routing id used when sending IPC messages. | |
| 102 int routing_id_; | |
| 103 | |
| 104 // The security origin of the frame that initiates this request. | |
| 105 GURL frame_origin_; | |
| 106 | |
| 107 bool is_synchronous_request_; | |
| 108 }; | |
| 109 | |
| 110 IPCResourceLoaderBridge::IPCResourceLoaderBridge( | |
| 111 ResourceDispatcher* dispatcher, | |
| 112 const RequestInfo& request_info) | |
| 113 : peer_(NULL), | |
| 114 dispatcher_(dispatcher), | |
| 115 request_id_(-1), | |
| 116 routing_id_(request_info.routing_id), | |
| 117 is_synchronous_request_(false) { | |
| 118 DCHECK(dispatcher_) << "no resource dispatcher"; | |
| 119 request_.method = request_info.method; | |
| 120 request_.url = request_info.url; | |
| 121 request_.first_party_for_cookies = request_info.first_party_for_cookies; | |
| 122 request_.referrer = request_info.referrer; | |
| 123 request_.referrer_policy = request_info.referrer_policy; | |
| 124 request_.headers = request_info.headers; | |
| 125 request_.load_flags = request_info.load_flags; | |
| 126 request_.origin_pid = request_info.requestor_pid; | |
| 127 request_.resource_type = request_info.request_type; | |
| 128 request_.priority = request_info.priority; | |
| 129 request_.request_context = request_info.request_context; | |
| 130 request_.appcache_host_id = request_info.appcache_host_id; | |
| 131 request_.download_to_file = request_info.download_to_file; | |
| 132 request_.has_user_gesture = request_info.has_user_gesture; | |
| 133 | |
| 134 const RequestExtraData kEmptyData; | |
| 135 const RequestExtraData* extra_data; | |
| 136 if (request_info.extra_data) | |
| 137 extra_data = static_cast<RequestExtraData*>(request_info.extra_data); | |
| 138 else | |
| 139 extra_data = &kEmptyData; | |
| 140 request_.visiblity_state = extra_data->visibility_state(); | |
| 141 request_.render_frame_id = extra_data->render_frame_id(); | |
| 142 request_.is_main_frame = extra_data->is_main_frame(); | |
| 143 request_.parent_is_main_frame = extra_data->parent_is_main_frame(); | |
| 144 request_.parent_render_frame_id = extra_data->parent_render_frame_id(); | |
| 145 request_.allow_download = extra_data->allow_download(); | |
| 146 request_.transition_type = extra_data->transition_type(); | |
| 147 request_.should_replace_current_entry = | |
| 148 extra_data->should_replace_current_entry(); | |
| 149 request_.transferred_request_child_id = | |
| 150 extra_data->transferred_request_child_id(); | |
| 151 request_.transferred_request_request_id = | |
| 152 extra_data->transferred_request_request_id(); | |
| 153 request_.service_worker_provider_id = | |
| 154 extra_data->service_worker_provider_id(); | |
| 155 frame_origin_ = extra_data->frame_origin(); | |
| 156 } | |
| 157 | |
| 158 IPCResourceLoaderBridge::~IPCResourceLoaderBridge() { | |
| 159 // we remove our hook for the resource dispatcher only when going away, since | |
| 160 // it doesn't keep track of whether we've force terminated the request | |
| 161 if (request_id_ >= 0) { | |
| 162 // this operation may fail, as the dispatcher will have preemptively | |
| 163 // removed us when the renderer sends the ReceivedAllData message. | |
| 164 dispatcher_->RemovePendingRequest(request_id_); | |
| 165 | |
| 166 if (request_.download_to_file) { | |
| 167 dispatcher_->message_sender()->Send( | |
| 168 new ResourceHostMsg_ReleaseDownloadedFile(request_id_)); | |
| 169 } | |
| 170 } | |
| 171 } | |
| 172 | |
| 173 void IPCResourceLoaderBridge::SetRequestBody( | |
| 174 ResourceRequestBody* request_body) { | |
| 175 DCHECK(request_id_ == -1) << "request already started"; | |
| 176 request_.request_body = request_body; | |
| 177 } | |
| 178 | |
| 179 // Writes a footer on the message and sends it | |
| 180 bool IPCResourceLoaderBridge::Start(RequestPeer* peer) { | |
| 181 if (request_id_ != -1) { | |
| 182 NOTREACHED() << "Starting a request twice"; | |
| 183 return false; | |
| 184 } | |
| 185 | |
| 186 peer_ = peer; | |
| 187 | |
| 188 // generate the request ID, and append it to the message | |
| 189 request_id_ = dispatcher_->AddPendingRequest(peer_, | |
| 190 request_.resource_type, | |
| 191 request_.origin_pid, | |
| 192 frame_origin_, | |
| 193 request_.url); | |
| 194 | |
| 195 return dispatcher_->message_sender()->Send( | |
| 196 new ResourceHostMsg_RequestResource(routing_id_, request_id_, request_)); | |
| 197 } | |
| 198 | |
| 199 void IPCResourceLoaderBridge::Cancel() { | |
| 200 if (request_id_ < 0) { | |
| 201 NOTREACHED() << "Trying to cancel an unstarted request"; | |
| 202 return; | |
| 203 } | |
| 204 | |
| 205 if (!is_synchronous_request_) | |
| 206 dispatcher_->CancelPendingRequest(request_id_); | |
| 207 | |
| 208 // We can't remove the request ID from the resource dispatcher because more | |
| 209 // data might be pending. Sending the cancel message may cause more data | |
| 210 // to be flushed, and will then cause a complete message to be sent. | |
| 211 } | |
| 212 | |
| 213 void IPCResourceLoaderBridge::SetDefersLoading(bool value) { | |
| 214 if (request_id_ < 0) { | |
| 215 NOTREACHED() << "Trying to (un)defer an unstarted request"; | |
| 216 return; | |
| 217 } | |
| 218 | |
| 219 dispatcher_->SetDefersLoading(request_id_, value); | |
| 220 } | |
| 221 | |
| 222 void IPCResourceLoaderBridge::DidChangePriority( | |
| 223 net::RequestPriority new_priority, int intra_priority_value) { | |
| 224 if (request_id_ < 0) { | |
| 225 NOTREACHED() << "Trying to change priority of an unstarted request"; | |
| 226 return; | |
| 227 } | |
| 228 | |
| 229 dispatcher_->DidChangePriority(routing_id_, request_id_, new_priority, | |
| 230 intra_priority_value); | |
| 231 } | |
| 232 | |
| 233 void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) { | |
| 234 if (request_id_ != -1) { | |
| 235 NOTREACHED() << "Starting a request twice"; | |
| 236 response->error_code = net::ERR_FAILED; | |
| 237 return; | |
| 238 } | |
| 239 | |
| 240 request_id_ = MakeRequestID(); | |
| 241 is_synchronous_request_ = true; | |
| 242 | |
| 243 SyncLoadResult result; | |
| 244 IPC::SyncMessage* msg = new ResourceHostMsg_SyncLoad(routing_id_, request_id_, | |
| 245 request_, &result); | |
| 246 // NOTE: This may pump events (see RenderThread::Send). | |
| 247 if (!dispatcher_->message_sender()->Send(msg)) { | |
| 248 response->error_code = net::ERR_FAILED; | |
| 249 return; | |
| 250 } | |
| 251 | |
| 252 response->error_code = result.error_code; | |
| 253 response->url = result.final_url; | |
| 254 response->headers = result.headers; | |
| 255 response->mime_type = result.mime_type; | |
| 256 response->charset = result.charset; | |
| 257 response->request_time = result.request_time; | |
| 258 response->response_time = result.response_time; | |
| 259 response->encoded_data_length = result.encoded_data_length; | |
| 260 response->load_timing = result.load_timing; | |
| 261 response->devtools_info = result.devtools_info; | |
| 262 response->data.swap(result.data); | |
| 263 response->download_file_path = result.download_file_path; | |
| 264 } | |
| 265 | |
| 266 // ResourceDispatcher --------------------------------------------------------- | |
| 267 | 67 |
| 268 ResourceDispatcher::ResourceDispatcher(IPC::Sender* sender) | 68 ResourceDispatcher::ResourceDispatcher(IPC::Sender* sender) |
| 269 : message_sender_(sender), | 69 : message_sender_(sender), |
| 70 request_id_(-1), | |
| 71 is_synchronous_request_(false), | |
| 270 weak_factory_(this), | 72 weak_factory_(this), |
| 271 delegate_(NULL), | 73 delegate_(NULL), |
| 272 io_timestamp_(base::TimeTicks()) { | 74 io_timestamp_(base::TimeTicks()) { |
| 273 } | 75 } |
| 274 | 76 |
| 275 ResourceDispatcher::~ResourceDispatcher() { | 77 ResourceDispatcher::~ResourceDispatcher() { |
| 78 // We remove our hook for the resource dispatcher only when going away, since | |
| 79 // it doesn't keep track of whether we've force terminated the request | |
| 80 if (request_id_ >= 0) { | |
| 81 // This operation may fail, as the dispatcher will have preemptively | |
| 82 // removed us when the renderer sends the ReceivedAllData message. | |
| 83 RemovePendingRequest(request_id_); | |
| 84 | |
| 85 if (request_->download_to_file) { | |
| 86 message_sender_->Send( | |
| 87 new ResourceHostMsg_ReleaseDownloadedFile(request_id_)); | |
| 88 } | |
| 89 } | |
|
jam
2014/04/16 16:24:04
ditto: remove this section
tfarina
2014/04/16 22:33:13
Done.
tfarina
2014/04/16 22:33:13
Done.
| |
| 276 } | 90 } |
| 277 | 91 |
| 278 // ResourceDispatcher implementation ------------------------------------------ | |
| 279 | |
| 280 bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) { | 92 bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) { |
| 281 if (!IsResourceDispatcherMessage(message)) { | 93 if (!IsResourceDispatcherMessage(message)) { |
| 282 return false; | 94 return false; |
| 283 } | 95 } |
| 284 | 96 |
| 285 int request_id; | 97 int request_id; |
| 286 | 98 |
| 287 PickleIterator iter(message); | 99 PickleIterator iter(message); |
| 288 if (!message.ReadInt(&iter, &request_id)) { | 100 if (!message.ReadInt(&iter, &request_id)) { |
| 289 NOTREACHED() << "malformed resource message"; | 101 NOTREACHED() << "malformed resource message"; |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 608 FollowPendingRedirect(request_id, request_info); | 420 FollowPendingRedirect(request_id, request_info); |
| 609 | 421 |
| 610 base::MessageLoop::current()->PostTask( | 422 base::MessageLoop::current()->PostTask( |
| 611 FROM_HERE, | 423 FROM_HERE, |
| 612 base::Bind(&ResourceDispatcher::FlushDeferredMessages, | 424 base::Bind(&ResourceDispatcher::FlushDeferredMessages, |
| 613 weak_factory_.GetWeakPtr(), | 425 weak_factory_.GetWeakPtr(), |
| 614 request_id)); | 426 request_id)); |
| 615 } | 427 } |
| 616 } | 428 } |
| 617 | 429 |
| 618 void ResourceDispatcher::DidChangePriority( | 430 void ResourceDispatcher::DidChangePriority(int routing_id, |
| 619 int routing_id, int request_id, net::RequestPriority new_priority, | 431 int request_id, |
| 620 int intra_priority_value) { | 432 net::RequestPriority new_priority, |
| 433 int intra_priority_value) { | |
| 621 DCHECK(ContainsKey(pending_requests_, request_id)); | 434 DCHECK(ContainsKey(pending_requests_, request_id)); |
| 622 message_sender()->Send(new ResourceHostMsg_DidChangePriority( | 435 message_sender()->Send(new ResourceHostMsg_DidChangePriority( |
| 623 request_id, new_priority, intra_priority_value)); | 436 request_id, new_priority, intra_priority_value)); |
| 624 } | 437 } |
| 625 | 438 |
| 626 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo() | 439 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo() |
| 627 : peer(NULL), | 440 : peer(NULL), |
| 628 resource_type(ResourceType::SUB_RESOURCE), | 441 resource_type(ResourceType::SUB_RESOURCE), |
| 629 is_deferred(false), | 442 is_deferred(false), |
| 630 blocked_response(false), | 443 blocked_response(false), |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 687 if (index != pending_requests_.end()) { | 500 if (index != pending_requests_.end()) { |
| 688 PendingRequestInfo& pending_request = index->second; | 501 PendingRequestInfo& pending_request = index->second; |
| 689 if (pending_request.is_deferred) { | 502 if (pending_request.is_deferred) { |
| 690 pending_request.deferred_message_queue.swap(q); | 503 pending_request.deferred_message_queue.swap(q); |
| 691 return; | 504 return; |
| 692 } | 505 } |
| 693 } | 506 } |
| 694 } | 507 } |
| 695 } | 508 } |
| 696 | 509 |
| 697 ResourceLoaderBridge* ResourceDispatcher::CreateBridge( | 510 void ResourceDispatcher::StartSync(const RequestInfo& request_info, |
| 698 const RequestInfo& request_info) { | 511 ResourceRequestBody* request_body, |
| 699 return new IPCResourceLoaderBridge(this, request_info); | 512 SyncLoadResponse* response) { |
| 513 if (request_id_ != -1) { | |
|
jam
2014/04/16 16:24:04
ditto: there should be no per-request state in RD
tfarina
2014/04/16 22:33:13
Done.
tfarina
2014/04/16 22:33:13
Done.
| |
| 514 NOTREACHED() << "Starting a request twice"; | |
| 515 response->error_code = net::ERR_FAILED; | |
| 516 return; | |
| 517 } | |
| 518 | |
| 519 CreateRequest(request_info, request_body); | |
| 520 | |
| 521 request_id_ = MakeRequestID(); | |
| 522 is_synchronous_request_ = true; | |
| 523 | |
| 524 SyncLoadResult result; | |
| 525 IPC::SyncMessage* msg = new ResourceHostMsg_SyncLoad( | |
| 526 request_info.routing_id, request_id_, *request_.get(), &result); | |
| 527 | |
| 528 // NOTE: This may pump events (see RenderThread::Send). | |
| 529 if (!message_sender_->Send(msg)) { | |
| 530 response->error_code = net::ERR_FAILED; | |
| 531 return; | |
| 532 } | |
| 533 | |
| 534 response->error_code = result.error_code; | |
| 535 response->url = result.final_url; | |
| 536 response->headers = result.headers; | |
| 537 response->mime_type = result.mime_type; | |
| 538 response->charset = result.charset; | |
| 539 response->request_time = result.request_time; | |
| 540 response->response_time = result.response_time; | |
| 541 response->encoded_data_length = result.encoded_data_length; | |
| 542 response->load_timing = result.load_timing; | |
| 543 response->devtools_info = result.devtools_info; | |
| 544 response->data.swap(result.data); | |
| 545 response->download_file_path = result.download_file_path; | |
| 546 } | |
| 547 | |
| 548 int ResourceDispatcher::StartAsync(const RequestInfo& request_info, | |
| 549 ResourceRequestBody* request_body, | |
| 550 RequestPeer* peer) { | |
| 551 if (request_id_ != -1) { | |
|
jam
2014/04/16 16:24:04
ditto
tfarina
2014/04/16 22:33:13
Done.
| |
| 552 NOTREACHED() << "Starting a request twice"; | |
| 553 return false; | |
| 554 } | |
| 555 | |
| 556 CreateRequest(request_info, request_body); | |
| 557 | |
| 558 // generate the request ID, and append it to the message | |
| 559 request_id_ = AddPendingRequest(peer, | |
|
jam
2014/04/16 16:24:04
ditto
tfarina
2014/04/16 22:33:13
Done.
tfarina
2014/04/16 22:33:13
Done.
| |
| 560 request_->resource_type, | |
| 561 request_->origin_pid, | |
| 562 frame_origin_, | |
| 563 request_->url); | |
| 564 | |
| 565 message_sender_->Send(new ResourceHostMsg_RequestResource( | |
| 566 request_info.routing_id, request_id_, *request_.get())); | |
| 567 | |
| 568 return request_id_; | |
| 569 } | |
| 570 | |
| 571 void ResourceDispatcher::Cancel(int request_id) { | |
|
jam
2014/04/16 16:24:04
actually no need to have Cancel method, since Canc
tfarina
2014/04/16 22:33:13
Done.
| |
| 572 if (!is_synchronous_request_) | |
| 573 CancelPendingRequest(request_id); | |
| 574 | |
| 575 // We can't remove the request ID from the resource dispatcher because more | |
| 576 // data might be pending. Sending the cancel message may cause more data | |
| 577 // to be flushed, and will then cause a complete message to be sent. | |
| 700 } | 578 } |
| 701 | 579 |
| 702 void ResourceDispatcher::ToResourceResponseInfo( | 580 void ResourceDispatcher::ToResourceResponseInfo( |
| 703 const PendingRequestInfo& request_info, | 581 const PendingRequestInfo& request_info, |
| 704 const ResourceResponseHead& browser_info, | 582 const ResourceResponseHead& browser_info, |
| 705 ResourceResponseInfo* renderer_info) const { | 583 ResourceResponseInfo* renderer_info) const { |
| 706 *renderer_info = browser_info; | 584 *renderer_info = browser_info; |
| 707 if (request_info.request_start.is_null() || | 585 if (request_info.request_start.is_null() || |
| 708 request_info.response_start.is_null() || | 586 request_info.response_start.is_null() || |
| 709 browser_info.request_start.is_null() || | 587 browser_info.request_start.is_null() || |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 804 // static | 682 // static |
| 805 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { | 683 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { |
| 806 while (!queue->empty()) { | 684 while (!queue->empty()) { |
| 807 IPC::Message* message = queue->front(); | 685 IPC::Message* message = queue->front(); |
| 808 ReleaseResourcesInDataMessage(*message); | 686 ReleaseResourcesInDataMessage(*message); |
| 809 queue->pop_front(); | 687 queue->pop_front(); |
| 810 delete message; | 688 delete message; |
| 811 } | 689 } |
| 812 } | 690 } |
| 813 | 691 |
| 692 void ResourceDispatcher::CreateRequest(const RequestInfo& request_info, | |
| 693 ResourceRequestBody* request_body) { | |
| 694 request_.reset(new ResourceHostMsg_Request); | |
| 695 request_->method = request_info.method; | |
| 696 request_->url = request_info.url; | |
| 697 request_->first_party_for_cookies = request_info.first_party_for_cookies; | |
| 698 request_->referrer = request_info.referrer; | |
| 699 request_->referrer_policy = request_info.referrer_policy; | |
| 700 request_->headers = request_info.headers; | |
| 701 request_->load_flags = request_info.load_flags; | |
| 702 request_->origin_pid = request_info.requestor_pid; | |
| 703 request_->resource_type = request_info.request_type; | |
| 704 request_->priority = request_info.priority; | |
| 705 request_->request_context = request_info.request_context; | |
| 706 request_->appcache_host_id = request_info.appcache_host_id; | |
| 707 request_->download_to_file = request_info.download_to_file; | |
| 708 request_->has_user_gesture = request_info.has_user_gesture; | |
| 709 | |
| 710 const RequestExtraData kEmptyData; | |
| 711 const RequestExtraData* extra_data; | |
| 712 if (request_info.extra_data) | |
| 713 extra_data = static_cast<RequestExtraData*>(request_info.extra_data); | |
| 714 else | |
| 715 extra_data = &kEmptyData; | |
| 716 request_->visiblity_state = extra_data->visibility_state(); | |
| 717 request_->render_frame_id = extra_data->render_frame_id(); | |
| 718 request_->is_main_frame = extra_data->is_main_frame(); | |
| 719 request_->parent_is_main_frame = extra_data->parent_is_main_frame(); | |
| 720 request_->parent_render_frame_id = extra_data->parent_render_frame_id(); | |
| 721 request_->allow_download = extra_data->allow_download(); | |
| 722 request_->transition_type = extra_data->transition_type(); | |
| 723 request_->should_replace_current_entry = | |
| 724 extra_data->should_replace_current_entry(); | |
| 725 request_->transferred_request_child_id = | |
| 726 extra_data->transferred_request_child_id(); | |
| 727 request_->transferred_request_request_id = | |
| 728 extra_data->transferred_request_request_id(); | |
| 729 request_->service_worker_provider_id = | |
| 730 extra_data->service_worker_provider_id(); | |
| 731 request_->request_body = request_body; | |
| 732 frame_origin_ = extra_data->frame_origin(); | |
| 733 } | |
| 734 | |
| 814 } // namespace content | 735 } // namespace content |
| OLD | NEW |