| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/common/resource_dispatcher.h" | 7 #include "chrome/common/resource_dispatcher.h" |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 #endif | 136 #endif |
| 137 } | 137 } |
| 138 | 138 |
| 139 IPCResourceLoaderBridge::~IPCResourceLoaderBridge() { | 139 IPCResourceLoaderBridge::~IPCResourceLoaderBridge() { |
| 140 // we remove our hook for the resource dispatcher only when going away, since | 140 // we remove our hook for the resource dispatcher only when going away, since |
| 141 // it doesn't keep track of whether we've force terminated the request | 141 // it doesn't keep track of whether we've force terminated the request |
| 142 if (request_id_ >= 0) { | 142 if (request_id_ >= 0) { |
| 143 // this operation may fail, as the dispatcher will have preemptively | 143 // this operation may fail, as the dispatcher will have preemptively |
| 144 // removed us when the renderer sends the ReceivedAllData message. | 144 // removed us when the renderer sends the ReceivedAllData message. |
| 145 dispatcher_->RemovePendingRequest(request_id_); | 145 dispatcher_->RemovePendingRequest(request_id_); |
| 146 |
| 147 if (request_.download_to_file) { |
| 148 dispatcher_->message_sender()->Send( |
| 149 new ViewHostMsg_ReleaseDownloadedFile(request_id_)); |
| 150 } |
| 146 } | 151 } |
| 147 } | 152 } |
| 148 | 153 |
| 149 void IPCResourceLoaderBridge::AppendDataToUpload(const char* data, | 154 void IPCResourceLoaderBridge::AppendDataToUpload(const char* data, |
| 150 int data_len) { | 155 int data_len) { |
| 151 DCHECK(request_id_ == -1) << "request already started"; | 156 DCHECK(request_id_ == -1) << "request already started"; |
| 152 | 157 |
| 153 // don't bother appending empty data segments | 158 // don't bother appending empty data segments |
| 154 if (data_len == 0) | 159 if (data_len == 0) |
| 155 return; | 160 return; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 response->url = result.final_url; | 258 response->url = result.final_url; |
| 254 response->headers = result.headers; | 259 response->headers = result.headers; |
| 255 response->mime_type = result.mime_type; | 260 response->mime_type = result.mime_type; |
| 256 response->charset = result.charset; | 261 response->charset = result.charset; |
| 257 response->request_time = result.request_time; | 262 response->request_time = result.request_time; |
| 258 response->response_time = result.response_time; | 263 response->response_time = result.response_time; |
| 259 response->connection_id = result.connection_id; | 264 response->connection_id = result.connection_id; |
| 260 response->connection_reused = result.connection_reused; | 265 response->connection_reused = result.connection_reused; |
| 261 response->load_timing = result.load_timing; | 266 response->load_timing = result.load_timing; |
| 262 response->data.swap(result.data); | 267 response->data.swap(result.data); |
| 268 response->download_file_path = result.download_file_path; |
| 263 } | 269 } |
| 264 | 270 |
| 265 } // namespace webkit_glue | 271 } // namespace webkit_glue |
| 266 | 272 |
| 267 // ResourceDispatcher --------------------------------------------------------- | 273 // ResourceDispatcher --------------------------------------------------------- |
| 268 | 274 |
| 269 ResourceDispatcher::ResourceDispatcher(IPC::Message::Sender* sender) | 275 ResourceDispatcher::ResourceDispatcher(IPC::Message::Sender* sender) |
| 270 : message_sender_(sender), | 276 : message_sender_(sender), |
| 271 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 277 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
| 272 } | 278 } |
| 273 | 279 |
| 274 ResourceDispatcher::~ResourceDispatcher() { | 280 ResourceDispatcher::~ResourceDispatcher() { |
| 275 } | 281 } |
| 276 | 282 |
| 277 // ResourceDispatcher implementation ------------------------------------------ | 283 // ResourceDispatcher implementation ------------------------------------------ |
| 278 | 284 |
| 279 bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) { | 285 bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) { |
| 280 if (!IsResourceDispatcherMessage(message)) { | 286 if (!IsResourceDispatcherMessage(message)) { |
| 281 return false; | 287 return false; |
| 282 } | 288 } |
| 283 | 289 |
| 284 int request_id; | 290 int request_id; |
| 285 | 291 |
| 286 void* iter = NULL; | 292 void* iter = NULL; |
| 287 if (!message.ReadInt(&iter, &request_id)) { | 293 if (!message.ReadInt(&iter, &request_id)) { |
| 288 NOTREACHED() << "malformed resource message"; | 294 NOTREACHED() << "malformed resource message"; |
| 289 return true; | 295 return true; |
| 290 } | 296 } |
| 291 | 297 |
| 292 PendingRequestList::iterator it = pending_requests_.find(request_id); | 298 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 293 if (it == pending_requests_.end()) { | 299 if (!request_info) { |
| 294 // This might happen for kill()ed requests on the webkit end, so perhaps it | |
| 295 // shouldn't be a warning... | |
| 296 DLOG(WARNING) << "Got response for a nonexistent or finished request"; | |
| 297 // Release resources in the message if it is a data message. | 300 // Release resources in the message if it is a data message. |
| 298 ReleaseResourcesInDataMessage(message); | 301 ReleaseResourcesInDataMessage(message); |
| 299 return true; | 302 return true; |
| 300 } | 303 } |
| 301 | 304 |
| 302 PendingRequestInfo& request_info = it->second; | 305 if (request_info->is_deferred) { |
| 303 if (request_info.is_deferred) { | 306 request_info->deferred_message_queue.push_back(new IPC::Message(message)); |
| 304 request_info.deferred_message_queue.push_back(new IPC::Message(message)); | |
| 305 return true; | 307 return true; |
| 306 } | 308 } |
| 307 // Make sure any deferred messages are dispatched before we dispatch more. | 309 // Make sure any deferred messages are dispatched before we dispatch more. |
| 308 if (!request_info.deferred_message_queue.empty()) { | 310 if (!request_info->deferred_message_queue.empty()) { |
| 309 FlushDeferredMessages(request_id); | 311 FlushDeferredMessages(request_id); |
| 310 // The request could have been deferred now. If yes then the current | 312 // The request could have been deferred now. If yes then the current |
| 311 // message has to be queued up. The request_info instance should remain | 313 // message has to be queued up. The request_info instance should remain |
| 312 // valid here as there are pending messages for it. | 314 // valid here as there are pending messages for it. |
| 313 DCHECK(pending_requests_.find(request_id) != pending_requests_.end()); | 315 DCHECK(pending_requests_.find(request_id) != pending_requests_.end()); |
| 314 if (request_info.is_deferred) { | 316 if (request_info->is_deferred) { |
| 315 request_info.deferred_message_queue.push_back(new IPC::Message(message)); | 317 request_info->deferred_message_queue.push_back(new IPC::Message(message)); |
| 316 return true; | 318 return true; |
| 317 } | 319 } |
| 318 } | 320 } |
| 319 | 321 |
| 320 DispatchMessage(message); | 322 DispatchMessage(message); |
| 321 return true; | 323 return true; |
| 322 } | 324 } |
| 323 | 325 |
| 326 ResourceDispatcher::PendingRequestInfo* |
| 327 ResourceDispatcher::GetPendingRequestInfo(int request_id) { |
| 328 PendingRequestList::iterator it = pending_requests_.find(request_id); |
| 329 if (it == pending_requests_.end()) { |
| 330 // This might happen for kill()ed requests on the webkit end, so perhaps it |
| 331 // shouldn't be a warning... |
| 332 DLOG(WARNING) << "Received message for a nonexistent or finished request"; |
| 333 return NULL; |
| 334 } |
| 335 return &(it->second); |
| 336 } |
| 337 |
| 324 void ResourceDispatcher::OnUploadProgress( | 338 void ResourceDispatcher::OnUploadProgress( |
| 325 const IPC::Message& message, int request_id, int64 position, int64 size) { | 339 const IPC::Message& message, int request_id, int64 position, int64 size) { |
| 326 PendingRequestList::iterator it = pending_requests_.find(request_id); | 340 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 327 if (it == pending_requests_.end()) { | 341 if (!request_info) |
| 328 // this might happen for kill()ed requests on the webkit end, so perhaps | |
| 329 // it shouldn't be a warning... | |
| 330 DLOG(WARNING) << "Got upload progress for a nonexistent or " | |
| 331 "finished request"; | |
| 332 return; | 342 return; |
| 333 } | |
| 334 | |
| 335 PendingRequestInfo& request_info = it->second; | |
| 336 | 343 |
| 337 RESOURCE_LOG("Dispatching upload progress for " << | 344 RESOURCE_LOG("Dispatching upload progress for " << |
| 338 request_info.peer->GetURLForDebugging().possibly_invalid_spec()); | 345 request_info->peer->GetURLForDebugging().possibly_invalid_spec()); |
| 339 request_info.peer->OnUploadProgress(position, size); | 346 request_info->peer->OnUploadProgress(position, size); |
| 340 | 347 |
| 341 // Acknowledge receipt | 348 // Acknowledge receipt |
| 342 message_sender()->Send( | 349 message_sender()->Send( |
| 343 new ViewHostMsg_UploadProgress_ACK(message.routing_id(), request_id)); | 350 new ViewHostMsg_UploadProgress_ACK(message.routing_id(), request_id)); |
| 344 } | 351 } |
| 345 | 352 |
| 346 void ResourceDispatcher::OnReceivedResponse( | 353 void ResourceDispatcher::OnReceivedResponse( |
| 347 int request_id, const ResourceResponseHead& response_head) { | 354 int request_id, const ResourceResponseHead& response_head) { |
| 348 PendingRequestList::iterator it = pending_requests_.find(request_id); | 355 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 349 if (it == pending_requests_.end()) { | 356 if (!request_info) |
| 350 // This might happen for kill()ed requests on the webkit end, so perhaps it | |
| 351 // shouldn't be a warning... | |
| 352 DLOG(WARNING) << "Got response for a nonexistent or finished request"; | |
| 353 return; | 357 return; |
| 354 } | |
| 355 | 358 |
| 356 PendingRequestInfo& request_info = it->second; | |
| 357 if (response_head.replace_extension_localization_templates) { | 359 if (response_head.replace_extension_localization_templates) { |
| 358 webkit_glue::ResourceLoaderBridge::Peer* new_peer = | 360 webkit_glue::ResourceLoaderBridge::Peer* new_peer = |
| 359 ExtensionLocalizationPeer::CreateExtensionLocalizationPeer( | 361 ExtensionLocalizationPeer::CreateExtensionLocalizationPeer( |
| 360 request_info.peer, message_sender(), response_head.mime_type, | 362 request_info->peer, message_sender(), response_head.mime_type, |
| 361 request_info.url); | 363 request_info->url); |
| 362 if (new_peer) | 364 if (new_peer) |
| 363 request_info.peer = new_peer; | 365 request_info->peer = new_peer; |
| 364 } | 366 } |
| 365 | 367 |
| 366 RESOURCE_LOG("Dispatching response for " << | 368 RESOURCE_LOG("Dispatching response for " << |
| 367 request_info.peer->GetURLForDebugging().possibly_invalid_spec()); | 369 request_info->peer->GetURLForDebugging().possibly_invalid_spec()); |
| 368 request_info.peer->OnReceivedResponse(response_head, false); | 370 request_info->peer->OnReceivedResponse(response_head, false); |
| 369 } | 371 } |
| 370 | 372 |
| 371 void ResourceDispatcher::OnReceivedCachedMetadata( | 373 void ResourceDispatcher::OnReceivedCachedMetadata( |
| 372 int request_id, const std::vector<char>& data) { | 374 int request_id, const std::vector<char>& data) { |
| 373 PendingRequestList::iterator it = pending_requests_.find(request_id); | 375 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 374 if (it == pending_requests_.end()) { | 376 if (!request_info) |
| 375 // this might happen for kill()ed requests on the webkit end, so perhaps | |
| 376 // it shouldn't be a warning... | |
| 377 DLOG(WARNING) << "Got metadata for a nonexistent or finished request"; | |
| 378 return; | 377 return; |
| 379 } | |
| 380 | 378 |
| 381 if (data.size()) { | 379 if (data.size()) { |
| 382 PendingRequestInfo& request_info = it->second; | |
| 383 RESOURCE_LOG("Dispatching " << data.size() << " metadata bytes for " << | 380 RESOURCE_LOG("Dispatching " << data.size() << " metadata bytes for " << |
| 384 request_info.peer->GetURLForDebugging().possibly_invalid_spec()); | 381 request_info->peer->GetURLForDebugging().possibly_invalid_spec()); |
| 385 request_info.peer->OnReceivedCachedMetadata(&data.front(), data.size()); | 382 request_info->peer->OnReceivedCachedMetadata(&data.front(), data.size()); |
| 386 } | 383 } |
| 387 } | 384 } |
| 388 | 385 |
| 389 void ResourceDispatcher::OnReceivedData(const IPC::Message& message, | 386 void ResourceDispatcher::OnReceivedData(const IPC::Message& message, |
| 390 int request_id, | 387 int request_id, |
| 391 base::SharedMemoryHandle shm_handle, | 388 base::SharedMemoryHandle shm_handle, |
| 392 int data_len) { | 389 int data_len) { |
| 393 // Acknowledge the reception of this data. | 390 // Acknowledge the reception of this data. |
| 394 message_sender()->Send( | 391 message_sender()->Send( |
| 395 new ViewHostMsg_DataReceived_ACK(message.routing_id(), request_id)); | 392 new ViewHostMsg_DataReceived_ACK(message.routing_id(), request_id)); |
| 396 | 393 |
| 397 const bool shm_valid = base::SharedMemory::IsHandleValid(shm_handle); | 394 const bool shm_valid = base::SharedMemory::IsHandleValid(shm_handle); |
| 398 DCHECK((shm_valid && data_len > 0) || (!shm_valid && !data_len)); | 395 DCHECK((shm_valid && data_len > 0) || (!shm_valid && !data_len)); |
| 399 base::SharedMemory shared_mem(shm_handle, true); // read only | 396 base::SharedMemory shared_mem(shm_handle, true); // read only |
| 400 | 397 |
| 401 PendingRequestList::iterator it = pending_requests_.find(request_id); | 398 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 402 if (it == pending_requests_.end()) { | 399 if (!request_info) |
| 403 // this might happen for kill()ed requests on the webkit end, so perhaps | |
| 404 // it shouldn't be a warning... | |
| 405 DLOG(WARNING) << "Got data for a nonexistent or finished request"; | |
| 406 return; | 400 return; |
| 407 } | |
| 408 | |
| 409 PendingRequestInfo& request_info = it->second; | |
| 410 | 401 |
| 411 if (data_len > 0 && shared_mem.Map(data_len)) { | 402 if (data_len > 0 && shared_mem.Map(data_len)) { |
| 412 RESOURCE_LOG("Dispatching " << data_len << " bytes for " << | 403 RESOURCE_LOG("Dispatching " << data_len << " bytes for " << |
| 413 request_info.peer->GetURLForDebugging().possibly_invalid_spec()); | 404 request_info->peer->GetURLForDebugging().possibly_invalid_spec()); |
| 414 const char* data = static_cast<char*>(shared_mem.memory()); | 405 const char* data = static_cast<char*>(shared_mem.memory()); |
| 415 request_info.peer->OnReceivedData(data, data_len); | 406 request_info->peer->OnReceivedData(data, data_len); |
| 416 } | 407 } |
| 417 } | 408 } |
| 418 | 409 |
| 410 void ResourceDispatcher::OnDownloadedData(const IPC::Message& message, |
| 411 int request_id, |
| 412 int data_len) { |
| 413 // Acknowledge the reception of this message. |
| 414 message_sender()->Send( |
| 415 new ViewHostMsg_DataDownloaded_ACK(message.routing_id(), request_id)); |
| 416 |
| 417 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 418 if (!request_info) |
| 419 return; |
| 420 |
| 421 RESOURCE_LOG("Dispatching " << data_len << " downloaded for " << |
| 422 request_info->peer->GetURLForDebugging().possibly_invalid_spec()); |
| 423 request_info->peer->OnDownloadedData(data_len); |
| 424 } |
| 425 |
| 419 void ResourceDispatcher::OnReceivedRedirect( | 426 void ResourceDispatcher::OnReceivedRedirect( |
| 420 const IPC::Message& message, | 427 const IPC::Message& message, |
| 421 int request_id, | 428 int request_id, |
| 422 const GURL& new_url, | 429 const GURL& new_url, |
| 423 const webkit_glue::ResourceLoaderBridge::ResponseInfo& info) { | 430 const webkit_glue::ResourceLoaderBridge::ResponseInfo& info) { |
| 424 PendingRequestList::iterator it = pending_requests_.find(request_id); | 431 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 425 if (it == pending_requests_.end()) { | 432 if (!request_info) |
| 426 // this might happen for kill()ed requests on the webkit end, so perhaps | |
| 427 // it shouldn't be a warning... | |
| 428 DLOG(WARNING) << "Got data for a nonexistent or finished request"; | |
| 429 return; | 433 return; |
| 430 } | |
| 431 | 434 |
| 432 PendingRequestInfo& request_info = it->second; | 435 RESOURCE_LOG( |
| 433 | 436 "Dispatching redirect for " << |
| 434 RESOURCE_LOG("Dispatching redirect for " << | 437 request_info->peer->GetURLForDebugging().possibly_invalid_spec()); |
| 435 request_info.peer->GetURLForDebugging().possibly_invalid_spec()); | |
| 436 | 438 |
| 437 bool has_new_first_party_for_cookies = false; | 439 bool has_new_first_party_for_cookies = false; |
| 438 GURL new_first_party_for_cookies; | 440 GURL new_first_party_for_cookies; |
| 439 if (request_info.peer->OnReceivedRedirect(new_url, info, | 441 if (request_info->peer->OnReceivedRedirect(new_url, info, |
| 440 &has_new_first_party_for_cookies, | 442 &has_new_first_party_for_cookies, |
| 441 &new_first_party_for_cookies)) { | 443 &new_first_party_for_cookies)) { |
| 442 message_sender()->Send( | 444 message_sender()->Send( |
| 443 new ViewHostMsg_FollowRedirect(message.routing_id(), request_id, | 445 new ViewHostMsg_FollowRedirect(message.routing_id(), request_id, |
| 444 has_new_first_party_for_cookies, | 446 has_new_first_party_for_cookies, |
| 445 new_first_party_for_cookies)); | 447 new_first_party_for_cookies)); |
| 446 } else { | 448 } else { |
| 447 CancelPendingRequest(message.routing_id(), request_id); | 449 CancelPendingRequest(message.routing_id(), request_id); |
| 448 } | 450 } |
| 449 } | 451 } |
| 450 | 452 |
| 451 void ResourceDispatcher::OnRequestComplete(int request_id, | 453 void ResourceDispatcher::OnRequestComplete(int request_id, |
| 452 const URLRequestStatus& status, | 454 const URLRequestStatus& status, |
| 453 const std::string& security_info, | 455 const std::string& security_info, |
| 454 const base::Time& completion_time) { | 456 const base::Time& completion_time) { |
| 455 PendingRequestList::iterator it = pending_requests_.find(request_id); | 457 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 456 if (it == pending_requests_.end()) { | 458 if (!request_info) |
| 457 // this might happen for kill()ed requests on the webkit end, so perhaps | |
| 458 // it shouldn't be a warning... | |
| 459 DLOG(WARNING) << "Got 'complete' for a nonexistent or finished request"; | |
| 460 return; | 459 return; |
| 461 } | |
| 462 | 460 |
| 463 PendingRequestInfo& request_info = it->second; | 461 webkit_glue::ResourceLoaderBridge::Peer* peer = request_info->peer; |
| 464 webkit_glue::ResourceLoaderBridge::Peer* peer = request_info.peer; | |
| 465 | 462 |
| 466 RESOURCE_LOG("Dispatching complete for " << | 463 RESOURCE_LOG("Dispatching complete for " << |
| 467 request_info.peer->GetURLForDebugging().possibly_invalid_spec()); | 464 peer->GetURLForDebugging().possibly_invalid_spec()); |
| 468 | 465 |
| 469 if (status.status() == URLRequestStatus::CANCELED && | 466 if (status.status() == URLRequestStatus::CANCELED && |
| 470 status.os_error() != net::ERR_ABORTED) { | 467 status.os_error() != net::ERR_ABORTED) { |
| 471 // Resource canceled with a specific error are filtered. | 468 // Resource canceled with a specific error are filtered. |
| 472 SecurityFilterPeer* new_peer = | 469 SecurityFilterPeer* new_peer = |
| 473 SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest( | 470 SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest( |
| 474 request_info.resource_type, | 471 request_info->resource_type, |
| 475 request_info.peer, | 472 request_info->peer, |
| 476 status.os_error()); | 473 status.os_error()); |
| 477 if (new_peer) { | 474 if (new_peer) { |
| 478 request_info.peer = new_peer; | 475 request_info->peer = new_peer; |
| 479 peer = new_peer; | 476 peer = new_peer; |
| 480 } | 477 } |
| 481 } | 478 } |
| 482 | 479 |
| 483 // The request ID will be removed from our pending list in the destructor. | 480 // The request ID will be removed from our pending list in the destructor. |
| 484 // Normally, dispatching this message causes the reference-counted request to | 481 // Normally, dispatching this message causes the reference-counted request to |
| 485 // die immediately. | 482 // die immediately. |
| 486 peer->OnCompletedRequest(status, security_info, completion_time); | 483 peer->OnCompletedRequest(status, security_info, completion_time); |
| 487 | 484 |
| 488 webkit_glue::NotifyCacheStats(); | 485 webkit_glue::NotifyCacheStats(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 } | 542 } |
| 546 | 543 |
| 547 void ResourceDispatcher::DispatchMessage(const IPC::Message& message) { | 544 void ResourceDispatcher::DispatchMessage(const IPC::Message& message) { |
| 548 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcher, message) | 545 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcher, message) |
| 549 IPC_MESSAGE_HANDLER(ViewMsg_Resource_UploadProgress, OnUploadProgress) | 546 IPC_MESSAGE_HANDLER(ViewMsg_Resource_UploadProgress, OnUploadProgress) |
| 550 IPC_MESSAGE_HANDLER(ViewMsg_Resource_ReceivedResponse, OnReceivedResponse) | 547 IPC_MESSAGE_HANDLER(ViewMsg_Resource_ReceivedResponse, OnReceivedResponse) |
| 551 IPC_MESSAGE_HANDLER( | 548 IPC_MESSAGE_HANDLER( |
| 552 ViewMsg_Resource_ReceivedCachedMetadata, OnReceivedCachedMetadata) | 549 ViewMsg_Resource_ReceivedCachedMetadata, OnReceivedCachedMetadata) |
| 553 IPC_MESSAGE_HANDLER(ViewMsg_Resource_ReceivedRedirect, OnReceivedRedirect) | 550 IPC_MESSAGE_HANDLER(ViewMsg_Resource_ReceivedRedirect, OnReceivedRedirect) |
| 554 IPC_MESSAGE_HANDLER(ViewMsg_Resource_DataReceived, OnReceivedData) | 551 IPC_MESSAGE_HANDLER(ViewMsg_Resource_DataReceived, OnReceivedData) |
| 552 IPC_MESSAGE_HANDLER(ViewMsg_Resource_DataDownloaded, OnDownloadedData) |
| 555 IPC_MESSAGE_HANDLER(ViewMsg_Resource_RequestComplete, OnRequestComplete) | 553 IPC_MESSAGE_HANDLER(ViewMsg_Resource_RequestComplete, OnRequestComplete) |
| 556 IPC_END_MESSAGE_MAP() | 554 IPC_END_MESSAGE_MAP() |
| 557 } | 555 } |
| 558 | 556 |
| 559 void ResourceDispatcher::FlushDeferredMessages(int request_id) { | 557 void ResourceDispatcher::FlushDeferredMessages(int request_id) { |
| 560 PendingRequestList::iterator it = pending_requests_.find(request_id); | 558 PendingRequestList::iterator it = pending_requests_.find(request_id); |
| 561 if (it == pending_requests_.end()) // The request could have become invalid. | 559 if (it == pending_requests_.end()) // The request could have become invalid. |
| 562 return; | 560 return; |
| 563 PendingRequestInfo& request_info = it->second; | 561 PendingRequestInfo& request_info = it->second; |
| 564 if (request_info.is_deferred) | 562 if (request_info.is_deferred) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 } | 595 } |
| 598 | 596 |
| 599 bool ResourceDispatcher::IsResourceDispatcherMessage( | 597 bool ResourceDispatcher::IsResourceDispatcherMessage( |
| 600 const IPC::Message& message) { | 598 const IPC::Message& message) { |
| 601 switch (message.type()) { | 599 switch (message.type()) { |
| 602 case ViewMsg_Resource_UploadProgress::ID: | 600 case ViewMsg_Resource_UploadProgress::ID: |
| 603 case ViewMsg_Resource_ReceivedResponse::ID: | 601 case ViewMsg_Resource_ReceivedResponse::ID: |
| 604 case ViewMsg_Resource_ReceivedCachedMetadata::ID: | 602 case ViewMsg_Resource_ReceivedCachedMetadata::ID: |
| 605 case ViewMsg_Resource_ReceivedRedirect::ID: | 603 case ViewMsg_Resource_ReceivedRedirect::ID: |
| 606 case ViewMsg_Resource_DataReceived::ID: | 604 case ViewMsg_Resource_DataReceived::ID: |
| 605 case ViewMsg_Resource_DataDownloaded::ID: |
| 607 case ViewMsg_Resource_RequestComplete::ID: | 606 case ViewMsg_Resource_RequestComplete::ID: |
| 608 return true; | 607 return true; |
| 609 | 608 |
| 610 default: | 609 default: |
| 611 break; | 610 break; |
| 612 } | 611 } |
| 613 | 612 |
| 614 return false; | 613 return false; |
| 615 } | 614 } |
| 616 | 615 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 638 | 637 |
| 639 // static | 638 // static |
| 640 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { | 639 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { |
| 641 while (!queue->empty()) { | 640 while (!queue->empty()) { |
| 642 IPC::Message* message = queue->front(); | 641 IPC::Message* message = queue->front(); |
| 643 ReleaseResourcesInDataMessage(*message); | 642 ReleaseResourcesInDataMessage(*message); |
| 644 queue->pop_front(); | 643 queue->pop_front(); |
| 645 delete message; | 644 delete message; |
| 646 } | 645 } |
| 647 } | 646 } |
| OLD | NEW |