Chromium Code Reviews| 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/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 autofill_manager_(), | 368 autofill_manager_(), |
| 369 plugin_installer_(), | 369 plugin_installer_(), |
| 370 bookmark_drag_(NULL), | 370 bookmark_drag_(NULL), |
| 371 ALLOW_THIS_IN_INITIALIZER_LIST(fav_icon_helper_(this)), | 371 ALLOW_THIS_IN_INITIALIZER_LIST(fav_icon_helper_(this)), |
| 372 is_loading_(false), | 372 is_loading_(false), |
| 373 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 373 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 374 crashed_error_code_(0), | 374 crashed_error_code_(0), |
| 375 waiting_for_response_(false), | 375 waiting_for_response_(false), |
| 376 max_page_id_(-1), | 376 max_page_id_(-1), |
| 377 current_load_start_(), | 377 current_load_start_(), |
| 378 pplt_load_start_(), | |
| 378 load_state_(net::LOAD_STATE_IDLE), | 379 load_state_(net::LOAD_STATE_IDLE), |
| 379 load_state_host_(), | 380 load_state_host_(), |
| 380 upload_size_(0), | 381 upload_size_(0), |
| 381 upload_position_(0), | 382 upload_position_(0), |
| 382 received_page_title_(false), | 383 received_page_title_(false), |
| 383 is_starred_(false), | 384 is_starred_(false), |
| 384 contents_mime_type_(), | 385 contents_mime_type_(), |
| 385 encoding_(), | 386 encoding_(), |
| 386 blocked_contents_(NULL), | 387 blocked_contents_(NULL), |
| 387 all_contents_blocked_(false), | 388 all_contents_blocked_(false), |
| (...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1647 | 1648 |
| 1648 ProvisionalLoadDetails details( | 1649 ProvisionalLoadDetails details( |
| 1649 is_main_frame, | 1650 is_main_frame, |
| 1650 controller_.IsURLInPageNavigation(validated_url), | 1651 controller_.IsURLInPageNavigation(validated_url), |
| 1651 validated_url, std::string(), false, is_error_page, frame_id); | 1652 validated_url, std::string(), false, is_error_page, frame_id); |
| 1652 NotificationService::current()->Notify( | 1653 NotificationService::current()->Notify( |
| 1653 NotificationType::FRAME_PROVISIONAL_LOAD_START, | 1654 NotificationType::FRAME_PROVISIONAL_LOAD_START, |
| 1654 Source<NavigationController>(&controller_), | 1655 Source<NavigationController>(&controller_), |
| 1655 Details<ProvisionalLoadDetails>(&details)); | 1656 Details<ProvisionalLoadDetails>(&details)); |
| 1656 if (is_main_frame) { | 1657 if (is_main_frame) { |
| 1658 // Record the beginning of a new PPLT navigation. | |
| 1659 pplt_load_start_ = base::TimeTicks::Now(); | |
| 1660 | |
| 1657 // If we're displaying a network error page do not reset the content | 1661 // If we're displaying a network error page do not reset the content |
| 1658 // settings delegate's cookies so the user has a chance to modify cookie | 1662 // settings delegate's cookies so the user has a chance to modify cookie |
| 1659 // settings. | 1663 // settings. |
| 1660 if (!is_error_page) | 1664 if (!is_error_page) |
| 1661 content_settings_delegate_->ClearCookieSpecificContentSettings(); | 1665 content_settings_delegate_->ClearCookieSpecificContentSettings(); |
| 1662 content_settings_delegate_->ClearGeolocationContentSettings(); | 1666 content_settings_delegate_->ClearGeolocationContentSettings(); |
| 1663 | 1667 |
| 1664 // Check if the URL we are about to load has been prerendered by any chance, | 1668 // Check if the URL we are about to load has been prerendered by any chance, |
| 1665 // and use it if possible. | 1669 // and use it if possible. |
| 1666 MaybeUsePreloadedPage(url); | 1670 MaybeUsePreloadedPage(url); |
| (...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2807 details.reset(new LoadNotificationDetails( | 2811 details.reset(new LoadNotificationDetails( |
| 2808 entry->virtual_url(), | 2812 entry->virtual_url(), |
| 2809 entry->transition_type(), | 2813 entry->transition_type(), |
| 2810 elapsed, | 2814 elapsed, |
| 2811 &controller_, | 2815 &controller_, |
| 2812 controller_.GetCurrentEntryIndex())); | 2816 controller_.GetCurrentEntryIndex())); |
| 2813 } | 2817 } |
| 2814 | 2818 |
| 2815 SetIsLoading(false, details.get()); | 2819 SetIsLoading(false, details.get()); |
| 2816 | 2820 |
| 2821 // Compute the PPLT metric and report it in a histogram, if needed. | |
| 2822 PrerenderManager* pm = profile()->GetPrerenderManager(); | |
|
cbentzel
2011/01/26 19:38:36
Can you move this into PrerenderManager or Prerend
tburkard
2011/01/26 20:05:50
Done.
| |
| 2823 if (pm != NULL && !pplt_load_start_.is_null() && | |
| 2824 (pm->mode() == PrerenderManager::kExperimentControlGroup || | |
| 2825 pm->mode() == PrerenderManager::kExperimentPrerenderGroup)) { | |
| 2826 base::TimeDelta elapsed = base::TimeTicks::Now() - pplt_load_start_; | |
| 2827 if (pm->mode() == PrerenderManager::kExperimentControlGroup) { | |
| 2828 UMA_HISTOGRAM_TIMES("PLT.PerceivedPageLoadTime_PrerenderControl", | |
| 2829 elapsed); | |
| 2830 } else { | |
| 2831 UMA_HISTOGRAM_TIMES("PLT.PerceivedPageLoadTime_PrerenderTreatment", | |
| 2832 elapsed); | |
| 2833 } | |
| 2834 } | |
| 2835 | |
| 2836 // Reset the PPLT metric. | |
| 2837 pplt_load_start_ = base::TimeTicks(); | |
| 2838 | |
| 2817 // Notify observers about navigation. | 2839 // Notify observers about navigation. |
| 2818 FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_, | 2840 FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_, |
| 2819 DidStopLoading()); | 2841 DidStopLoading()); |
| 2820 } | 2842 } |
| 2821 | 2843 |
| 2822 void TabContents::DidChangeLoadProgress(double progress) { | 2844 void TabContents::DidChangeLoadProgress(double progress) { |
| 2823 if (delegate()) | 2845 if (delegate()) |
| 2824 delegate()->LoadProgressChanged(progress); | 2846 delegate()->LoadProgressChanged(progress); |
| 2825 } | 2847 } |
| 2826 | 2848 |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3386 } | 3408 } |
| 3387 | 3409 |
| 3388 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 3410 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 3389 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 3411 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 3390 rwh_view->SetSize(view()->GetContainerSize()); | 3412 rwh_view->SetSize(view()->GetContainerSize()); |
| 3391 } | 3413 } |
| 3392 | 3414 |
| 3393 bool TabContents::MaybeUsePreloadedPage(const GURL& url) { | 3415 bool TabContents::MaybeUsePreloadedPage(const GURL& url) { |
| 3394 PrerenderManager* pm = profile()->GetPrerenderManager(); | 3416 PrerenderManager* pm = profile()->GetPrerenderManager(); |
| 3395 if (pm != NULL) { | 3417 if (pm != NULL) { |
| 3396 if (pm->MaybeUsePreloadedPage(this, url)) { | 3418 if (pm->MaybeUsePreloadedPage(this, url)) |
| 3397 // TODO(tburkard): If the preloaded page has not finished preloading | |
| 3398 // yet, we should not do this. | |
| 3399 DidStopLoading(); | |
| 3400 return true; | 3419 return true; |
| 3401 } | |
| 3402 } | 3420 } |
| 3403 return false; | 3421 return false; |
| 3404 } | 3422 } |
| OLD | NEW |