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/browser/renderer_host/resource_dispatcher_host.h" | 7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 | 1291 |
1292 info->set_has_started_reading(true); | 1292 info->set_has_started_reading(true); |
1293 return request->Read(buf, buf_size, bytes_read); | 1293 return request->Read(buf, buf_size, bytes_read); |
1294 } | 1294 } |
1295 | 1295 |
1296 void ResourceDispatcherHost::OnReadCompleted(URLRequest* request, | 1296 void ResourceDispatcherHost::OnReadCompleted(URLRequest* request, |
1297 int bytes_read) { | 1297 int bytes_read) { |
1298 DCHECK(request); | 1298 DCHECK(request); |
1299 RESOURCE_LOG("OnReadCompleted: " << request->url().spec()); | 1299 RESOURCE_LOG("OnReadCompleted: " << request->url().spec()); |
1300 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1300 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); |
| 1301 |
| 1302 // OnReadCompleted can be called without Read (e.g., for chrome:// URLs). |
| 1303 // Make sure we know that a read has begun. |
| 1304 info->set_has_started_reading(true); |
| 1305 |
1301 if (PauseRequestIfNeeded(info)) { | 1306 if (PauseRequestIfNeeded(info)) { |
1302 info->set_paused_read_bytes(bytes_read); | 1307 info->set_paused_read_bytes(bytes_read); |
1303 RESOURCE_LOG("OnReadCompleted pausing: " << request->url().spec()); | 1308 RESOURCE_LOG("OnReadCompleted pausing: " << request->url().spec()); |
1304 return; | 1309 return; |
1305 } | 1310 } |
1306 | 1311 |
1307 if (request->status().is_success() && CompleteRead(request, &bytes_read)) { | 1312 if (request->status().is_success() && CompleteRead(request, &bytes_read)) { |
1308 // The request can be paused if we realize that the renderer is not | 1313 // The request can be paused if we realize that the renderer is not |
1309 // servicing messages fast enough. | 1314 // servicing messages fast enough. |
1310 if (info->pause_count() == 0 && | 1315 if (info->pause_count() == 0 && |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1814 // them. | 1819 // them. |
1815 case ResourceType::IMAGE: | 1820 case ResourceType::IMAGE: |
1816 return net::LOWEST; | 1821 return net::LOWEST; |
1817 | 1822 |
1818 default: | 1823 default: |
1819 // When new resource types are added, their priority must be considered. | 1824 // When new resource types are added, their priority must be considered. |
1820 NOTREACHED(); | 1825 NOTREACHED(); |
1821 return net::LOW; | 1826 return net::LOW; |
1822 } | 1827 } |
1823 } | 1828 } |
OLD | NEW |