| 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 <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/debug/alias.h" | 13 #include "base/debug/alias.h" |
| 14 #include "base/debug/dump_without_crashing.h" | 14 #include "base/debug/dump_without_crashing.h" |
| 15 #include "base/debug/stack_trace.h" | 15 #include "base/debug/stack_trace.h" |
| 16 #include "base/feature_list.h" | 16 #include "base/feature_list.h" |
| 17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 18 #include "base/memory/shared_memory.h" | 18 #include "base/memory/shared_memory.h" |
| 19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
| 20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 21 #include "base/rand_util.h" | 21 #include "base/rand_util.h" |
| 22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 24 #include "content/child/mojo_pipe_received_data.h" |
| 24 #include "content/child/request_extra_data.h" | 25 #include "content/child/request_extra_data.h" |
| 25 #include "content/child/request_info.h" | 26 #include "content/child/request_info.h" |
| 26 #include "content/child/resource_scheduling_filter.h" | 27 #include "content/child/resource_scheduling_filter.h" |
| 27 #include "content/child/shared_memory_received_data_factory.h" | 28 #include "content/child/shared_memory_received_data_factory.h" |
| 28 #include "content/child/site_isolation_stats_gatherer.h" | 29 #include "content/child/site_isolation_stats_gatherer.h" |
| 29 #include "content/child/sync_load_response.h" | 30 #include "content/child/sync_load_response.h" |
| 30 #include "content/common/inter_process_time_ticks_converter.h" | 31 #include "content/common/inter_process_time_ticks_converter.h" |
| 31 #include "content/common/navigation_params.h" | 32 #include "content/common/navigation_params.h" |
| 32 #include "content/common/resource_messages.h" | 33 #include "content/common/resource_messages.h" |
| 33 #include "content/public/child/fixed_received_data.h" | 34 #include "content/public/child/fixed_received_data.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 185 } |
| 185 | 186 |
| 186 void ResourceDispatcher::OnSetDataBuffer(int request_id, | 187 void ResourceDispatcher::OnSetDataBuffer(int request_id, |
| 187 base::SharedMemoryHandle shm_handle, | 188 base::SharedMemoryHandle shm_handle, |
| 188 int shm_size, | 189 int shm_size, |
| 189 base::ProcessId renderer_pid) { | 190 base::ProcessId renderer_pid) { |
| 190 TRACE_EVENT0("loader", "ResourceDispatcher::OnSetDataBuffer"); | 191 TRACE_EVENT0("loader", "ResourceDispatcher::OnSetDataBuffer"); |
| 191 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 192 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 192 if (!request_info) | 193 if (!request_info) |
| 193 return; | 194 return; |
| 195 DCHECK(!request_info->mojo_data_pipe_handle.is_valid()); |
| 194 | 196 |
| 195 bool shm_valid = base::SharedMemory::IsHandleValid(shm_handle); | 197 bool shm_valid = base::SharedMemory::IsHandleValid(shm_handle); |
| 196 CHECK((shm_valid && shm_size > 0) || (!shm_valid && !shm_size)); | 198 CHECK((shm_valid && shm_size > 0) || (!shm_valid && !shm_size)); |
| 197 | 199 |
| 198 request_info->buffer.reset( | 200 request_info->buffer.reset( |
| 199 new base::SharedMemory(shm_handle, true)); // read only | 201 new base::SharedMemory(shm_handle, true)); // read only |
| 200 request_info->received_data_factory = | 202 request_info->received_data_factory = |
| 201 make_scoped_refptr(new SharedMemoryReceivedDataFactory( | 203 make_scoped_refptr(new SharedMemoryReceivedDataFactory( |
| 202 message_sender_, request_id, request_info->buffer)); | 204 message_sender_, request_id, request_info->buffer)); |
| 203 | 205 |
| 204 bool ok = request_info->buffer->Map(shm_size); | 206 bool ok = request_info->buffer->Map(shm_size); |
| 205 if (!ok) { | 207 if (!ok) { |
| 206 // Added to help debug crbug/160401. | 208 // Added to help debug crbug/160401. |
| 207 base::ProcessId renderer_pid_copy = renderer_pid; | 209 base::ProcessId renderer_pid_copy = renderer_pid; |
| 208 base::debug::Alias(&renderer_pid_copy); | 210 base::debug::Alias(&renderer_pid_copy); |
| 209 | 211 |
| 210 base::SharedMemoryHandle shm_handle_copy = shm_handle; | 212 base::SharedMemoryHandle shm_handle_copy = shm_handle; |
| 211 base::debug::Alias(&shm_handle_copy); | 213 base::debug::Alias(&shm_handle_copy); |
| 212 | 214 |
| 213 CrashOnMapFailure(); | 215 CrashOnMapFailure(); |
| 214 return; | 216 return; |
| 215 } | 217 } |
| 216 | 218 |
| 217 // TODO(erikchen): Temporary debugging. http://crbug.com/527588. | 219 // TODO(erikchen): Temporary debugging. http://crbug.com/527588. |
| 218 CHECK_GE(shm_size, 0); | 220 CHECK_GE(shm_size, 0); |
| 219 CHECK_LE(shm_size, 512 * 1024); | 221 CHECK_LE(shm_size, 512 * 1024); |
| 220 request_info->buffer_size = shm_size; | 222 request_info->buffer_size = shm_size; |
| 221 } | 223 } |
| 222 | 224 |
| 225 void ResourceDispatcher::WaitForMojoData(int request_id, |
| 226 PendingRequestInfo* request_info) { |
| 227 DCHECK(!request_info->mojo_watcher.IsWatching()); |
| 228 DCHECK(request_info->mojo_data_pipe_handle.is_valid()); |
| 229 LOG(ERROR) << ">>> ResourceDispatcher::WaitForMojoData: request_id = " |
| 230 << request_id; |
| 231 MojoResult rv = request_info->mojo_watcher.Start( |
| 232 request_info->mojo_data_pipe_handle.get(), MOJO_HANDLE_SIGNAL_READABLE, |
| 233 base::Bind(&ResourceDispatcher::ReceivedMojoData, |
| 234 weak_factory_.GetWeakPtr(), request_id)); |
| 235 CHECK_EQ(rv, MOJO_RESULT_OK); |
| 236 } |
| 237 |
| 238 void ResourceDispatcher::ReceivedMojoData(int request_id, MojoResult) { |
| 239 // Note: it seems like we can ignore the MojoResult parameter here and simply |
| 240 // rely on the one returned by mojo::BeginReadDataRaw. |
| 241 LOG(ERROR) << ">>> ResourceDispatcher::ReceivedMojoData: request_id = " |
| 242 << request_id; |
| 243 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedData"); |
| 244 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 245 if (!request_info) |
| 246 return; |
| 247 CHECK(request_info->mojo_data_pipe_handle.is_valid()); |
| 248 |
| 249 // TODO(carlosk): see if we need to create an equivalent UMA metric as |
| 250 // ResourceDispatcher.OnReceivedDataTime for the handling of Mojo data; |
| 251 |
| 252 // Read all available data bundles received. |
| 253 MojoResult rv = MOJO_RESULT_OK; |
| 254 while (rv == MOJO_RESULT_OK) { |
| 255 const void* buffer = nullptr; |
| 256 uint32_t num_bytes = 0; |
| 257 rv = mojo::BeginReadDataRaw(request_info->mojo_data_pipe_handle.get(), |
| 258 &buffer, &num_bytes, MOJO_READ_DATA_FLAG_NONE); |
| 259 if (rv == MOJO_RESULT_OK) { |
| 260 // There's data to read from the pipe. |
| 261 AcceptMojoMessage(request_info, buffer, num_bytes); |
| 262 } |
| 263 } |
| 264 |
| 265 if (rv == MOJO_RESULT_SHOULD_WAIT) { |
| 266 // No more data to be read from the pipe for now. |
| 267 // Apparently there's no need to re-register the watcher... |
| 268 // WaitForMojoData(request_id, request_info); |
| 269 } else if (rv == MOJO_RESULT_FAILED_PRECONDITION) { |
| 270 // Regular EOF from the pipe; maybe errors too? |
| 271 // TODO(carlosk): given the extra data sent along with |
| 272 // ResourceMsg_RequestComplete we would need an IPC for that. But are |
| 273 // there any ordering guarantees between piped data and IPCs? If not we'd |
| 274 // have to create a barrier between EOF and that IPC or receive this data |
| 275 // through the pipe. |
| 276 request_info->mojo_watcher.Cancel(); |
| 277 request_info->mojo_data_pipe_handle.reset(); |
| 278 // Note: this is dummy data; it should all come from the browser. |
| 279 ResourceMsg_RequestCompleteData request_complete_data; |
| 280 request_complete_data.error_code = net::OK; |
| 281 request_complete_data.was_ignored_by_handler = false; |
| 282 request_complete_data.exists_in_cache = false; |
| 283 request_complete_data.completion_time = base::TimeTicks::Now(); |
| 284 request_complete_data.encoded_data_length = request_info->mojo_total_bytes; |
| 285 LOG(ERROR) << ">>> Will call ResourceDispatcher::OnRequestComplete for " |
| 286 "Mojo: request_id = " |
| 287 << request_id; |
| 288 OnRequestComplete(request_id, request_complete_data); |
| 289 } else { |
| 290 // Something else that I still have to figure out... |
| 291 CHECK(false) << "Unhandled MojoResult: " << rv; |
| 292 } |
| 293 } |
| 294 |
| 295 void ResourceDispatcher::AcceptMojoMessage(PendingRequestInfo* request_info, |
| 296 const void* buffer, |
| 297 uint32_t num_bytes) { |
| 298 LOG(ERROR) << ">>> ResourceDispatcher::AcceptMojoMessage: num_bytes = " |
| 299 << num_bytes; |
| 300 DCHECK(num_bytes > 0); |
| 301 // Check whether this response data is compliant with our cross-site |
| 302 // document blocking policy. We only do this for the first chunk of data. |
| 303 if (request_info->site_isolation_metadata.get()) { |
| 304 SiteIsolationStatsGatherer::OnReceivedFirstChunk( |
| 305 request_info->site_isolation_metadata, static_cast<const char*>(buffer), |
| 306 num_bytes); |
| 307 request_info->site_isolation_metadata.reset(); |
| 308 } |
| 309 |
| 310 request_info->mojo_total_bytes += num_bytes; |
| 311 scoped_ptr<RequestPeer::ReceivedData> mojo_data = |
| 312 MojoPipeReceivedData::Create(request_info->mojo_data_pipe_handle.get(), |
| 313 buffer, num_bytes); |
| 314 |
| 315 request_info->peer->OnReceivedData(std::move(mojo_data)); |
| 316 } |
| 317 |
| 223 void ResourceDispatcher::OnReceivedInlinedDataChunk( | 318 void ResourceDispatcher::OnReceivedInlinedDataChunk( |
| 224 int request_id, | 319 int request_id, |
| 225 const std::vector<char>& data, | 320 const std::vector<char>& data, |
| 226 int encoded_data_length) { | 321 int encoded_data_length) { |
| 227 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedInlinedDataChunk"); | 322 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedInlinedDataChunk"); |
| 228 DCHECK(!data.empty()); | 323 DCHECK(!data.empty()); |
| 229 DCHECK(base::FeatureList::IsEnabled(features::kOptimizeIPCForSmallResource)); | 324 DCHECK(base::FeatureList::IsEnabled(features::kOptimizeIPCForSmallResource)); |
| 230 | 325 |
| 231 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 326 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 232 if (!request_info || data.empty()) | 327 if (!request_info || data.empty()) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 249 | 344 |
| 250 void ResourceDispatcher::OnReceivedData(int request_id, | 345 void ResourceDispatcher::OnReceivedData(int request_id, |
| 251 int data_offset, | 346 int data_offset, |
| 252 int data_length, | 347 int data_length, |
| 253 int encoded_data_length) { | 348 int encoded_data_length) { |
| 254 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedData"); | 349 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedData"); |
| 255 DCHECK_GT(data_length, 0); | 350 DCHECK_GT(data_length, 0); |
| 256 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 351 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 257 bool send_ack = true; | 352 bool send_ack = true; |
| 258 if (request_info && data_length > 0) { | 353 if (request_info && data_length > 0) { |
| 354 DCHECK(!request_info->mojo_data_pipe_handle.is_valid()); |
| 259 CHECK(base::SharedMemory::IsHandleValid(request_info->buffer->handle())); | 355 CHECK(base::SharedMemory::IsHandleValid(request_info->buffer->handle())); |
| 260 CHECK_GE(request_info->buffer_size, data_offset + data_length); | 356 CHECK_GE(request_info->buffer_size, data_offset + data_length); |
| 261 | 357 |
| 262 base::TimeTicks time_start = base::TimeTicks::Now(); | 358 base::TimeTicks time_start = base::TimeTicks::Now(); |
| 263 | 359 |
| 264 const char* data_start = static_cast<char*>(request_info->buffer->memory()); | 360 const char* data_start = static_cast<char*>(request_info->buffer->memory()); |
| 265 CHECK(data_start); | 361 CHECK(data_start); |
| 266 CHECK(data_start + data_offset); | 362 CHECK(data_start + data_offset); |
| 267 const char* data_ptr = data_start + data_offset; | 363 const char* data_ptr = data_start + data_offset; |
| 268 | 364 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 // (crbug.com/547047) | 475 // (crbug.com/547047) |
| 380 peer->OnCompletedRequest(request_complete_data.error_code, | 476 peer->OnCompletedRequest(request_complete_data.error_code, |
| 381 request_complete_data.was_ignored_by_handler, | 477 request_complete_data.was_ignored_by_handler, |
| 382 request_complete_data.exists_in_cache, | 478 request_complete_data.exists_in_cache, |
| 383 request_complete_data.security_info, | 479 request_complete_data.security_info, |
| 384 renderer_completion_time, | 480 renderer_completion_time, |
| 385 request_complete_data.encoded_data_length); | 481 request_complete_data.encoded_data_length); |
| 386 } | 482 } |
| 387 | 483 |
| 388 bool ResourceDispatcher::RemovePendingRequest(int request_id) { | 484 bool ResourceDispatcher::RemovePendingRequest(int request_id) { |
| 485 if (request_id < -1) |
| 486 LOG(ERROR) << "ResourceDispatcher::RemovePendingRequest request_id: " |
| 487 << request_id; |
| 389 PendingRequestMap::iterator it = pending_requests_.find(request_id); | 488 PendingRequestMap::iterator it = pending_requests_.find(request_id); |
| 390 if (it == pending_requests_.end()) | 489 if (it == pending_requests_.end()) |
| 391 return false; | 490 return false; |
| 491 if (request_id < -1) |
| 492 LOG(ERROR) << "ResourceDispatcher::RemovePendingRequest request deleted"; |
| 392 | 493 |
| 393 PendingRequestInfo* request_info = it->second.get(); | 494 PendingRequestInfo* request_info = it->second.get(); |
| 394 | 495 |
| 395 bool release_downloaded_file = request_info->download_to_file; | 496 bool release_downloaded_file = request_info->download_to_file; |
| 396 | 497 |
| 397 ReleaseResourcesInMessageQueue(&request_info->deferred_message_queue); | 498 ReleaseResourcesInMessageQueue(&request_info->deferred_message_queue); |
| 398 | 499 |
| 399 // Always delete the pending_request asyncly so that cancelling the request | 500 // Always delete the pending_request asyncly so that cancelling the request |
| 400 // doesn't delete the request context info while its response is still being | 501 // doesn't delete the request context info while its response is still being |
| 401 // handled. | 502 // handled. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 const GURL& frame_origin, | 585 const GURL& frame_origin, |
| 485 const GURL& request_url, | 586 const GURL& request_url, |
| 486 bool download_to_file) | 587 bool download_to_file) |
| 487 : peer(std::move(peer)), | 588 : peer(std::move(peer)), |
| 488 resource_type(resource_type), | 589 resource_type(resource_type), |
| 489 origin_pid(origin_pid), | 590 origin_pid(origin_pid), |
| 490 url(request_url), | 591 url(request_url), |
| 491 frame_origin(frame_origin), | 592 frame_origin(frame_origin), |
| 492 response_url(request_url), | 593 response_url(request_url), |
| 493 download_to_file(download_to_file), | 594 download_to_file(download_to_file), |
| 494 request_start(base::TimeTicks::Now()) { | 595 request_start(base::TimeTicks::Now()), |
| 495 } | 596 mojo_total_bytes(0) {} |
| 496 | 597 |
| 497 ResourceDispatcher::PendingRequestInfo::~PendingRequestInfo() { | 598 ResourceDispatcher::PendingRequestInfo::~PendingRequestInfo() { |
| 498 } | 599 } |
| 499 | 600 |
| 500 void ResourceDispatcher::DispatchMessage(const IPC::Message& message) { | 601 void ResourceDispatcher::DispatchMessage(const IPC::Message& message) { |
| 501 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcher, message) | 602 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcher, message) |
| 502 IPC_MESSAGE_HANDLER(ResourceMsg_UploadProgress, OnUploadProgress) | 603 IPC_MESSAGE_HANDLER(ResourceMsg_UploadProgress, OnUploadProgress) |
| 503 IPC_MESSAGE_HANDLER(ResourceMsg_ReceivedResponse, OnReceivedResponse) | 604 IPC_MESSAGE_HANDLER(ResourceMsg_ReceivedResponse, OnReceivedResponse) |
| 504 IPC_MESSAGE_HANDLER(ResourceMsg_ReceivedCachedMetadata, | 605 IPC_MESSAGE_HANDLER(ResourceMsg_ReceivedCachedMetadata, |
| 505 OnReceivedCachedMetadata) | 606 OnReceivedCachedMetadata) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 response->request_time = result.request_time; | 669 response->request_time = result.request_time; |
| 569 response->response_time = result.response_time; | 670 response->response_time = result.response_time; |
| 570 response->encoded_data_length = result.encoded_data_length; | 671 response->encoded_data_length = result.encoded_data_length; |
| 571 response->load_timing = result.load_timing; | 672 response->load_timing = result.load_timing; |
| 572 response->devtools_info = result.devtools_info; | 673 response->devtools_info = result.devtools_info; |
| 573 response->data.swap(result.data); | 674 response->data.swap(result.data); |
| 574 response->download_file_path = result.download_file_path; | 675 response->download_file_path = result.download_file_path; |
| 575 response->socket_address = result.socket_address; | 676 response->socket_address = result.socket_address; |
| 576 } | 677 } |
| 577 | 678 |
| 578 int ResourceDispatcher::StartAsync(const RequestInfo& request_info, | 679 int ResourceDispatcher::StartAsync( |
| 579 ResourceRequestBody* request_body, | 680 const RequestInfo& request_info, |
| 580 scoped_ptr<RequestPeer> peer) { | 681 ResourceRequestBody* request_body, |
| 682 scoped_ptr<RequestPeer> peer, |
| 683 mojo::ScopedDataPipeConsumerHandle mojo_data_pipe_handle, |
| 684 int browser_request_id) { |
| 685 DCHECK_EQ(browser_request_id != -1, mojo_data_pipe_handle.is_valid()); |
| 581 GURL frame_origin; | 686 GURL frame_origin; |
| 582 scoped_ptr<ResourceHostMsg_Request> request = | 687 scoped_ptr<ResourceHostMsg_Request> request = |
| 583 CreateRequest(request_info, request_body, &frame_origin); | 688 CreateRequest(request_info, request_body, &frame_origin); |
| 584 | 689 |
| 585 // Compute a unique request_id for this renderer process. | 690 int request_id; |
| 586 int request_id = MakeRequestID(); | 691 if (browser_request_id == -1) { |
| 692 // Compute a unique request_id for this renderer process. |
| 693 request_id = MakeRequestID(); |
| 694 } else { |
| 695 // Uses the request_id already created by the browser. |
| 696 CHECK(!GetPendingRequestInfo(browser_request_id)); |
| 697 request_id = browser_request_id; |
| 698 } |
| 587 pending_requests_[request_id] = make_scoped_ptr(new PendingRequestInfo( | 699 pending_requests_[request_id] = make_scoped_ptr(new PendingRequestInfo( |
| 588 std::move(peer), request->resource_type, request->origin_pid, | 700 std::move(peer), request->resource_type, request->origin_pid, |
| 589 frame_origin, request->url, request_info.download_to_file)); | 701 frame_origin, request->url, request_info.download_to_file)); |
| 590 | 702 |
| 591 if (resource_scheduling_filter_.get() && | 703 if (resource_scheduling_filter_.get() && |
| 592 request_info.loading_web_task_runner) { | 704 request_info.loading_web_task_runner) { |
| 593 resource_scheduling_filter_->SetRequestIdTaskRunner( | 705 resource_scheduling_filter_->SetRequestIdTaskRunner( |
| 594 request_id, | 706 request_id, |
| 595 make_scoped_ptr(request_info.loading_web_task_runner->clone())); | 707 make_scoped_ptr(request_info.loading_web_task_runner->clone())); |
| 596 } | 708 } |
| 597 | 709 |
| 598 message_sender_->Send(new ResourceHostMsg_RequestResource( | 710 // PlzNavigate: if there is a Mojo data pipe handle set we know this is a |
| 599 request_info.routing_id, request_id, *request)); | 711 // PlzNavigate loading of a navigated document. |
| 712 if (mojo_data_pipe_handle.is_valid()) { |
| 713 LOG(ERROR) << "*** ResourceDispatcher::StartAsync request_id: " |
| 714 << request_id; |
| 715 LOG(ERROR) << "*** ResourceDispatcher::StartAsync url: " |
| 716 << request_info.url; |
| 717 // SetAndListenToMojoDataPipe(request_id, std::move(mojo_data_pipe_handle)); |
| 718 PendingRequestInfo* pending_request_info = |
| 719 GetPendingRequestInfo(request_id); |
| 720 pending_request_info->mojo_data_pipe_handle = |
| 721 std::move(mojo_data_pipe_handle); |
| 722 |
| 723 // Short circuiting call to OnReceivedResponse to immediately start the |
| 724 // request. |
| 725 // Note: the ResourceResponseHead() can be empty because it is completely |
| 726 // and totally reset in: |
| 727 // - ResourceDispatcher::OnReceivedResponse |
| 728 // - WebURLLoaderImpl::RequestPeerImpl::OnReceivedResponse |
| 729 // -->> WebURLLoaderImpl::Context::OnReceivedResponse (HERE!) |
| 730 OnReceivedResponse(request_id, ResourceResponseHead()); |
| 731 |
| 732 // Now that the correct state is set we can start listening for data from |
| 733 // the Mojo pipe, if one is set for this pending request. |
| 734 WaitForMojoData(request_id, pending_request_info); |
| 735 |
| 736 // TODO(carlosk): sending ResourceHostMsg_RequestResource to the browser |
| 737 // should not be needed but we still have to figure out if any of its side |
| 738 // effects are necessary for the request to actually succeed. |
| 739 } else { |
| 740 message_sender_->Send(new ResourceHostMsg_RequestResource( |
| 741 request_info.routing_id, request_id, *request)); |
| 742 } |
| 600 | 743 |
| 601 return request_id; | 744 return request_id; |
| 602 } | 745 } |
| 603 | 746 |
| 604 void ResourceDispatcher::ToResourceResponseInfo( | 747 void ResourceDispatcher::ToResourceResponseInfo( |
| 605 const PendingRequestInfo& request_info, | 748 const PendingRequestInfo& request_info, |
| 606 const ResourceResponseHead& browser_info, | 749 const ResourceResponseHead& browser_info, |
| 607 ResourceResponseInfo* renderer_info) const { | 750 ResourceResponseInfo* renderer_info) const { |
| 608 *renderer_info = browser_info; | 751 *renderer_info = browser_info; |
| 609 if (request_info.request_start.is_null() || | 752 if (request_info.request_start.is_null() || |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 *frame_origin = extra_data->frame_origin(); | 951 *frame_origin = extra_data->frame_origin(); |
| 809 return request; | 952 return request; |
| 810 } | 953 } |
| 811 | 954 |
| 812 void ResourceDispatcher::SetResourceSchedulingFilter( | 955 void ResourceDispatcher::SetResourceSchedulingFilter( |
| 813 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { | 956 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { |
| 814 resource_scheduling_filter_ = resource_scheduling_filter; | 957 resource_scheduling_filter_ = resource_scheduling_filter; |
| 815 } | 958 } |
| 816 | 959 |
| 817 } // namespace content | 960 } // namespace content |
| OLD | NEW |