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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 // 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 |
310 // it shouldn't be a warning... | 310 // it shouldn't be a warning... |
311 DLOG(WARNING) << "Got upload progress for a nonexistant or " | 311 DLOG(WARNING) << "Got upload progress for a nonexistant or " |
312 "finished request"; | 312 "finished request"; |
313 return; | 313 return; |
314 } | 314 } |
315 | 315 |
316 PendingRequestInfo& request_info = it->second; | 316 PendingRequestInfo& request_info = it->second; |
317 | 317 |
318 RESOURCE_LOG("Dispatching upload progress for " << | 318 RESOURCE_LOG("Dispatching upload progress for " << |
319 request_info.peer->GetURLForDebugging()); | 319 request_info.peer->GetURLForDebugging().possibly_invalid_spec()); |
320 request_info.peer->OnUploadProgress(position, size); | 320 request_info.peer->OnUploadProgress(position, size); |
321 | 321 |
322 // Acknowlegde reciept | 322 // Acknowlegde reciept |
323 message_sender()->Send( | 323 message_sender()->Send( |
324 new ViewHostMsg_UploadProgress_ACK(message.routing_id(), request_id)); | 324 new ViewHostMsg_UploadProgress_ACK(message.routing_id(), request_id)); |
325 } | 325 } |
326 | 326 |
327 void ResourceDispatcher::OnReceivedResponse( | 327 void ResourceDispatcher::OnReceivedResponse( |
328 int request_id, const ResourceResponseHead& response_head) { | 328 int request_id, const ResourceResponseHead& response_head) { |
329 PendingRequestList::iterator it = pending_requests_.find(request_id); | 329 PendingRequestList::iterator it = pending_requests_.find(request_id); |
(...skipping 14 matching lines...) Expand all Loading... |
344 NULL, peer, | 344 NULL, peer, |
345 request_info.resource_type, response_head.mime_type, | 345 request_info.resource_type, response_head.mime_type, |
346 request_info.filter_policy, | 346 request_info.filter_policy, |
347 net::ERR_INSECURE_RESPONSE); | 347 net::ERR_INSECURE_RESPONSE); |
348 if (new_peer) { | 348 if (new_peer) { |
349 request_info.peer = new_peer; | 349 request_info.peer = new_peer; |
350 peer = new_peer; | 350 peer = new_peer; |
351 } | 351 } |
352 } | 352 } |
353 | 353 |
354 RESOURCE_LOG("Dispatching response for " << peer->GetURLForDebugging()); | 354 RESOURCE_LOG("Dispatching response for " << |
| 355 peer->GetURLForDebugging().possibly_invalid_spec()); |
355 peer->OnReceivedResponse(response_head, false); | 356 peer->OnReceivedResponse(response_head, false); |
356 } | 357 } |
357 | 358 |
358 void ResourceDispatcher::OnReceivedData(const IPC::Message& message, | 359 void ResourceDispatcher::OnReceivedData(const IPC::Message& message, |
359 int request_id, | 360 int request_id, |
360 base::SharedMemoryHandle shm_handle, | 361 base::SharedMemoryHandle shm_handle, |
361 int data_len) { | 362 int data_len) { |
362 // Acknowledge the reception of this data. | 363 // Acknowledge the reception of this data. |
363 message_sender()->Send( | 364 message_sender()->Send( |
364 new ViewHostMsg_DataReceived_ACK(message.routing_id(), request_id)); | 365 new ViewHostMsg_DataReceived_ACK(message.routing_id(), request_id)); |
365 | 366 |
366 const bool shm_valid = base::SharedMemory::IsHandleValid(shm_handle); | 367 const bool shm_valid = base::SharedMemory::IsHandleValid(shm_handle); |
367 DCHECK((shm_valid && data_len > 0) || (!shm_valid && !data_len)); | 368 DCHECK((shm_valid && data_len > 0) || (!shm_valid && !data_len)); |
368 base::SharedMemory shared_mem(shm_handle, true); // read only | 369 base::SharedMemory shared_mem(shm_handle, true); // read only |
369 | 370 |
370 PendingRequestList::iterator it = pending_requests_.find(request_id); | 371 PendingRequestList::iterator it = pending_requests_.find(request_id); |
371 if (it == pending_requests_.end()) { | 372 if (it == pending_requests_.end()) { |
372 // this might happen for kill()ed requests on the webkit end, so perhaps | 373 // this might happen for kill()ed requests on the webkit end, so perhaps |
373 // it shouldn't be a warning... | 374 // it shouldn't be a warning... |
374 DLOG(WARNING) << "Got data for a nonexistant or finished request"; | 375 DLOG(WARNING) << "Got data for a nonexistant or finished request"; |
375 return; | 376 return; |
376 } | 377 } |
377 | 378 |
378 PendingRequestInfo& request_info = it->second; | 379 PendingRequestInfo& request_info = it->second; |
379 | 380 |
380 if (data_len > 0 && shared_mem.Map(data_len)) { | 381 if (data_len > 0 && shared_mem.Map(data_len)) { |
381 RESOURCE_LOG("Dispatching " << data_len << " bytes for " << | 382 RESOURCE_LOG("Dispatching " << data_len << " bytes for " << |
382 request_info.peer->GetURLForDebugging()); | 383 request_info.peer->GetURLForDebugging().possibly_invalid_spec()); |
383 const char* data = static_cast<char*>(shared_mem.memory()); | 384 const char* data = static_cast<char*>(shared_mem.memory()); |
384 request_info.peer->OnReceivedData(data, data_len); | 385 request_info.peer->OnReceivedData(data, data_len); |
385 } | 386 } |
386 } | 387 } |
387 | 388 |
388 void ResourceDispatcher::OnReceivedRedirect( | 389 void ResourceDispatcher::OnReceivedRedirect( |
389 const IPC::Message& message, | 390 const IPC::Message& message, |
390 int request_id, | 391 int request_id, |
391 const GURL& new_url, | 392 const GURL& new_url, |
392 const webkit_glue::ResourceLoaderBridge::ResponseInfo& info) { | 393 const webkit_glue::ResourceLoaderBridge::ResponseInfo& info) { |
393 PendingRequestList::iterator it = pending_requests_.find(request_id); | 394 PendingRequestList::iterator it = pending_requests_.find(request_id); |
394 if (it == pending_requests_.end()) { | 395 if (it == pending_requests_.end()) { |
395 // this might happen for kill()ed requests on the webkit end, so perhaps | 396 // this might happen for kill()ed requests on the webkit end, so perhaps |
396 // it shouldn't be a warning... | 397 // it shouldn't be a warning... |
397 DLOG(WARNING) << "Got data for a nonexistant or finished request"; | 398 DLOG(WARNING) << "Got data for a nonexistant or finished request"; |
398 return; | 399 return; |
399 } | 400 } |
400 | 401 |
401 PendingRequestInfo& request_info = it->second; | 402 PendingRequestInfo& request_info = it->second; |
402 | 403 |
403 RESOURCE_LOG("Dispatching redirect for " << | 404 RESOURCE_LOG("Dispatching redirect for " << |
404 request_info.peer->GetURLForDebugging()); | 405 request_info.peer->GetURLForDebugging().possibly_invalid_spec()); |
405 | 406 |
406 if (request_info.peer->OnReceivedRedirect(new_url, info)) { | 407 if (request_info.peer->OnReceivedRedirect(new_url, info)) { |
407 message_sender()->Send( | 408 message_sender()->Send( |
408 new ViewHostMsg_FollowRedirect(message.routing_id(), request_id)); | 409 new ViewHostMsg_FollowRedirect(message.routing_id(), request_id)); |
409 } else { | 410 } else { |
410 CancelPendingRequest(message.routing_id(), request_id); | 411 CancelPendingRequest(message.routing_id(), request_id); |
411 } | 412 } |
412 } | 413 } |
413 | 414 |
414 void ResourceDispatcher::OnRequestComplete(int request_id, | 415 void ResourceDispatcher::OnRequestComplete(int request_id, |
415 const URLRequestStatus& status, | 416 const URLRequestStatus& status, |
416 const std::string& security_info) { | 417 const std::string& security_info) { |
417 PendingRequestList::iterator it = pending_requests_.find(request_id); | 418 PendingRequestList::iterator it = pending_requests_.find(request_id); |
418 if (it == pending_requests_.end()) { | 419 if (it == pending_requests_.end()) { |
419 // this might happen for kill()ed requests on the webkit end, so perhaps | 420 // this might happen for kill()ed requests on the webkit end, so perhaps |
420 // it shouldn't be a warning... | 421 // it shouldn't be a warning... |
421 DLOG(WARNING) << "Got 'complete' for a nonexistant or finished request"; | 422 DLOG(WARNING) << "Got 'complete' for a nonexistant or finished request"; |
422 return; | 423 return; |
423 } | 424 } |
424 | 425 |
425 PendingRequestInfo& request_info = it->second; | 426 PendingRequestInfo& request_info = it->second; |
426 webkit_glue::ResourceLoaderBridge::Peer* peer = request_info.peer; | 427 webkit_glue::ResourceLoaderBridge::Peer* peer = request_info.peer; |
427 | 428 |
428 RESOURCE_LOG("Dispatching complete for " << | 429 RESOURCE_LOG("Dispatching complete for " << |
429 request_info.peer->GetURLForDebugging()); | 430 request_info.peer->GetURLForDebugging().possibly_invalid_spec()); |
430 | 431 |
431 if (status.status() == URLRequestStatus::CANCELED && | 432 if (status.status() == URLRequestStatus::CANCELED && |
432 status.os_error() != net::ERR_ABORTED) { | 433 status.os_error() != net::ERR_ABORTED) { |
433 // Resource canceled with a specific error are filtered. | 434 // Resource canceled with a specific error are filtered. |
434 SecurityFilterPeer* new_peer = | 435 SecurityFilterPeer* new_peer = |
435 SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest( | 436 SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest( |
436 request_info.resource_type, | 437 request_info.resource_type, |
437 request_info.peer, | 438 request_info.peer, |
438 status.os_error()); | 439 status.os_error()); |
439 if (new_peer) { | 440 if (new_peer) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 // handle or there will be a memory leak. | 608 // handle or there will be a memory leak. |
608 if (message.type() == ViewMsg_Resource_DataReceived::ID) { | 609 if (message.type() == ViewMsg_Resource_DataReceived::ID) { |
609 base::SharedMemoryHandle shm_handle; | 610 base::SharedMemoryHandle shm_handle; |
610 if (IPC::ParamTraits<base::SharedMemoryHandle>::Read(&message, | 611 if (IPC::ParamTraits<base::SharedMemoryHandle>::Read(&message, |
611 &iter, | 612 &iter, |
612 &shm_handle)) { | 613 &shm_handle)) { |
613 base::SharedMemory::CloseHandle(shm_handle); | 614 base::SharedMemory::CloseHandle(shm_handle); |
614 } | 615 } |
615 } | 616 } |
616 } | 617 } |
OLD | NEW |