| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 #include "webkit/appcache/appcache_interfaces.h" | 83 #include "webkit/appcache/appcache_interfaces.h" |
| 84 #include "webkit/blob/blob_storage_controller.h" | 84 #include "webkit/blob/blob_storage_controller.h" |
| 85 #include "webkit/blob/shareable_file_reference.h" | 85 #include "webkit/blob/shareable_file_reference.h" |
| 86 | 86 |
| 87 using base::Time; | 87 using base::Time; |
| 88 using base::TimeDelta; | 88 using base::TimeDelta; |
| 89 using base::TimeTicks; | 89 using base::TimeTicks; |
| 90 using content::BrowserThread; | 90 using content::BrowserThread; |
| 91 using content::GlobalRequestID; | 91 using content::GlobalRequestID; |
| 92 using content::ResourceContext; | 92 using content::ResourceContext; |
| 93 using content::ResourceRequestInfo; |
| 93 using content::ResourceResponse; | 94 using content::ResourceResponse; |
| 94 using content::ResourceThrottle; | 95 using content::ResourceThrottle; |
| 95 using content::ThrottlingResourceHandler; | 96 using content::ThrottlingResourceHandler; |
| 96 using content::WebContents; | 97 using content::WebContents; |
| 97 using content::WorkerServiceImpl; | 98 using content::WorkerServiceImpl; |
| 98 using webkit_blob::ShareableFileReference; | 99 using webkit_blob::ShareableFileReference; |
| 99 | 100 |
| 100 // ---------------------------------------------------------------------------- | 101 // ---------------------------------------------------------------------------- |
| 101 | 102 |
| 102 namespace { | 103 namespace { |
| (...skipping 1807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1910 net::URLRequest* request) { | 1911 net::URLRequest* request) { |
| 1911 // Avoid writing this function twice by casting the const version. | 1912 // Avoid writing this function twice by casting the const version. |
| 1912 const net::URLRequest* const_request = request; | 1913 const net::URLRequest* const_request = request; |
| 1913 return const_cast<ResourceDispatcherHostRequestInfo*>( | 1914 return const_cast<ResourceDispatcherHostRequestInfo*>( |
| 1914 InfoForRequest(const_request)); | 1915 InfoForRequest(const_request)); |
| 1915 } | 1916 } |
| 1916 | 1917 |
| 1917 // static | 1918 // static |
| 1918 const ResourceDispatcherHostRequestInfo* ResourceDispatcherHost::InfoForRequest( | 1919 const ResourceDispatcherHostRequestInfo* ResourceDispatcherHost::InfoForRequest( |
| 1919 const net::URLRequest* request) { | 1920 const net::URLRequest* request) { |
| 1920 const ResourceDispatcherHostRequestInfo* info = | 1921 return static_cast<const ResourceDispatcherHostRequestInfo*>( |
| 1921 static_cast<const ResourceDispatcherHostRequestInfo*>( | 1922 ResourceRequestInfo::ForRequest(request)); |
| 1922 request->GetUserData(NULL)); | |
| 1923 return info; | |
| 1924 } | 1923 } |
| 1925 | 1924 |
| 1926 // static | 1925 // static |
| 1927 bool ResourceDispatcherHost::RenderViewForRequest( | 1926 bool ResourceDispatcherHost::RenderViewForRequest( |
| 1928 const net::URLRequest* request, | 1927 const net::URLRequest* request, |
| 1929 int* render_process_host_id, | 1928 int* render_process_id, |
| 1930 int* render_view_host_id) { | 1929 int* render_view_id) { |
| 1931 const ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1930 const ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); |
| 1932 if (!info) { | 1931 if (!info) { |
| 1933 *render_process_host_id = -1; | 1932 *render_process_id = -1; |
| 1934 *render_view_host_id = -1; | 1933 *render_view_id = -1; |
| 1935 return false; | 1934 return false; |
| 1936 } | 1935 } |
| 1937 | 1936 |
| 1938 // If the request is from the worker process, find a tab that owns the worker. | 1937 return info->GetAssociatedRenderView(render_process_id, render_view_id); |
| 1939 if (info->process_type() == content::PROCESS_TYPE_WORKER) { | |
| 1940 // Need to display some related UI for this network request - pick an | |
| 1941 // arbitrary parent to do so. | |
| 1942 if (!WorkerServiceImpl::GetInstance()->GetRendererForWorker( | |
| 1943 info->child_id(), render_process_host_id, render_view_host_id)) { | |
| 1944 *render_process_host_id = -1; | |
| 1945 *render_view_host_id = -1; | |
| 1946 return false; | |
| 1947 } | |
| 1948 } else { | |
| 1949 *render_process_host_id = info->child_id(); | |
| 1950 *render_view_host_id = info->route_id(); | |
| 1951 } | |
| 1952 return true; | |
| 1953 } | 1938 } |
| 1954 | 1939 |
| 1955 net::URLRequest* ResourceDispatcherHost::GetURLRequest( | 1940 net::URLRequest* ResourceDispatcherHost::GetURLRequest( |
| 1956 const GlobalRequestID& request_id) const { | 1941 const GlobalRequestID& request_id) const { |
| 1957 // This should be running in the IO loop. | 1942 // This should be running in the IO loop. |
| 1958 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1943 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1959 | 1944 |
| 1960 PendingRequestList::const_iterator i = pending_requests_.find(request_id); | 1945 PendingRequestList::const_iterator i = pending_requests_.find(request_id); |
| 1961 if (i == pending_requests_.end()) | 1946 if (i == pending_requests_.end()) |
| 1962 return NULL; | 1947 return NULL; |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2283 scoped_refptr<ResourceHandler> transferred_resource_handler( | 2268 scoped_refptr<ResourceHandler> transferred_resource_handler( |
| 2284 new DoomedResourceHandler(info->resource_handler())); | 2269 new DoomedResourceHandler(info->resource_handler())); |
| 2285 info->set_resource_handler(transferred_resource_handler.get()); | 2270 info->set_resource_handler(transferred_resource_handler.get()); |
| 2286 } | 2271 } |
| 2287 | 2272 |
| 2288 bool ResourceDispatcherHost::IsTransferredNavigation( | 2273 bool ResourceDispatcherHost::IsTransferredNavigation( |
| 2289 const content::GlobalRequestID& transferred_request_id) const { | 2274 const content::GlobalRequestID& transferred_request_id) const { |
| 2290 return transferred_navigations_.find(transferred_request_id) != | 2275 return transferred_navigations_.find(transferred_request_id) != |
| 2291 transferred_navigations_.end(); | 2276 transferred_navigations_.end(); |
| 2292 } | 2277 } |
| OLD | NEW |