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