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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/favicon/favicon_tab_helper.h" | 14 #include "chrome/browser/favicon/favicon_tab_helper.h" |
15 #include "chrome/browser/prerender/prerender_contents.h" | 15 #include "chrome/browser/prerender/prerender_contents.h" |
16 #include "chrome/browser/prerender/prerender_final_status.h" | 16 #include "chrome/browser/prerender/prerender_final_status.h" |
| 17 #include "chrome/browser/prerender/prerender_observer.h" |
17 #include "chrome/browser/prerender/prerender_tracker.h" | 18 #include "chrome/browser/prerender/prerender_tracker.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" |
21 #include "chrome/common/render_messages.h" | 22 #include "chrome/common/render_messages.h" |
22 #include "content/browser/browser_thread.h" | 23 #include "content/browser/browser_thread.h" |
23 #include "content/browser/renderer_host/render_view_host.h" | 24 #include "content/browser/renderer_host/render_view_host.h" |
24 #include "content/browser/renderer_host/render_process_host.h" | 25 #include "content/browser/renderer_host/render_process_host.h" |
25 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 26 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
26 #include "content/browser/tab_contents/render_view_host_manager.h" | 27 #include "content/browser/tab_contents/render_view_host_manager.h" |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 | 602 |
602 GURL icon_url = prerender_contents->icon_url(); | 603 GURL icon_url = prerender_contents->icon_url(); |
603 if (!icon_url.is_empty()) { | 604 if (!icon_url.is_empty()) { |
604 std::vector<FaviconURL> urls; | 605 std::vector<FaviconURL> urls; |
605 urls.push_back(FaviconURL(icon_url, FaviconURL::FAVICON)); | 606 urls.push_back(FaviconURL(icon_url, FaviconURL::FAVICON)); |
606 new_tab_contents->favicon_tab_helper()->OnUpdateFaviconURL( | 607 new_tab_contents->favicon_tab_helper()->OnUpdateFaviconURL( |
607 prerender_contents->page_id(), | 608 prerender_contents->page_id(), |
608 urls); | 609 urls); |
609 } | 610 } |
610 | 611 |
| 612 // Update PPLT metrics: |
| 613 // If the tab has finished loading, record a PPLT of 0. |
| 614 // If the tab is still loading, reset its start time to the current time. |
| 615 PrerenderObserver* prerender_observer = |
| 616 new_tab_contents->prerender_observer(); |
| 617 DCHECK(prerender_observer != NULL); |
| 618 prerender_observer->PrerenderSwappedIn(); |
| 619 |
611 // See if we have any pending prerender requests for this routing id and start | 620 // See if we have any pending prerender requests for this routing id and start |
612 // the preload if we do. | 621 // the preload if we do. |
613 std::pair<int, int> child_route_pair = std::make_pair(child_id, route_id); | 622 std::pair<int, int> child_route_pair = std::make_pair(child_id, route_id); |
614 PendingPrerenderList::iterator pending_it = | 623 PendingPrerenderList::iterator pending_it = |
615 pending_prerender_list_.find(child_route_pair); | 624 pending_prerender_list_.find(child_route_pair); |
616 if (pending_it != pending_prerender_list_.end()) { | 625 if (pending_it != pending_prerender_list_.end()) { |
617 for (std::vector<PendingContentsData>::iterator content_it = | 626 for (std::vector<PendingContentsData>::iterator content_it = |
618 pending_it->second.begin(); | 627 pending_it->second.begin(); |
619 content_it != pending_it->second.end(); ++content_it) { | 628 content_it != pending_it->second.end(); ++content_it) { |
620 AddPreload(pending_it->first, content_it->url_, content_it->referrer_); | 629 AddPreload(pending_it->first, content_it->url_, content_it->referrer_); |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 base::TimeTicks cutoff = GetCurrentTimeTicks() - | 1009 base::TimeTicks cutoff = GetCurrentTimeTicks() - |
1001 base::TimeDelta::FromMilliseconds(kNavigationRecordWindowMs); | 1010 base::TimeDelta::FromMilliseconds(kNavigationRecordWindowMs); |
1002 while (!navigations_.empty()) { | 1011 while (!navigations_.empty()) { |
1003 if (navigations_.front().time_ > cutoff) | 1012 if (navigations_.front().time_ > cutoff) |
1004 break; | 1013 break; |
1005 navigations_.pop_front(); | 1014 navigations_.pop_front(); |
1006 } | 1015 } |
1007 } | 1016 } |
1008 | 1017 |
1009 } // namespace prerender | 1018 } // namespace prerender |
OLD | NEW |