| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 351 |
| 352 case OMNIBOX_HEURISTIC_EXACT_FULL: | 352 case OMNIBOX_HEURISTIC_EXACT_FULL: |
| 353 origin = ORIGIN_OMNIBOX_EXACT_FULL; | 353 origin = ORIGIN_OMNIBOX_EXACT_FULL; |
| 354 break; | 354 break; |
| 355 | 355 |
| 356 default: | 356 default: |
| 357 NOTREACHED(); | 357 NOTREACHED(); |
| 358 break; | 358 break; |
| 359 }; | 359 }; |
| 360 | 360 |
| 361 histograms_->RecordPrerenderFromOmnibox(); |
| 362 |
| 361 return AddPrerender(origin, std::make_pair(-1, -1), url, GURL(), | 363 return AddPrerender(origin, std::make_pair(-1, -1), url, GURL(), |
| 362 session_storage_namespace); | 364 session_storage_namespace); |
| 363 } | 365 } |
| 364 | 366 |
| 365 bool PrerenderManager::AddPrerender( | 367 bool PrerenderManager::AddPrerender( |
| 366 Origin origin, | 368 Origin origin, |
| 367 const std::pair<int, int>& child_route_id_pair, | 369 const std::pair<int, int>& child_route_id_pair, |
| 368 const GURL& url_arg, | 370 const GURL& url_arg, |
| 369 const GURL& referrer, | 371 const GURL& referrer, |
| 370 SessionStorageNamespace* session_storage_namespace) { | 372 SessionStorageNamespace* session_storage_namespace) { |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 | 641 |
| 640 if (!prerender_contents->load_start_time().is_null()) { | 642 if (!prerender_contents->load_start_time().is_null()) { |
| 641 histograms_->RecordTimeUntilUsed(GetCurrentTimeTicks() - | 643 histograms_->RecordTimeUntilUsed(GetCurrentTimeTicks() - |
| 642 prerender_contents->load_start_time(), | 644 prerender_contents->load_start_time(), |
| 643 config_.max_age); | 645 config_.max_age); |
| 644 } | 646 } |
| 645 | 647 |
| 646 histograms_->RecordPerSessionCount(++prerenders_per_session_count_); | 648 histograms_->RecordPerSessionCount(++prerenders_per_session_count_); |
| 647 prerender_contents->set_final_status(FINAL_STATUS_USED); | 649 prerender_contents->set_final_status(FINAL_STATUS_USED); |
| 648 | 650 |
| 651 histograms_->RecordOmniboxUsedPrerender(prerender_contents->origin()); |
| 652 |
| 649 new_render_view_host->Send( | 653 new_render_view_host->Send( |
| 650 new ChromeViewMsg_SetIsPrerendering(new_render_view_host->routing_id(), | 654 new ChromeViewMsg_SetIsPrerendering(new_render_view_host->routing_id(), |
| 651 false)); | 655 false)); |
| 652 | 656 |
| 653 TabContentsWrapper* new_tab_contents = | 657 TabContentsWrapper* new_tab_contents = |
| 654 prerender_contents->ReleasePrerenderContents(); | 658 prerender_contents->ReleasePrerenderContents(); |
| 655 TabContentsWrapper* old_tab_contents = | 659 TabContentsWrapper* old_tab_contents = |
| 656 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); | 660 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); |
| 657 DCHECK(new_tab_contents); | 661 DCHECK(new_tab_contents); |
| 658 DCHECK(old_tab_contents); | 662 DCHECK(old_tab_contents); |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 if (!render_process_host || !render_process_host->GetBrowserContext()) | 1154 if (!render_process_host || !render_process_host->GetBrowserContext()) |
| 1151 return NULL; | 1155 return NULL; |
| 1152 Profile* profile = Profile::FromBrowserContext( | 1156 Profile* profile = Profile::FromBrowserContext( |
| 1153 render_process_host->GetBrowserContext()); | 1157 render_process_host->GetBrowserContext()); |
| 1154 if (!profile) | 1158 if (!profile) |
| 1155 return NULL; | 1159 return NULL; |
| 1156 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile); | 1160 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile); |
| 1157 } | 1161 } |
| 1158 | 1162 |
| 1159 } // namespace prerender | 1163 } // namespace prerender |
| OLD | NEW |