| 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 <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include "chrome/browser/renderer_host/resource_request_details.h" | 47 #include "chrome/browser/renderer_host/resource_request_details.h" |
| 48 #include "chrome/browser/renderer_host/safe_browsing_resource_handler.h" | 48 #include "chrome/browser/renderer_host/safe_browsing_resource_handler.h" |
| 49 #include "chrome/browser/renderer_host/save_file_resource_handler.h" | 49 #include "chrome/browser/renderer_host/save_file_resource_handler.h" |
| 50 #include "chrome/browser/renderer_host/sync_resource_handler.h" | 50 #include "chrome/browser/renderer_host/sync_resource_handler.h" |
| 51 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 51 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 52 #include "chrome/browser/ssl/ssl_client_auth_handler.h" | 52 #include "chrome/browser/ssl/ssl_client_auth_handler.h" |
| 53 #include "chrome/browser/ssl/ssl_manager.h" | 53 #include "chrome/browser/ssl/ssl_manager.h" |
| 54 #include "chrome/browser/ui/login/login_prompt.h" | 54 #include "chrome/browser/ui/login/login_prompt.h" |
| 55 #include "chrome/browser/worker_host/worker_service.h" | 55 #include "chrome/browser/worker_host/worker_service.h" |
| 56 #include "chrome/common/chrome_switches.h" | 56 #include "chrome/common/chrome_switches.h" |
| 57 #include "chrome/common/notification_service.h" |
| 57 #include "chrome/common/render_messages.h" | 58 #include "chrome/common/render_messages.h" |
| 58 #include "chrome/common/render_messages_params.h" | 59 #include "chrome/common/render_messages_params.h" |
| 59 #include "chrome/common/url_constants.h" | 60 #include "chrome/common/url_constants.h" |
| 60 #include "net/base/auth.h" | 61 #include "net/base/auth.h" |
| 61 #include "net/base/cert_status_flags.h" | 62 #include "net/base/cert_status_flags.h" |
| 62 #include "net/base/load_flags.h" | 63 #include "net/base/load_flags.h" |
| 63 #include "net/base/mime_util.h" | 64 #include "net/base/mime_util.h" |
| 64 #include "net/base/net_errors.h" | 65 #include "net/base/net_errors.h" |
| 65 #include "net/base/request_priority.h" | 66 #include "net/base/request_priority.h" |
| 66 #include "net/base/ssl_cert_request_info.h" | 67 #include "net/base/ssl_cert_request_info.h" |
| (...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 void ResourceDispatcherHost::NotifyResponseStarted(net::URLRequest* request, | 1565 void ResourceDispatcherHost::NotifyResponseStarted(net::URLRequest* request, |
| 1565 int child_id) { | 1566 int child_id) { |
| 1566 // Notify the observers on the IO thread. | 1567 // Notify the observers on the IO thread. |
| 1567 FOR_EACH_OBSERVER(Observer, observer_list_, OnRequestStarted(this, request)); | 1568 FOR_EACH_OBSERVER(Observer, observer_list_, OnRequestStarted(this, request)); |
| 1568 | 1569 |
| 1569 int render_process_id, render_view_id; | 1570 int render_process_id, render_view_id; |
| 1570 if (!RenderViewForRequest(request, &render_process_id, &render_view_id)) | 1571 if (!RenderViewForRequest(request, &render_process_id, &render_view_id)) |
| 1571 return; | 1572 return; |
| 1572 | 1573 |
| 1573 // Notify the observers on the UI thread. | 1574 // Notify the observers on the UI thread. |
| 1574 CallRenderViewHostResourceDelegate( | 1575 ResourceRequestDetails* detail = new ResourceRequestDetails( |
| 1575 render_process_id, render_view_id, | 1576 request, GetCertID(request, child_id)); |
| 1576 &RenderViewHostDelegate::Resource::DidStartReceivingResourceResponse, | 1577 BrowserThread::PostTask( |
| 1577 ResourceRequestDetails(request, GetCertID(request, child_id))); | 1578 BrowserThread::UI, FROM_HERE, |
| 1579 NewRunnableFunction( |
| 1580 &ResourceDispatcherHost::NotifyOnUI<ResourceRequestDetails>, |
| 1581 NotificationType::RESOURCE_RESPONSE_STARTED, |
| 1582 render_process_id, render_view_id, detail)); |
| 1578 } | 1583 } |
| 1579 | 1584 |
| 1580 void ResourceDispatcherHost::NotifyResponseCompleted(net::URLRequest* request, | 1585 void ResourceDispatcherHost::NotifyResponseCompleted(net::URLRequest* request, |
| 1581 int child_id) { | 1586 int child_id) { |
| 1582 // Notify the observers on the IO thread. | 1587 // Notify the observers on the IO thread. |
| 1583 FOR_EACH_OBSERVER(Observer, observer_list_, | 1588 FOR_EACH_OBSERVER(Observer, observer_list_, |
| 1584 OnResponseCompleted(this, request)); | 1589 OnResponseCompleted(this, request)); |
| 1585 } | 1590 } |
| 1586 | 1591 |
| 1587 void ResourceDispatcherHost::NotifyReceivedRedirect(net::URLRequest* request, | 1592 void ResourceDispatcherHost::NotifyReceivedRedirect(net::URLRequest* request, |
| 1588 int child_id, | 1593 int child_id, |
| 1589 const GURL& new_url) { | 1594 const GURL& new_url) { |
| 1590 // Notify the observers on the IO thread. | 1595 // Notify the observers on the IO thread. |
| 1591 FOR_EACH_OBSERVER(Observer, observer_list_, | 1596 FOR_EACH_OBSERVER(Observer, observer_list_, |
| 1592 OnReceivedRedirect(this, request, new_url)); | 1597 OnReceivedRedirect(this, request, new_url)); |
| 1593 | 1598 |
| 1594 int render_process_id, render_view_id; | 1599 int render_process_id, render_view_id; |
| 1595 if (!RenderViewForRequest(request, &render_process_id, &render_view_id)) | 1600 if (!RenderViewForRequest(request, &render_process_id, &render_view_id)) |
| 1596 return; | 1601 return; |
| 1597 | 1602 |
| 1598 // Notify the observers on the UI thread. | 1603 // Notify the observers on the UI thread. |
| 1599 CallRenderViewHostResourceDelegate( | 1604 ResourceRedirectDetails* detail = new ResourceRedirectDetails( |
| 1600 render_process_id, render_view_id, | 1605 request, GetCertID(request, child_id), new_url); |
| 1601 &RenderViewHostDelegate::Resource::DidRedirectResource, | 1606 BrowserThread::PostTask( |
| 1602 ResourceRedirectDetails(request, GetCertID(request, child_id), new_url)); | 1607 BrowserThread::UI, FROM_HERE, |
| 1608 NewRunnableFunction( |
| 1609 &ResourceDispatcherHost::NotifyOnUI<ResourceRedirectDetails>, |
| 1610 NotificationType::RESOURCE_RECEIVED_REDIRECT, |
| 1611 render_process_id, render_view_id, detail)); |
| 1612 } |
| 1613 |
| 1614 template <class T> |
| 1615 void ResourceDispatcherHost::NotifyOnUI(NotificationType type, |
| 1616 int render_process_id, |
| 1617 int render_view_id, |
| 1618 T* detail) { |
| 1619 RenderViewHost* rvh = |
| 1620 RenderViewHost::FromID(render_process_id, render_view_id); |
| 1621 if (!rvh) |
| 1622 return; |
| 1623 RenderViewHostDelegate* rvhd = rvh->delegate(); |
| 1624 NotificationService::current()->Notify( |
| 1625 type, Source<RenderViewHostDelegate>(rvhd), Details<T>(detail)); |
| 1626 delete detail; |
| 1603 } | 1627 } |
| 1604 | 1628 |
| 1605 namespace { | 1629 namespace { |
| 1606 | 1630 |
| 1607 // This function attempts to return the "more interesting" load state of |a| | 1631 // This function attempts to return the "more interesting" load state of |a| |
| 1608 // and |b|. We don't have temporal information about these load states | 1632 // and |b|. We don't have temporal information about these load states |
| 1609 // (meaning we don't know when we transitioned into these states), so we just | 1633 // (meaning we don't know when we transitioned into these states), so we just |
| 1610 // rank them according to how "interesting" the states are. | 1634 // rank them according to how "interesting" the states are. |
| 1611 // | 1635 // |
| 1612 // We take advantage of the fact that the load states are an enumeration listed | 1636 // We take advantage of the fact that the load states are an enumeration listed |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1889 return is_prefetch_enabled_; | 1913 return is_prefetch_enabled_; |
| 1890 } | 1914 } |
| 1891 | 1915 |
| 1892 // static | 1916 // static |
| 1893 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { | 1917 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { |
| 1894 is_prefetch_enabled_ = value; | 1918 is_prefetch_enabled_ = value; |
| 1895 } | 1919 } |
| 1896 | 1920 |
| 1897 // static | 1921 // static |
| 1898 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; | 1922 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; |
| OLD | NEW |