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_contents.h" | 5 #include "chrome/browser/prerender/prerender_contents.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 has_finished_loading_(false), | 215 has_finished_loading_(false), |
216 final_status_(FINAL_STATUS_MAX), | 216 final_status_(FINAL_STATUS_MAX), |
217 match_complete_status_(MATCH_COMPLETE_DEFAULT), | 217 match_complete_status_(MATCH_COMPLETE_DEFAULT), |
218 prerendering_has_been_cancelled_(false), | 218 prerendering_has_been_cancelled_(false), |
219 child_id_(-1), | 219 child_id_(-1), |
220 route_id_(-1), | 220 route_id_(-1), |
221 origin_(origin), | 221 origin_(origin), |
222 experiment_id_(experiment_id), | 222 experiment_id_(experiment_id), |
223 creator_child_id_(-1), | 223 creator_child_id_(-1), |
224 main_frame_id_(0), | 224 main_frame_id_(0), |
225 cookie_status_(0) { | 225 cookie_status_(0), |
| 226 network_bytes_(0) { |
226 DCHECK(prerender_manager != NULL); | 227 DCHECK(prerender_manager != NULL); |
227 } | 228 } |
228 | 229 |
229 PrerenderContents* PrerenderContents::CreateMatchCompleteReplacement() { | 230 PrerenderContents* PrerenderContents::CreateMatchCompleteReplacement() { |
230 PrerenderContents* new_contents = prerender_manager_->CreatePrerenderContents( | 231 PrerenderContents* new_contents = prerender_manager_->CreatePrerenderContents( |
231 prerender_url(), referrer(), origin(), experiment_id()); | 232 prerender_url(), referrer(), origin(), experiment_id()); |
232 | 233 |
233 new_contents->load_start_time_ = load_start_time_; | 234 new_contents->load_start_time_ = load_start_time_; |
234 new_contents->session_storage_namespace_id_ = session_storage_namespace_id_; | 235 new_contents->session_storage_namespace_id_ = session_storage_namespace_id_; |
235 new_contents->set_match_complete_status( | 236 new_contents->set_match_complete_status( |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 if (prerendering_has_started_ && | 391 if (prerendering_has_started_ && |
391 (final_status() == FINAL_STATUS_USED || | 392 (final_status() == FINAL_STATUS_USED || |
392 final_status() == FINAL_STATUS_TIMED_OUT || | 393 final_status() == FINAL_STATUS_TIMED_OUT || |
393 final_status() == FINAL_STATUS_CANCELLED)) { | 394 final_status() == FINAL_STATUS_CANCELLED)) { |
394 prerender_manager_->RecordCookieStatus(origin(), experiment_id(), | 395 prerender_manager_->RecordCookieStatus(origin(), experiment_id(), |
395 cookie_status_); | 396 cookie_status_); |
396 } | 397 } |
397 prerender_manager_->RecordFinalStatusWithMatchCompleteStatus( | 398 prerender_manager_->RecordFinalStatusWithMatchCompleteStatus( |
398 origin(), experiment_id(), match_complete_status(), final_status()); | 399 origin(), experiment_id(), match_complete_status(), final_status()); |
399 | 400 |
| 401 bool used = final_status() == FINAL_STATUS_USED || |
| 402 final_status() == FINAL_STATUS_WOULD_HAVE_BEEN_USED; |
| 403 prerender_manager_->RecordBytes(used, network_bytes_); |
| 404 |
400 // Broadcast the removal of aliases. | 405 // Broadcast the removal of aliases. |
401 for (content::RenderProcessHost::iterator host_iterator = | 406 for (content::RenderProcessHost::iterator host_iterator = |
402 content::RenderProcessHost::AllHostsIterator(); | 407 content::RenderProcessHost::AllHostsIterator(); |
403 !host_iterator.IsAtEnd(); | 408 !host_iterator.IsAtEnd(); |
404 host_iterator.Advance()) { | 409 host_iterator.Advance()) { |
405 content::RenderProcessHost* host = host_iterator.GetCurrentValue(); | 410 content::RenderProcessHost* host = host_iterator.GetCurrentValue(); |
406 host->Send(new PrerenderMsg_OnPrerenderRemoveAliases(alias_urls_)); | 411 host->Send(new PrerenderMsg_OnPrerenderRemoveAliases(alias_urls_)); |
407 } | 412 } |
408 | 413 |
409 // If we still have a WebContents, clean up anything we need to and then | 414 // If we still have a WebContents, clean up anything we need to and then |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 | 839 |
835 DCHECK_GE(cookie_status_, 0); | 840 DCHECK_GE(cookie_status_, 0); |
836 DCHECK_LT(cookie_status_, kNumCookieStatuses); | 841 DCHECK_LT(cookie_status_, kNumCookieStatuses); |
837 } | 842 } |
838 | 843 |
839 void PrerenderContents::AddResourceThrottle( | 844 void PrerenderContents::AddResourceThrottle( |
840 const base::WeakPtr<PrerenderResourceThrottle>& throttle) { | 845 const base::WeakPtr<PrerenderResourceThrottle>& throttle) { |
841 resource_throttles_.push_back(throttle); | 846 resource_throttles_.push_back(throttle); |
842 } | 847 } |
843 | 848 |
| 849 void PrerenderContents::AddNetworkBytes(int64 bytes) { |
| 850 network_bytes_ += bytes; |
| 851 } |
| 852 |
844 } // namespace prerender | 853 } // namespace prerender |
OLD | NEW |