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 #include "chrome/browser/prerender/prerender_manager.h" | 5 #include "chrome/browser/prerender/prerender_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 bool should_replace_current_entry) | 1120 bool should_replace_current_entry) |
1121 : content::WebContentsObserver(target_contents), | 1121 : content::WebContentsObserver(target_contents), |
1122 manager_(manager), | 1122 manager_(manager), |
1123 target_contents_(target_contents), | 1123 target_contents_(target_contents), |
1124 prerender_data_(prerender_data), | 1124 prerender_data_(prerender_data), |
1125 url_(url), | 1125 url_(url), |
1126 should_replace_current_entry_(should_replace_current_entry), | 1126 should_replace_current_entry_(should_replace_current_entry), |
1127 start_time_(base::TimeTicks::Now()), | 1127 start_time_(base::TimeTicks::Now()), |
1128 swap_successful_(false), | 1128 swap_successful_(false), |
1129 weak_factory_(this) { | 1129 weak_factory_(this) { |
1130 // Record the RFH id in the tracker to install throttles on MAIN_FRAME | 1130 RenderViewCreated(target_contents->GetRenderViewHost()); |
1131 // requests from that route. | |
1132 int render_process_id = | |
1133 target_contents->GetMainFrame()->GetProcess()->GetID(); | |
1134 int render_frame_id = target_contents->GetMainFrame()->GetRoutingID(); | |
1135 render_frame_route_id_pair_ = PrerenderTracker::ChildRouteIdPair( | |
1136 render_process_id, render_frame_id); | |
1137 manager_->prerender_tracker()->AddPrerenderPendingSwap( | |
1138 render_frame_route_id_pair_, url_); | |
1139 } | 1131 } |
1140 | 1132 |
1141 PrerenderManager::PendingSwap::~PendingSwap() { | 1133 PrerenderManager::PendingSwap::~PendingSwap() { |
1142 manager_->prerender_tracker()->RemovePrerenderPendingSwap( | 1134 for (size_t i = 0; i < main_rfh_ids_.size(); i++) { |
1143 render_frame_route_id_pair_, swap_successful_); | 1135 manager_->prerender_tracker()->RemovePrerenderPendingSwap( |
| 1136 main_rfh_ids_[i], swap_successful_); |
| 1137 } |
1144 } | 1138 } |
1145 | 1139 |
1146 void PrerenderManager::PendingSwap::BeginSwap() { | 1140 void PrerenderManager::PendingSwap::BeginSwap() { |
1147 SessionStorageNamespace* target_namespace = | 1141 SessionStorageNamespace* target_namespace = |
1148 target_contents_->GetController().GetDefaultSessionStorageNamespace(); | 1142 target_contents_->GetController().GetDefaultSessionStorageNamespace(); |
1149 SessionStorageNamespace* prerender_namespace = | 1143 SessionStorageNamespace* prerender_namespace = |
1150 prerender_data_->contents()->GetSessionStorageNamespace(); | 1144 prerender_data_->contents()->GetSessionStorageNamespace(); |
1151 | 1145 |
1152 prerender_namespace->Merge( | 1146 prerender_namespace->Merge( |
1153 true, prerender_data_->contents()->child_id(), | 1147 true, prerender_data_->contents()->child_id(), |
(...skipping 24 matching lines...) Expand all Loading... |
1178 const base::string16& frame_unique_name, | 1172 const base::string16& frame_unique_name, |
1179 bool is_main_frame, | 1173 bool is_main_frame, |
1180 const GURL& validated_url, | 1174 const GURL& validated_url, |
1181 content::PageTransition transition_type, | 1175 content::PageTransition transition_type, |
1182 content::RenderViewHost* render_view_host){ | 1176 content::RenderViewHost* render_view_host){ |
1183 if (!is_main_frame) | 1177 if (!is_main_frame) |
1184 return; | 1178 return; |
1185 prerender_data_->ClearPendingSwap(); | 1179 prerender_data_->ClearPendingSwap(); |
1186 } | 1180 } |
1187 | 1181 |
| 1182 void PrerenderManager::PendingSwap::RenderViewCreated( |
| 1183 content::RenderViewHost* render_view_host) { |
| 1184 // Record the RFH id in the tracker to install throttles on MAIN_FRAME |
| 1185 // requests from that route. |
| 1186 int render_process_id = |
| 1187 render_view_host->GetMainFrame()->GetProcess()->GetID(); |
| 1188 int render_frame_id = render_view_host->GetMainFrame()->GetRoutingID(); |
| 1189 PrerenderTracker::ChildRouteIdPair render_frame_route_id_pair( |
| 1190 render_process_id, render_frame_id); |
| 1191 main_rfh_ids_.push_back(render_frame_route_id_pair); |
| 1192 manager_->prerender_tracker()->AddPrerenderPendingSwap( |
| 1193 render_frame_route_id_pair, url_); |
| 1194 } |
| 1195 |
1188 void PrerenderManager::PendingSwap::DidFailProvisionalLoad( | 1196 void PrerenderManager::PendingSwap::DidFailProvisionalLoad( |
1189 int64 frame_id, | 1197 int64 frame_id, |
1190 const base::string16& frame_unique_name, | 1198 const base::string16& frame_unique_name, |
1191 bool is_main_frame, | 1199 bool is_main_frame, |
1192 const GURL& validated_url, | 1200 const GURL& validated_url, |
1193 int error_code, | 1201 int error_code, |
1194 const base::string16& error_description, | 1202 const base::string16& error_description, |
1195 content::RenderViewHost* render_view_host) { | 1203 content::RenderViewHost* render_view_host) { |
1196 if (!is_main_frame) | 1204 if (!is_main_frame) |
1197 return; | 1205 return; |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 earliest_create_date); | 1895 earliest_create_date); |
1888 } | 1896 } |
1889 | 1897 |
1890 void PrerenderManager::RecordCookieStatus(Origin origin, | 1898 void PrerenderManager::RecordCookieStatus(Origin origin, |
1891 uint8 experiment_id, | 1899 uint8 experiment_id, |
1892 int cookie_status) const { | 1900 int cookie_status) const { |
1893 histograms_->RecordCookieStatus(origin, experiment_id, cookie_status); | 1901 histograms_->RecordCookieStatus(origin, experiment_id, cookie_status); |
1894 } | 1902 } |
1895 | 1903 |
1896 } // namespace prerender | 1904 } // namespace prerender |
OLD | NEW |