Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(570)

Side by Side Diff: chrome/common/resource_dispatcher.cc

Issue 113931: Remove code path that passes a file handle to the renderer... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/resource_dispatcher.h ('k') | net/base/cache_type.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 return true; 287 return true;
288 } 288 }
289 // Make sure any deferred messages are dispatched before we dispatch more. 289 // Make sure any deferred messages are dispatched before we dispatch more.
290 if (!request_info.deferred_message_queue.empty()) 290 if (!request_info.deferred_message_queue.empty())
291 FlushDeferredMessages(request_id); 291 FlushDeferredMessages(request_id);
292 292
293 DispatchMessage(message); 293 DispatchMessage(message);
294 return true; 294 return true;
295 } 295 }
296 296
297 void ResourceDispatcher::OnDownloadProgress(
298 const IPC::Message& message, int request_id, int64 position, int64 size) {
299 PendingRequestList::iterator it = pending_requests_.find(request_id);
300 if (it == pending_requests_.end()) {
301 DLOG(WARNING) << "Got download progress for a nonexistant or "
302 " finished requests";
303 return;
304 }
305
306 PendingRequestInfo& request_info = it->second;
307
308 RESOURCE_LOG("Dispatching download progress for " <<
309 request_info.peer->GetURLForDebugging());
310 request_info.peer->OnDownloadProgress(position, size);
311
312 // Send the ACK message back.
313 IPC::Message::Sender* sender = message_sender();
314 if (sender) {
315 sender->Send(
316 new ViewHostMsg_DownloadProgress_ACK(message.routing_id(), request_id));
317 }
318 }
319
320 void ResourceDispatcher::OnUploadProgress( 297 void ResourceDispatcher::OnUploadProgress(
321 const IPC::Message& message, int request_id, int64 position, int64 size) { 298 const IPC::Message& message, int request_id, int64 position, int64 size) {
322 PendingRequestList::iterator it = pending_requests_.find(request_id); 299 PendingRequestList::iterator it = pending_requests_.find(request_id);
323 if (it == pending_requests_.end()) { 300 if (it == pending_requests_.end()) {
324 // this might happen for kill()ed requests on the webkit end, so perhaps 301 // this might happen for kill()ed requests on the webkit end, so perhaps
325 // it shouldn't be a warning... 302 // it shouldn't be a warning...
326 DLOG(WARNING) << "Got upload progress for a nonexistant or " 303 DLOG(WARNING) << "Got upload progress for a nonexistant or "
327 "finished request"; 304 "finished request";
328 return; 305 return;
329 } 306 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 request_info.is_deferred = false; 474 request_info.is_deferred = false;
498 MessageLoop::current()->PostTask(FROM_HERE, 475 MessageLoop::current()->PostTask(FROM_HERE,
499 method_factory_.NewRunnableMethod( 476 method_factory_.NewRunnableMethod(
500 &ResourceDispatcher::FlushDeferredMessages, request_id)); 477 &ResourceDispatcher::FlushDeferredMessages, request_id));
501 } 478 }
502 } 479 }
503 480
504 void ResourceDispatcher::DispatchMessage(const IPC::Message& message) { 481 void ResourceDispatcher::DispatchMessage(const IPC::Message& message) {
505 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcher, message) 482 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcher, message)
506 IPC_MESSAGE_HANDLER(ViewMsg_Resource_UploadProgress, OnUploadProgress) 483 IPC_MESSAGE_HANDLER(ViewMsg_Resource_UploadProgress, OnUploadProgress)
507 IPC_MESSAGE_HANDLER(ViewMsg_Resource_DownloadProgress, OnDownloadProgress)
508 IPC_MESSAGE_HANDLER(ViewMsg_Resource_ReceivedResponse, OnReceivedResponse) 484 IPC_MESSAGE_HANDLER(ViewMsg_Resource_ReceivedResponse, OnReceivedResponse)
509 IPC_MESSAGE_HANDLER(ViewMsg_Resource_ReceivedRedirect, OnReceivedRedirect) 485 IPC_MESSAGE_HANDLER(ViewMsg_Resource_ReceivedRedirect, OnReceivedRedirect)
510 IPC_MESSAGE_HANDLER(ViewMsg_Resource_DataReceived, OnReceivedData) 486 IPC_MESSAGE_HANDLER(ViewMsg_Resource_DataReceived, OnReceivedData)
511 IPC_MESSAGE_HANDLER(ViewMsg_Resource_RequestComplete, OnRequestComplete) 487 IPC_MESSAGE_HANDLER(ViewMsg_Resource_RequestComplete, OnRequestComplete)
512 IPC_END_MESSAGE_MAP() 488 IPC_END_MESSAGE_MAP()
513 } 489 }
514 490
515 void ResourceDispatcher::FlushDeferredMessages(int request_id) { 491 void ResourceDispatcher::FlushDeferredMessages(int request_id) {
516 PendingRequestList::iterator it = pending_requests_.find(request_id); 492 PendingRequestList::iterator it = pending_requests_.find(request_id);
517 if (it == pending_requests_.end()) // The request could have become invalid. 493 if (it == pending_requests_.end()) // The request could have become invalid.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 flags, origin_pid, 528 flags, origin_pid,
553 resource_type, 529 resource_type,
554 request_context, 530 request_context,
555 app_cache_context_id, 531 app_cache_context_id,
556 route_id); 532 route_id);
557 } 533 }
558 534
559 bool ResourceDispatcher::IsResourceDispatcherMessage( 535 bool ResourceDispatcher::IsResourceDispatcherMessage(
560 const IPC::Message& message) { 536 const IPC::Message& message) {
561 switch (message.type()) { 537 switch (message.type()) {
562 case ViewMsg_Resource_DownloadProgress::ID:
563 case ViewMsg_Resource_UploadProgress::ID: 538 case ViewMsg_Resource_UploadProgress::ID:
564 case ViewMsg_Resource_ReceivedResponse::ID: 539 case ViewMsg_Resource_ReceivedResponse::ID:
565 case ViewMsg_Resource_ReceivedRedirect::ID: 540 case ViewMsg_Resource_ReceivedRedirect::ID:
566 case ViewMsg_Resource_DataReceived::ID: 541 case ViewMsg_Resource_DataReceived::ID:
567 case ViewMsg_Resource_RequestComplete::ID: 542 case ViewMsg_Resource_RequestComplete::ID:
568 return true; 543 return true;
569 544
570 default: 545 default:
571 break; 546 break;
572 } 547 }
(...skipping 14 matching lines...) Expand all
587 // handle or there will be a memory leak. 562 // handle or there will be a memory leak.
588 if (message.type() == ViewMsg_Resource_DataReceived::ID) { 563 if (message.type() == ViewMsg_Resource_DataReceived::ID) {
589 base::SharedMemoryHandle shm_handle; 564 base::SharedMemoryHandle shm_handle;
590 if (IPC::ParamTraits<base::SharedMemoryHandle>::Read(&message, 565 if (IPC::ParamTraits<base::SharedMemoryHandle>::Read(&message,
591 &iter, 566 &iter,
592 &shm_handle)) { 567 &shm_handle)) {
593 base::SharedMemory::CloseHandle(shm_handle); 568 base::SharedMemory::CloseHandle(shm_handle);
594 } 569 }
595 } 570 }
596 } 571 }
OLDNEW
« no previous file with comments | « chrome/common/resource_dispatcher.h ('k') | net/base/cache_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698