| 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/common/resource_dispatcher.h" | 7 #include "content/common/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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 response->devtools_info = result.devtools_info; | 250 response->devtools_info = result.devtools_info; |
| 251 response->data.swap(result.data); | 251 response->data.swap(result.data); |
| 252 response->download_file_path = result.download_file_path; | 252 response->download_file_path = result.download_file_path; |
| 253 } | 253 } |
| 254 | 254 |
| 255 // ResourceDispatcher --------------------------------------------------------- | 255 // ResourceDispatcher --------------------------------------------------------- |
| 256 | 256 |
| 257 ResourceDispatcher::ResourceDispatcher(IPC::Sender* sender) | 257 ResourceDispatcher::ResourceDispatcher(IPC::Sender* sender) |
| 258 : message_sender_(sender), | 258 : message_sender_(sender), |
| 259 weak_factory_(this), | 259 weak_factory_(this), |
| 260 delegate_(NULL) { | 260 delegate_(NULL), |
| 261 io_timestamp_(base::TimeTicks()) { |
| 261 } | 262 } |
| 262 | 263 |
| 263 ResourceDispatcher::~ResourceDispatcher() { | 264 ResourceDispatcher::~ResourceDispatcher() { |
| 264 } | 265 } |
| 265 | 266 |
| 266 // ResourceDispatcher implementation ------------------------------------------ | 267 // ResourceDispatcher implementation ------------------------------------------ |
| 267 | 268 |
| 268 bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) { | 269 bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) { |
| 269 if (!IsResourceDispatcherMessage(message)) { | 270 if (!IsResourceDispatcherMessage(message)) { |
| 270 return false; | 271 return false; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 // Acknowledge receipt | 328 // Acknowledge receipt |
| 328 message_sender()->Send( | 329 message_sender()->Send( |
| 329 new ResourceHostMsg_UploadProgress_ACK(message.routing_id(), request_id)); | 330 new ResourceHostMsg_UploadProgress_ACK(message.routing_id(), request_id)); |
| 330 } | 331 } |
| 331 | 332 |
| 332 void ResourceDispatcher::OnReceivedResponse( | 333 void ResourceDispatcher::OnReceivedResponse( |
| 333 int request_id, const ResourceResponseHead& response_head) { | 334 int request_id, const ResourceResponseHead& response_head) { |
| 334 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 335 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 335 if (!request_info) | 336 if (!request_info) |
| 336 return; | 337 return; |
| 337 request_info->response_start = base::TimeTicks::Now(); | 338 request_info->response_start = io_timestamp_; |
| 339 io_timestamp_ = base::TimeTicks(); |
| 338 | 340 |
| 339 if (delegate_) { | 341 if (delegate_) { |
| 340 ResourceLoaderBridge::Peer* new_peer = | 342 ResourceLoaderBridge::Peer* new_peer = |
| 341 delegate_->OnReceivedResponse( | 343 delegate_->OnReceivedResponse( |
| 342 request_info->peer, response_head.mime_type, request_info->url); | 344 request_info->peer, response_head.mime_type, request_info->url); |
| 343 if (new_peer) | 345 if (new_peer) |
| 344 request_info->peer = new_peer; | 346 request_info->peer = new_peer; |
| 345 } | 347 } |
| 346 | 348 |
| 347 ResourceResponseInfo renderer_response_info; | 349 ResourceResponseInfo renderer_response_info; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 } | 442 } |
| 441 | 443 |
| 442 void ResourceDispatcher::OnReceivedRedirect( | 444 void ResourceDispatcher::OnReceivedRedirect( |
| 443 const IPC::Message& message, | 445 const IPC::Message& message, |
| 444 int request_id, | 446 int request_id, |
| 445 const GURL& new_url, | 447 const GURL& new_url, |
| 446 const ResourceResponseHead& response_head) { | 448 const ResourceResponseHead& response_head) { |
| 447 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 449 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 448 if (!request_info) | 450 if (!request_info) |
| 449 return; | 451 return; |
| 450 request_info->response_start = base::TimeTicks::Now(); | 452 request_info->response_start = io_timestamp_; |
| 453 io_timestamp_ = base::TimeTicks(); |
| 451 | 454 |
| 452 int32 routing_id = message.routing_id(); | 455 int32 routing_id = message.routing_id(); |
| 453 bool has_new_first_party_for_cookies = false; | 456 bool has_new_first_party_for_cookies = false; |
| 454 GURL new_first_party_for_cookies; | 457 GURL new_first_party_for_cookies; |
| 455 ResourceResponseInfo renderer_response_info; | 458 ResourceResponseInfo renderer_response_info; |
| 456 ToResourceResponseInfo(*request_info, response_head, &renderer_response_info); | 459 ToResourceResponseInfo(*request_info, response_head, &renderer_response_info); |
| 457 if (request_info->peer->OnReceivedRedirect(new_url, renderer_response_info, | 460 if (request_info->peer->OnReceivedRedirect(new_url, renderer_response_info, |
| 458 &has_new_first_party_for_cookies, | 461 &has_new_first_party_for_cookies, |
| 459 &new_first_party_for_cookies)) { | 462 &new_first_party_for_cookies)) { |
| 460 // Double-check if the request is still around. The call above could | 463 // Double-check if the request is still around. The call above could |
| (...skipping 23 matching lines...) Expand all Loading... |
| 484 | 487 |
| 485 void ResourceDispatcher::OnRequestComplete( | 488 void ResourceDispatcher::OnRequestComplete( |
| 486 int request_id, | 489 int request_id, |
| 487 int error_code, | 490 int error_code, |
| 488 bool was_ignored_by_handler, | 491 bool was_ignored_by_handler, |
| 489 const std::string& security_info, | 492 const std::string& security_info, |
| 490 const base::TimeTicks& browser_completion_time) { | 493 const base::TimeTicks& browser_completion_time) { |
| 491 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 494 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 492 if (!request_info) | 495 if (!request_info) |
| 493 return; | 496 return; |
| 494 request_info->completion_time = base::TimeTicks::Now(); | 497 request_info->completion_time = io_timestamp_; |
| 498 io_timestamp_ = base::TimeTicks(); |
| 495 request_info->buffer.reset(); | 499 request_info->buffer.reset(); |
| 496 request_info->buffer_size = 0; | 500 request_info->buffer_size = 0; |
| 497 | 501 |
| 498 ResourceLoaderBridge::Peer* peer = request_info->peer; | 502 ResourceLoaderBridge::Peer* peer = request_info->peer; |
| 499 | 503 |
| 500 if (delegate_) { | 504 if (delegate_) { |
| 501 ResourceLoaderBridge::Peer* new_peer = | 505 ResourceLoaderBridge::Peer* new_peer = |
| 502 delegate_->OnRequestComplete( | 506 delegate_->OnRequestComplete( |
| 503 request_info->peer, request_info->resource_type, error_code); | 507 request_info->peer, request_info->resource_type, error_code); |
| 504 if (new_peer) | 508 if (new_peer) |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { | 752 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { |
| 749 while (!queue->empty()) { | 753 while (!queue->empty()) { |
| 750 IPC::Message* message = queue->front(); | 754 IPC::Message* message = queue->front(); |
| 751 ReleaseResourcesInDataMessage(*message); | 755 ReleaseResourcesInDataMessage(*message); |
| 752 queue->pop_front(); | 756 queue->pop_front(); |
| 753 delete message; | 757 delete message; |
| 754 } | 758 } |
| 755 } | 759 } |
| 756 | 760 |
| 757 } // namespace content | 761 } // namespace content |
| OLD | NEW |