| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 ReleaseResourcesInDataMessage(message); | 279 ReleaseResourcesInDataMessage(message); |
| 280 return true; | 280 return true; |
| 281 } | 281 } |
| 282 | 282 |
| 283 PendingRequestInfo& request_info = it->second; | 283 PendingRequestInfo& request_info = it->second; |
| 284 if (request_info.is_deferred) { | 284 if (request_info.is_deferred) { |
| 285 request_info.deferred_message_queue.push_back(new IPC::Message(message)); | 285 request_info.deferred_message_queue.push_back(new IPC::Message(message)); |
| 286 return true; | 286 return true; |
| 287 } | 287 } |
| 288 // Make sure any deferred messages are dispatched before we dispatch more. | 288 // Make sure any deferred messages are dispatched before we dispatch more. |
| 289 if (!request_info.deferred_message_queue.empty()) | 289 if (!request_info.deferred_message_queue.empty()) { |
| 290 FlushDeferredMessages(request_id); | 290 FlushDeferredMessages(request_id); |
| 291 // The request could have been deferred now. If yes then the current |
| 292 // message has to be queued up. The request_info instance should remain |
| 293 // valid here as there are pending messages for it. |
| 294 DCHECK(pending_requests_.find(request_id) != pending_requests_.end()); |
| 295 if (request_info.is_deferred) { |
| 296 request_info.deferred_message_queue.push_back(new IPC::Message(message)); |
| 297 return true; |
| 298 } |
| 299 } |
| 291 | 300 |
| 292 DispatchMessage(message); | 301 DispatchMessage(message); |
| 293 return true; | 302 return true; |
| 294 } | 303 } |
| 295 | 304 |
| 296 void ResourceDispatcher::OnUploadProgress( | 305 void ResourceDispatcher::OnUploadProgress( |
| 297 const IPC::Message& message, int request_id, int64 position, int64 size) { | 306 const IPC::Message& message, int request_id, int64 position, int64 size) { |
| 298 PendingRequestList::iterator it = pending_requests_.find(request_id); | 307 PendingRequestList::iterator it = pending_requests_.find(request_id); |
| 299 if (it == pending_requests_.end()) { | 308 if (it == pending_requests_.end()) { |
| 300 // this might happen for kill()ed requests on the webkit end, so perhaps | 309 // this might happen for kill()ed requests on the webkit end, so perhaps |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 // handle or there will be a memory leak. | 607 // handle or there will be a memory leak. |
| 599 if (message.type() == ViewMsg_Resource_DataReceived::ID) { | 608 if (message.type() == ViewMsg_Resource_DataReceived::ID) { |
| 600 base::SharedMemoryHandle shm_handle; | 609 base::SharedMemoryHandle shm_handle; |
| 601 if (IPC::ParamTraits<base::SharedMemoryHandle>::Read(&message, | 610 if (IPC::ParamTraits<base::SharedMemoryHandle>::Read(&message, |
| 602 &iter, | 611 &iter, |
| 603 &shm_handle)) { | 612 &shm_handle)) { |
| 604 base::SharedMemory::CloseHandle(shm_handle); | 613 base::SharedMemory::CloseHandle(shm_handle); |
| 605 } | 614 } |
| 606 } | 615 } |
| 607 } | 616 } |
| OLD | NEW |