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.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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 delegate_->DownloadStarting(request, context, child_id, route_id, | 382 delegate_->DownloadStarting(request, context, child_id, route_id, |
383 request_id, !request->is_pending(), &throttles); | 383 request_id, !request->is_pending(), &throttles); |
384 if (!throttles.empty()) { | 384 if (!throttles.empty()) { |
385 handler = new ThrottlingResourceHandler(this, handler, child_id, | 385 handler = new ThrottlingResourceHandler(this, handler, child_id, |
386 request_id, throttles.Pass()); | 386 request_id, throttles.Pass()); |
387 } | 387 } |
388 } | 388 } |
389 return handler; | 389 return handler; |
390 } | 390 } |
391 | 391 |
392 ResourceType::Type ResourceDispatcherHost::ResourceTypeForInstance( | |
393 const SSLErrorHandler::instance_id& id) { | |
394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
395 net::URLRequest* request = GetURLRequest(id); | |
396 DCHECK(request); | |
397 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | |
398 DCHECK(info); | |
399 return info->resource_type(); | |
400 } | |
401 | |
402 const GURL& ResourceDispatcherHost::URLForInstance( | |
403 const SSLErrorHandler::instance_id& id) { | |
404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
405 net::URLRequest* request = GetURLRequest(id); | |
406 DCHECK(request); | |
407 return request->url(); | |
408 } | |
409 | |
410 bool ResourceDispatcherHost::RenderViewForInstance( | |
411 const SSLErrorHandler::instance_id& id, | |
412 int* render_process_host_id, | |
413 int* render_view_host_id) { | |
414 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
415 return RenderViewForRequest( | |
416 GetURLRequest(id), render_process_host_id, render_view_host_id); | |
417 } | |
418 | |
419 void ResourceDispatcherHost::CancelRequestForInstance( | |
420 const SSLErrorHandler::instance_id& id, | |
421 int error, | |
422 const net::SSLInfo* ssl_info) { | |
423 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
424 net::URLRequest* request = GetURLRequest(id); | |
425 // The request can be NULL if it was cancelled by the renderer (as the | |
426 // request of the user navigating to a new page from the location bar). | |
427 if (!request) | |
428 return; | |
429 DVLOG(1) << "CancelRequestForInstance() url: " << request->url().spec(); | |
430 if (ssl_info) | |
431 request->SimulateSSLError(error, *ssl_info); | |
432 else | |
433 request->SimulateError(error); | |
434 } | |
435 | |
436 void ResourceDispatcherHost::ContinueRequestForInstance( | |
437 const SSLErrorHandler::instance_id&id) { | |
438 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
439 net::URLRequest* request = GetURLRequest(id); | |
440 // The request can be NULL if it was cancelled by the renderer (as the | |
441 // request of the user navigating to a new page from the location bar). | |
442 if (!request) | |
443 return; | |
444 DVLOG(1) << "ContinueRequestForInstance() url: " << request->url().spec(); | |
445 request->ContinueDespiteLastError(); | |
446 } | |
447 | |
392 void ResourceDispatcherHost::SetRequestInfo( | 448 void ResourceDispatcherHost::SetRequestInfo( |
393 net::URLRequest* request, | 449 net::URLRequest* request, |
394 ResourceDispatcherHostRequestInfo* info) { | 450 ResourceDispatcherHostRequestInfo* info) { |
395 request->SetUserData(NULL, info); | 451 request->SetUserData(NULL, info); |
396 } | 452 } |
397 | 453 |
398 void ResourceDispatcherHost::OnShutdown() { | 454 void ResourceDispatcherHost::OnShutdown() { |
399 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 455 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
400 is_shutdown_ = true; | 456 is_shutdown_ = true; |
401 resource_queue_.Shutdown(); | 457 resource_queue_.Shutdown(); |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1422 info->set_ssl_client_auth_handler( | 1478 info->set_ssl_client_auth_handler( |
1423 new SSLClientAuthHandler(request, cert_request_info)); | 1479 new SSLClientAuthHandler(request, cert_request_info)); |
1424 info->ssl_client_auth_handler()->SelectCertificate(); | 1480 info->ssl_client_auth_handler()->SelectCertificate(); |
1425 } | 1481 } |
1426 | 1482 |
1427 void ResourceDispatcherHost::OnSSLCertificateError( | 1483 void ResourceDispatcherHost::OnSSLCertificateError( |
1428 net::URLRequest* request, | 1484 net::URLRequest* request, |
1429 const net::SSLInfo& ssl_info, | 1485 const net::SSLInfo& ssl_info, |
1430 bool is_hsts_host) { | 1486 bool is_hsts_host) { |
1431 DCHECK(request); | 1487 DCHECK(request); |
1432 SSLManager::OnSSLCertificateError(this, request, ssl_info, is_hsts_host); | 1488 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); |
1489 SSLErrorHandler::instance_id instance; | |
wtc
2012/02/22 00:36:23
Nit: 'error_handler_id' seems more clear than 'ins
Takashi Toyoshima
2012/02/22 08:15:35
Now, 'request_id' looks better as instance of Glob
| |
1490 instance.first = info->child_id(); | |
1491 instance.second = info->request_id(); | |
1492 SSLManager::OnSSLCertificateError(this, instance, ssl_info, is_hsts_host); | |
1433 } | 1493 } |
1434 | 1494 |
1435 bool ResourceDispatcherHost::CanGetCookies( | 1495 bool ResourceDispatcherHost::CanGetCookies( |
1436 const net::URLRequest* request, | 1496 const net::URLRequest* request, |
1437 const net::CookieList& cookie_list) const { | 1497 const net::CookieList& cookie_list) const { |
1438 VLOG(1) << "OnGetCookies: " << request->url().spec(); | 1498 VLOG(1) << "OnGetCookies: " << request->url().spec(); |
1439 int render_process_id, render_view_id; | 1499 int render_process_id, render_view_id; |
1440 if (!RenderViewForRequest(request, &render_process_id, &render_view_id)) | 1500 if (!RenderViewForRequest(request, &render_process_id, &render_view_id)) |
1441 return false; | 1501 return false; |
1442 | 1502 |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1975 // This should be running in the IO loop. | 2035 // This should be running in the IO loop. |
1976 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2036 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1977 | 2037 |
1978 PendingRequestList::const_iterator i = pending_requests_.find(request_id); | 2038 PendingRequestList::const_iterator i = pending_requests_.find(request_id); |
1979 if (i == pending_requests_.end()) | 2039 if (i == pending_requests_.end()) |
1980 return NULL; | 2040 return NULL; |
1981 | 2041 |
1982 return i->second; | 2042 return i->second; |
1983 } | 2043 } |
1984 | 2044 |
2045 net::URLRequest* ResourceDispatcherHost::GetURLRequest( | |
2046 const SSLErrorHandler::instance_id& id) const { | |
2047 content::GlobalRequestID request_id; | |
2048 request_id.child_id = id.first; | |
2049 request_id.request_id = id.second; | |
2050 return GetURLRequest(request_id); | |
2051 } | |
2052 | |
1985 static int GetCertID(net::URLRequest* request, int child_id) { | 2053 static int GetCertID(net::URLRequest* request, int child_id) { |
1986 if (request->ssl_info().cert) { | 2054 if (request->ssl_info().cert) { |
1987 return CertStore::GetInstance()->StoreCert(request->ssl_info().cert, | 2055 return CertStore::GetInstance()->StoreCert(request->ssl_info().cert, |
1988 child_id); | 2056 child_id); |
1989 } | 2057 } |
1990 return 0; | 2058 return 0; |
1991 } | 2059 } |
1992 | 2060 |
1993 void ResourceDispatcherHost::NotifyResponseStarted(net::URLRequest* request, | 2061 void ResourceDispatcherHost::NotifyResponseStarted(net::URLRequest* request, |
1994 int child_id) { | 2062 int child_id) { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2301 scoped_refptr<ResourceHandler> transferred_resource_handler( | 2369 scoped_refptr<ResourceHandler> transferred_resource_handler( |
2302 new DoomedResourceHandler(info->resource_handler())); | 2370 new DoomedResourceHandler(info->resource_handler())); |
2303 info->set_resource_handler(transferred_resource_handler.get()); | 2371 info->set_resource_handler(transferred_resource_handler.get()); |
2304 } | 2372 } |
2305 | 2373 |
2306 bool ResourceDispatcherHost::IsTransferredNavigation( | 2374 bool ResourceDispatcherHost::IsTransferredNavigation( |
2307 const content::GlobalRequestID& transferred_request_id) const { | 2375 const content::GlobalRequestID& transferred_request_id) const { |
2308 return transferred_navigations_.find(transferred_request_id) != | 2376 return transferred_navigations_.find(transferred_request_id) != |
2309 transferred_navigations_.end(); | 2377 transferred_navigations_.end(); |
2310 } | 2378 } |
OLD | NEW |