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

Side by Side Diff: content/browser/renderer_host/resource_dispatcher_host.cc

Issue 6881106: Treat ERR_CONNECTION_CLOSED as end-of-data marker for downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pick 91c11da Forced logging on again. Created 9 years, 7 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/renderer_host/resource_dispatcher_host.h" 7 #include "content/browser/renderer_host/resource_dispatcher_host.h"
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 void ResourceDispatcherHost::ResumeRequest(const GlobalRequestID& request_id) { 1468 void ResourceDispatcherHost::ResumeRequest(const GlobalRequestID& request_id) {
1469 PendingRequestList::iterator i = pending_requests_.find(request_id); 1469 PendingRequestList::iterator i = pending_requests_.find(request_id);
1470 if (i == pending_requests_.end()) // The request may have been destroyed 1470 if (i == pending_requests_.end()) // The request may have been destroyed
1471 return; 1471 return;
1472 1472
1473 net::URLRequest* request = i->second; 1473 net::URLRequest* request = i->second;
1474 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); 1474 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request);
1475 if (!info->is_paused()) 1475 if (!info->is_paused())
1476 return; 1476 return;
1477 1477
1478 VLOG(1) << "Resuming: " << i->second->url().spec(); 1478 VLOG(1) << "Resuming: \"" << i->second->url().spec() << "\""
1479 << " paused_read_bytes = " << info->paused_read_bytes()
1480 << " called response started = " << info->called_on_response_started()
1481 << " started reading = " << info->has_started_reading();
1479 1482
1480 info->set_is_paused(false); 1483 info->set_is_paused(false);
1481 1484
1482 if (info->called_on_response_started()) { 1485 if (info->called_on_response_started()) {
1483 if (info->has_started_reading()) { 1486 if (info->has_started_reading()) {
1484 OnReadCompleted(i->second, info->paused_read_bytes()); 1487 OnReadCompleted(i->second, info->paused_read_bytes());
1485 } else { 1488 } else {
1486 StartReading(request); 1489 StartReading(request);
1487 } 1490 }
1488 } else { 1491 } else {
(...skipping 27 matching lines...) Expand all
1516 DCHECK(buf); 1519 DCHECK(buf);
1517 DCHECK(buf_size > 0); 1520 DCHECK(buf_size > 0);
1518 1521
1519 info->set_has_started_reading(true); 1522 info->set_has_started_reading(true);
1520 return request->Read(buf, buf_size, bytes_read); 1523 return request->Read(buf, buf_size, bytes_read);
1521 } 1524 }
1522 1525
1523 void ResourceDispatcherHost::OnReadCompleted(net::URLRequest* request, 1526 void ResourceDispatcherHost::OnReadCompleted(net::URLRequest* request,
1524 int bytes_read) { 1527 int bytes_read) {
1525 DCHECK(request); 1528 DCHECK(request);
1526 VLOG(1) << "OnReadCompleted: " << request->url().spec(); 1529 VLOG(1) << "OnReadCompleted: \"" << request->url().spec() << "\""
1530 << " bytes_read = " << bytes_read;
1527 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); 1531 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request);
1528 1532
1529 // bytes_read == -1 always implies an error, so we want to skip the 1533 // bytes_read == -1 always implies an error, so we want to skip the
1530 // pause checks and just call OnResponseCompleted. 1534 // pause checks and just call OnResponseCompleted.
1531 if (bytes_read == -1) { 1535 if (bytes_read == -1) {
1532 DCHECK(!request->status().is_success()); 1536 DCHECK(!request->status().is_success());
1533 1537
1534 OnResponseCompleted(request); 1538 OnResponseCompleted(request);
1535 return; 1539 return;
1536 } 1540 }
1537 1541
1538 // OnReadCompleted can be called without Read (e.g., for chrome:// URLs). 1542 // OnReadCompleted can be called without Read (e.g., for chrome:// URLs).
1539 // Make sure we know that a read has begun. 1543 // Make sure we know that a read has begun.
1540 info->set_has_started_reading(true); 1544 info->set_has_started_reading(true);
1541 1545
1542 if (PauseRequestIfNeeded(info)) { 1546 if (PauseRequestIfNeeded(info)) {
1543 info->set_paused_read_bytes(bytes_read); 1547 info->set_paused_read_bytes(bytes_read);
1544 VLOG(1) << "OnReadCompleted pausing: " << request->url().spec(); 1548 VLOG(1) << "OnReadCompleted pausing: \"" << request->url().spec() << "\""
1549 << " bytes_read = " << bytes_read;
1545 return; 1550 return;
1546 } 1551 }
1547 1552
1548 if (request->status().is_success() && CompleteRead(request, &bytes_read)) { 1553 if (request->status().is_success() && CompleteRead(request, &bytes_read)) {
1549 // The request can be paused if we realize that the renderer is not 1554 // The request can be paused if we realize that the renderer is not
1550 // servicing messages fast enough. 1555 // servicing messages fast enough.
1551 if (info->pause_count() == 0 && 1556 if (info->pause_count() == 0 &&
1552 Read(request, &bytes_read) && 1557 Read(request, &bytes_read) &&
1553 request->status().is_success()) { 1558 request->status().is_success()) {
1554 if (bytes_read == 0) { 1559 if (bytes_read == 0) {
1555 CompleteRead(request, &bytes_read); 1560 CompleteRead(request, &bytes_read);
1556 } else { 1561 } else {
1557 // Force the next CompleteRead / Read pair to run as a separate task. 1562 // Force the next CompleteRead / Read pair to run as a separate task.
1558 // This avoids a fast, large network request from monopolizing the IO 1563 // This avoids a fast, large network request from monopolizing the IO
1559 // thread and starving other IO operations from running. 1564 // thread and starving other IO operations from running.
1565 VLOG(1) << "OnReadCompleted postponing: \""
1566 << request->url().spec() << "\""
1567 << " bytes_read = " << bytes_read;
1560 info->set_paused_read_bytes(bytes_read); 1568 info->set_paused_read_bytes(bytes_read);
1561 info->set_is_paused(true); 1569 info->set_is_paused(true);
1562 GlobalRequestID id(info->child_id(), info->request_id()); 1570 GlobalRequestID id(info->child_id(), info->request_id());
1563 MessageLoop::current()->PostTask( 1571 MessageLoop::current()->PostTask(
1564 FROM_HERE, 1572 FROM_HERE,
1565 method_runner_.NewRunnableMethod( 1573 method_runner_.NewRunnableMethod(
1566 &ResourceDispatcherHost::ResumeRequest, id)); 1574 &ResourceDispatcherHost::ResumeRequest, id));
1567 return; 1575 return;
1568 } 1576 }
1569 } 1577 }
1570 } 1578 }
1571 1579
1572 if (PauseRequestIfNeeded(info)) { 1580 if (PauseRequestIfNeeded(info)) {
1573 info->set_paused_read_bytes(bytes_read); 1581 info->set_paused_read_bytes(bytes_read);
1574 VLOG(1) << "OnReadCompleted (CompleteRead) pausing: " 1582 VLOG(1) << "OnReadCompleted (CompleteRead) pausing: \""
1575 << request->url().spec(); 1583 << request->url().spec() << "\""
1584 << " bytes_read = " << bytes_read;
1576 return; 1585 return;
1577 } 1586 }
1578 1587
1579 // If the status is not IO pending then we've either finished (success) or we 1588 // If the status is not IO pending then we've either finished (success) or we
1580 // had an error. Either way, we're done! 1589 // had an error. Either way, we're done!
1581 if (!request->status().is_io_pending()) 1590 if (!request->status().is_io_pending())
1582 OnResponseCompleted(request); 1591 OnResponseCompleted(request);
1583 } 1592 }
1584 1593
1585 bool ResourceDispatcherHost::CompleteRead(net::URLRequest* request, 1594 bool ResourceDispatcherHost::CompleteRead(net::URLRequest* request,
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 return is_prefetch_enabled_; 2049 return is_prefetch_enabled_;
2041 } 2050 }
2042 2051
2043 // static 2052 // static
2044 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { 2053 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) {
2045 is_prefetch_enabled_ = value; 2054 is_prefetch_enabled_ = value;
2046 } 2055 }
2047 2056
2048 // static 2057 // static
2049 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; 2058 bool ResourceDispatcherHost::is_prefetch_enabled_ = false;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698