| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_impl.h" | 7 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 313 |
| 314 // static | 314 // static |
| 315 ResourceDispatcherHost* ResourceDispatcherHost::Get() { | 315 ResourceDispatcherHost* ResourceDispatcherHost::Get() { |
| 316 return g_resource_dispatcher_host; | 316 return g_resource_dispatcher_host; |
| 317 } | 317 } |
| 318 | 318 |
| 319 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() | 319 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() |
| 320 : download_file_manager_(new DownloadFileManager(NULL)), | 320 : download_file_manager_(new DownloadFileManager(NULL)), |
| 321 save_file_manager_(new SaveFileManager()), | 321 save_file_manager_(new SaveFileManager()), |
| 322 request_id_(-1), | 322 request_id_(-1), |
| 323 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | |
| 324 ALLOW_THIS_IN_INITIALIZER_LIST(ssl_delegate_weak_factory_(this)), | |
| 325 is_shutdown_(false), | 323 is_shutdown_(false), |
| 326 max_outstanding_requests_cost_per_process_( | 324 max_outstanding_requests_cost_per_process_( |
| 327 kMaxOutstandingRequestsCostPerProcess), | 325 kMaxOutstandingRequestsCostPerProcess), |
| 328 filter_(NULL), | 326 filter_(NULL), |
| 329 delegate_(NULL), | 327 delegate_(NULL), |
| 330 allow_cross_origin_auth_prompt_(false) { | 328 allow_cross_origin_auth_prompt_(false) { |
| 331 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 332 DCHECK(!g_resource_dispatcher_host); | 330 DCHECK(!g_resource_dispatcher_host); |
| 333 g_resource_dispatcher_host = this; | 331 g_resource_dispatcher_host = this; |
| 334 | 332 |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 const net::SSLInfo& ssl_info, | 1508 const net::SSLInfo& ssl_info, |
| 1511 bool is_hsts_host) { | 1509 bool is_hsts_host) { |
| 1512 DCHECK(request); | 1510 DCHECK(request); |
| 1513 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 1511 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
| 1514 DCHECK(info); | 1512 DCHECK(info); |
| 1515 GlobalRequestID request_id(info->GetChildID(), info->GetRequestID()); | 1513 GlobalRequestID request_id(info->GetChildID(), info->GetRequestID()); |
| 1516 int render_process_id; | 1514 int render_process_id; |
| 1517 int render_view_id; | 1515 int render_view_id; |
| 1518 if(!info->GetAssociatedRenderView(&render_process_id, &render_view_id)) | 1516 if(!info->GetAssociatedRenderView(&render_process_id, &render_view_id)) |
| 1519 NOTREACHED(); | 1517 NOTREACHED(); |
| 1520 SSLManager::OnSSLCertificateError(ssl_delegate_weak_factory_.GetWeakPtr(), | 1518 SSLManager::OnSSLCertificateError( |
| 1521 request_id, info->GetResourceType(), request->url(), render_process_id, | 1519 AsWeakPtr(), request_id, info->GetResourceType(), request->url(), |
| 1522 render_view_id, ssl_info, is_hsts_host); | 1520 render_process_id, render_view_id, ssl_info, is_hsts_host); |
| 1523 } | 1521 } |
| 1524 | 1522 |
| 1525 void ResourceDispatcherHostImpl::OnResponseStarted(net::URLRequest* request) { | 1523 void ResourceDispatcherHostImpl::OnResponseStarted(net::URLRequest* request) { |
| 1526 VLOG(1) << "OnResponseStarted: " << request->url().spec(); | 1524 VLOG(1) << "OnResponseStarted: " << request->url().spec(); |
| 1527 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 1525 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
| 1528 | 1526 |
| 1529 if (request->status().is_success()) { | 1527 if (request->status().is_success()) { |
| 1530 if (PauseRequestIfNeeded(info)) { | 1528 if (PauseRequestIfNeeded(info)) { |
| 1531 VLOG(1) << "OnResponseStarted pausing: " << request->url().spec(); | 1529 VLOG(1) << "OnResponseStarted pausing: " << request->url().spec(); |
| 1532 return; | 1530 return; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 return; | 1792 return; |
| 1795 } | 1793 } |
| 1796 info->set_pause_count(pause_count); | 1794 info->set_pause_count(pause_count); |
| 1797 | 1795 |
| 1798 VLOG(1) << "To pause (" << pause << "): " << i->second->url().spec(); | 1796 VLOG(1) << "To pause (" << pause << "): " << i->second->url().spec(); |
| 1799 | 1797 |
| 1800 // If we're resuming, kick the request to start reading again. Run the read | 1798 // If we're resuming, kick the request to start reading again. Run the read |
| 1801 // asynchronously to avoid recursion problems. | 1799 // asynchronously to avoid recursion problems. |
| 1802 if (info->pause_count() == 0) { | 1800 if (info->pause_count() == 0) { |
| 1803 MessageLoop::current()->PostTask(FROM_HERE, | 1801 MessageLoop::current()->PostTask(FROM_HERE, |
| 1804 base::Bind( | 1802 base::Bind(&ResourceDispatcherHostImpl::ResumeRequest, |
| 1805 &ResourceDispatcherHostImpl::ResumeRequest, | 1803 AsWeakPtr(), global_id)); |
| 1806 weak_factory_.GetWeakPtr(), | |
| 1807 global_id)); | |
| 1808 } | 1804 } |
| 1809 } | 1805 } |
| 1810 | 1806 |
| 1811 void ResourceDispatcherHostImpl::ResumeRequest( | 1807 void ResourceDispatcherHostImpl::ResumeRequest( |
| 1812 const GlobalRequestID& request_id) { | 1808 const GlobalRequestID& request_id) { |
| 1813 PendingRequestList::iterator i = pending_requests_.find(request_id); | 1809 PendingRequestList::iterator i = pending_requests_.find(request_id); |
| 1814 if (i == pending_requests_.end()) // The request may have been destroyed | 1810 if (i == pending_requests_.end()) // The request may have been destroyed |
| 1815 return; | 1811 return; |
| 1816 | 1812 |
| 1817 net::URLRequest* request = i->second; | 1813 net::URLRequest* request = i->second; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1912 // This avoids a fast, large network request from monopolizing the IO | 1908 // This avoids a fast, large network request from monopolizing the IO |
| 1913 // thread and starving other IO operations from running. | 1909 // thread and starving other IO operations from running. |
| 1914 VLOG(1) << "OnReadCompleted postponing: \"" | 1910 VLOG(1) << "OnReadCompleted postponing: \"" |
| 1915 << request->url().spec() << "\"" | 1911 << request->url().spec() << "\"" |
| 1916 << " bytes_read = " << bytes_read; | 1912 << " bytes_read = " << bytes_read; |
| 1917 info->set_paused_read_bytes(bytes_read); | 1913 info->set_paused_read_bytes(bytes_read); |
| 1918 info->set_is_paused(true); | 1914 info->set_is_paused(true); |
| 1919 GlobalRequestID id(info->GetChildID(), info->GetRequestID()); | 1915 GlobalRequestID id(info->GetChildID(), info->GetRequestID()); |
| 1920 MessageLoop::current()->PostTask( | 1916 MessageLoop::current()->PostTask( |
| 1921 FROM_HERE, | 1917 FROM_HERE, |
| 1922 base::Bind( | 1918 base::Bind(&ResourceDispatcherHostImpl::ResumeRequest, |
| 1923 &ResourceDispatcherHostImpl::ResumeRequest, | 1919 AsWeakPtr(), id)); |
| 1924 weak_factory_.GetWeakPtr(), id)); | |
| 1925 return; | 1920 return; |
| 1926 } | 1921 } |
| 1927 } | 1922 } |
| 1928 } | 1923 } |
| 1929 | 1924 |
| 1930 if (PauseRequestIfNeeded(info)) { | 1925 if (PauseRequestIfNeeded(info)) { |
| 1931 info->set_paused_read_bytes(bytes_read); | 1926 info->set_paused_read_bytes(bytes_read); |
| 1932 VLOG(1) << "OnReadCompleted (CompleteRead) pausing: \"" | 1927 VLOG(1) << "OnReadCompleted (CompleteRead) pausing: \"" |
| 1933 << request->url().spec() << "\"" | 1928 << request->url().spec() << "\"" |
| 1934 << " bytes_read = " << bytes_read; | 1929 << " bytes_read = " << bytes_read; |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2361 return allow_cross_origin_auth_prompt_; | 2356 return allow_cross_origin_auth_prompt_; |
| 2362 } | 2357 } |
| 2363 | 2358 |
| 2364 bool ResourceDispatcherHostImpl::IsTransferredNavigation( | 2359 bool ResourceDispatcherHostImpl::IsTransferredNavigation( |
| 2365 const GlobalRequestID& transferred_request_id) const { | 2360 const GlobalRequestID& transferred_request_id) const { |
| 2366 return transferred_navigations_.find(transferred_request_id) != | 2361 return transferred_navigations_.find(transferred_request_id) != |
| 2367 transferred_navigations_.end(); | 2362 transferred_navigations_.end(); |
| 2368 } | 2363 } |
| 2369 | 2364 |
| 2370 } // namespace content | 2365 } // namespace content |
| OLD | NEW |