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 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2007 &ResourceDispatcherHost::NotifyOnUI<ResourceRedirectDetails>, | 2007 &ResourceDispatcherHost::NotifyOnUI<ResourceRedirectDetails>, |
2008 static_cast<int>(content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT), | 2008 static_cast<int>(content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT), |
2009 render_process_id, render_view_id, detail)); | 2009 render_process_id, render_view_id, detail)); |
2010 } | 2010 } |
2011 | 2011 |
2012 template <class T> | 2012 template <class T> |
2013 void ResourceDispatcherHost::NotifyOnUI(int type, | 2013 void ResourceDispatcherHost::NotifyOnUI(int type, |
2014 int render_process_id, | 2014 int render_process_id, |
2015 int render_view_id, | 2015 int render_view_id, |
2016 T* detail) { | 2016 T* detail) { |
2017 RenderViewHost* rvh = | 2017 RenderViewHostImpl* rvh = |
2018 RenderViewHost::FromID(render_process_id, render_view_id); | 2018 RenderViewHostImpl::FromID(render_process_id, render_view_id); |
2019 if (rvh) { | 2019 if (rvh) { |
2020 content::RenderViewHostDelegate* rvhd = rvh->delegate(); | 2020 content::RenderViewHostDelegate* rvhd = rvh->GetDelegate(); |
2021 content::NotificationService::current()->Notify( | 2021 content::NotificationService::current()->Notify( |
2022 type, content::Source<WebContents>(rvhd->GetAsWebContents()), | 2022 type, content::Source<WebContents>(rvhd->GetAsWebContents()), |
2023 content::Details<T>(detail)); | 2023 content::Details<T>(detail)); |
2024 } | 2024 } |
2025 delete detail; | 2025 delete detail; |
2026 } | 2026 } |
2027 | 2027 |
2028 namespace { | 2028 namespace { |
2029 | 2029 |
2030 // This function attempts to return the "more interesting" load state of |a| | 2030 // This function attempts to return the "more interesting" load state of |a| |
(...skipping 26 matching lines...) Expand all Loading... |
2057 }; | 2057 }; |
2058 | 2058 |
2059 // Map from ProcessID+ViewID pair to LoadState | 2059 // Map from ProcessID+ViewID pair to LoadState |
2060 typedef std::map<std::pair<int, int>, LoadInfo> LoadInfoMap; | 2060 typedef std::map<std::pair<int, int>, LoadInfo> LoadInfoMap; |
2061 | 2061 |
2062 // Used to marshal calls to LoadStateChanged from the IO to UI threads. We do | 2062 // Used to marshal calls to LoadStateChanged from the IO to UI threads. We do |
2063 // them all as a single callback to avoid spamming the UI thread. | 2063 // them all as a single callback to avoid spamming the UI thread. |
2064 void LoadInfoUpdateCallback(const LoadInfoMap& info_map) { | 2064 void LoadInfoUpdateCallback(const LoadInfoMap& info_map) { |
2065 LoadInfoMap::const_iterator i; | 2065 LoadInfoMap::const_iterator i; |
2066 for (i = info_map.begin(); i != info_map.end(); ++i) { | 2066 for (i = info_map.begin(); i != info_map.end(); ++i) { |
2067 RenderViewHost* view = | 2067 RenderViewHostImpl* view = |
2068 RenderViewHost::FromID(i->first.first, i->first.second); | 2068 RenderViewHostImpl::FromID(i->first.first, i->first.second); |
2069 if (view) // The view could be gone at this point. | 2069 if (view) // The view could be gone at this point. |
2070 view->LoadStateChanged(i->second.url, i->second.load_state, | 2070 view->LoadStateChanged(i->second.url, i->second.load_state, |
2071 i->second.upload_position, | 2071 i->second.upload_position, |
2072 i->second.upload_size); | 2072 i->second.upload_size); |
2073 } | 2073 } |
2074 } | 2074 } |
2075 | 2075 |
2076 } // namespace | 2076 } // namespace |
2077 | 2077 |
2078 void ResourceDispatcherHost::UpdateLoadStates() { | 2078 void ResourceDispatcherHost::UpdateLoadStates() { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2283 scoped_refptr<ResourceHandler> transferred_resource_handler( | 2283 scoped_refptr<ResourceHandler> transferred_resource_handler( |
2284 new DoomedResourceHandler(info->resource_handler())); | 2284 new DoomedResourceHandler(info->resource_handler())); |
2285 info->set_resource_handler(transferred_resource_handler.get()); | 2285 info->set_resource_handler(transferred_resource_handler.get()); |
2286 } | 2286 } |
2287 | 2287 |
2288 bool ResourceDispatcherHost::IsTransferredNavigation( | 2288 bool ResourceDispatcherHost::IsTransferredNavigation( |
2289 const content::GlobalRequestID& transferred_request_id) const { | 2289 const content::GlobalRequestID& transferred_request_id) const { |
2290 return transferred_navigations_.find(transferred_request_id) != | 2290 return transferred_navigations_.find(transferred_request_id) != |
2291 transferred_navigations_.end(); | 2291 transferred_navigations_.end(); |
2292 } | 2292 } |
OLD | NEW |