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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 return net::IDLE; | 288 return net::IDLE; |
289 | 289 |
290 default: | 290 default: |
291 // When new resource types are added, their priority must be considered. | 291 // When new resource types are added, their priority must be considered. |
292 NOTREACHED(); | 292 NOTREACHED(); |
293 return net::LOW; | 293 return net::LOW; |
294 } | 294 } |
295 } | 295 } |
296 | 296 |
297 void OnSwapOutACKHelper(int render_process_id, int render_view_id) { | 297 void OnSwapOutACKHelper(int render_process_id, int render_view_id) { |
298 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id, | 298 RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(render_process_id, |
299 render_view_id); | 299 render_view_id); |
300 if (rvh) | 300 if (rvh) |
301 rvh->OnSwapOutACK(); | 301 rvh->OnSwapOutACK(); |
302 } | 302 } |
303 | 303 |
304 } // namespace | 304 } // namespace |
305 | 305 |
306 ResourceDispatcherHost* ResourceDispatcherHost::Get() { | 306 ResourceDispatcherHost* ResourceDispatcherHost::Get() { |
307 return g_resource_dispatcher_host; | 307 return g_resource_dispatcher_host; |
308 } | 308 } |
309 | 309 |
(...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 &ResourceDispatcherHost::NotifyOnUI<ResourceRedirectDetails>, | 2022 &ResourceDispatcherHost::NotifyOnUI<ResourceRedirectDetails>, |
2023 static_cast<int>(content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT), | 2023 static_cast<int>(content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT), |
2024 render_process_id, render_view_id, detail)); | 2024 render_process_id, render_view_id, detail)); |
2025 } | 2025 } |
2026 | 2026 |
2027 template <class T> | 2027 template <class T> |
2028 void ResourceDispatcherHost::NotifyOnUI(int type, | 2028 void ResourceDispatcherHost::NotifyOnUI(int type, |
2029 int render_process_id, | 2029 int render_process_id, |
2030 int render_view_id, | 2030 int render_view_id, |
2031 T* detail) { | 2031 T* detail) { |
2032 RenderViewHost* rvh = | 2032 RenderViewHostImpl* rvh = |
2033 RenderViewHost::FromID(render_process_id, render_view_id); | 2033 RenderViewHostImpl::FromID(render_process_id, render_view_id); |
2034 if (rvh) { | 2034 if (rvh) { |
2035 content::RenderViewHostDelegate* rvhd = rvh->delegate(); | 2035 content::RenderViewHostDelegate* rvhd = rvh->GetDelegate(); |
2036 content::NotificationService::current()->Notify( | 2036 content::NotificationService::current()->Notify( |
2037 type, content::Source<WebContents>(rvhd->GetAsWebContents()), | 2037 type, content::Source<WebContents>(rvhd->GetAsWebContents()), |
2038 content::Details<T>(detail)); | 2038 content::Details<T>(detail)); |
2039 } | 2039 } |
2040 delete detail; | 2040 delete detail; |
2041 } | 2041 } |
2042 | 2042 |
2043 namespace { | 2043 namespace { |
2044 | 2044 |
2045 // This function attempts to return the "more interesting" load state of |a| | 2045 // This function attempts to return the "more interesting" load state of |a| |
(...skipping 26 matching lines...) Expand all Loading... |
2072 }; | 2072 }; |
2073 | 2073 |
2074 // Map from ProcessID+ViewID pair to LoadState | 2074 // Map from ProcessID+ViewID pair to LoadState |
2075 typedef std::map<std::pair<int, int>, LoadInfo> LoadInfoMap; | 2075 typedef std::map<std::pair<int, int>, LoadInfo> LoadInfoMap; |
2076 | 2076 |
2077 // Used to marshal calls to LoadStateChanged from the IO to UI threads. We do | 2077 // Used to marshal calls to LoadStateChanged from the IO to UI threads. We do |
2078 // them all as a single callback to avoid spamming the UI thread. | 2078 // them all as a single callback to avoid spamming the UI thread. |
2079 void LoadInfoUpdateCallback(const LoadInfoMap& info_map) { | 2079 void LoadInfoUpdateCallback(const LoadInfoMap& info_map) { |
2080 LoadInfoMap::const_iterator i; | 2080 LoadInfoMap::const_iterator i; |
2081 for (i = info_map.begin(); i != info_map.end(); ++i) { | 2081 for (i = info_map.begin(); i != info_map.end(); ++i) { |
2082 RenderViewHost* view = | 2082 RenderViewHostImpl* view = |
2083 RenderViewHost::FromID(i->first.first, i->first.second); | 2083 RenderViewHostImpl::FromID(i->first.first, i->first.second); |
2084 if (view) // The view could be gone at this point. | 2084 if (view) // The view could be gone at this point. |
2085 view->LoadStateChanged(i->second.url, i->second.load_state, | 2085 view->LoadStateChanged(i->second.url, i->second.load_state, |
2086 i->second.upload_position, | 2086 i->second.upload_position, |
2087 i->second.upload_size); | 2087 i->second.upload_size); |
2088 } | 2088 } |
2089 } | 2089 } |
2090 | 2090 |
2091 } // namespace | 2091 } // namespace |
2092 | 2092 |
2093 void ResourceDispatcherHost::UpdateLoadStates() { | 2093 void ResourceDispatcherHost::UpdateLoadStates() { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2298 scoped_refptr<ResourceHandler> transferred_resource_handler( | 2298 scoped_refptr<ResourceHandler> transferred_resource_handler( |
2299 new DoomedResourceHandler(info->resource_handler())); | 2299 new DoomedResourceHandler(info->resource_handler())); |
2300 info->set_resource_handler(transferred_resource_handler.get()); | 2300 info->set_resource_handler(transferred_resource_handler.get()); |
2301 } | 2301 } |
2302 | 2302 |
2303 bool ResourceDispatcherHost::IsTransferredNavigation( | 2303 bool ResourceDispatcherHost::IsTransferredNavigation( |
2304 const content::GlobalRequestID& transferred_request_id) const { | 2304 const content::GlobalRequestID& transferred_request_id) const { |
2305 return transferred_navigations_.find(transferred_request_id) != | 2305 return transferred_navigations_.find(transferred_request_id) != |
2306 transferred_navigations_.end(); | 2306 transferred_navigations_.end(); |
2307 } | 2307 } |
OLD | NEW |