OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/prerender/prerender_contents.h" | 10 #include "chrome/browser/prerender/prerender_contents.h" |
11 #include "chrome/browser/renderer_host/render_view_host.h" | |
11 #include "chrome/browser/tab_contents/tab_contents.h" | 12 #include "chrome/browser/tab_contents/tab_contents.h" |
12 #include "chrome/browser/tab_contents/render_view_host_manager.h" | 13 #include "chrome/browser/tab_contents/render_view_host_manager.h" |
14 #include "chrome/common/render_messages.h" | |
13 | 15 |
14 struct PrerenderManager::PrerenderContentsData { | 16 struct PrerenderManager::PrerenderContentsData { |
15 PrerenderContents* contents_; | 17 PrerenderContents* contents_; |
16 base::Time start_time_; | 18 base::Time start_time_; |
17 GURL url_; | 19 GURL url_; |
18 PrerenderContentsData(PrerenderContents* contents, | 20 PrerenderContentsData(PrerenderContents* contents, |
19 base::Time start_time, | 21 base::Time start_time, |
20 GURL url) | 22 GURL url) |
21 : contents_(contents), | 23 : contents_(contents), |
22 start_time_(start_time), | 24 start_time_(start_time), |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 } | 88 } |
87 | 89 |
88 bool PrerenderManager::MaybeUsePreloadedPage(TabContents* tc, const GURL& url) { | 90 bool PrerenderManager::MaybeUsePreloadedPage(TabContents* tc, const GURL& url) { |
89 DCHECK(CalledOnValidThread()); | 91 DCHECK(CalledOnValidThread()); |
90 scoped_ptr<PrerenderContents> pc(GetEntry(url)); | 92 scoped_ptr<PrerenderContents> pc(GetEntry(url)); |
91 if (pc.get() == NULL) | 93 if (pc.get() == NULL) |
92 return false; | 94 return false; |
93 | 95 |
94 RenderViewHost* rvh = pc->render_view_host(); | 96 RenderViewHost* rvh = pc->render_view_host(); |
95 pc->set_render_view_host(NULL); | 97 pc->set_render_view_host(NULL); |
98 rvh->Send(new ViewMsg_DisplayPrerenderedPage(rvh->routing_id())); | |
cbentzel
2011/01/20 19:46:59
Long term it _feels_ like this should go in the Pr
mmenke
2011/01/20 20:04:22
Hmm...Might make sense to have the PrerenderConten
| |
96 tc->SwapInRenderViewHost(rvh); | 99 tc->SwapInRenderViewHost(rvh); |
97 | 100 |
98 ViewHostMsg_FrameNavigate_Params* p = pc->navigate_params(); | 101 ViewHostMsg_FrameNavigate_Params* p = pc->navigate_params(); |
99 if (p != NULL) | 102 if (p != NULL) |
100 tc->DidNavigate(rvh, *p); | 103 tc->DidNavigate(rvh, *p); |
101 | 104 |
102 string16 title = pc->title(); | 105 string16 title = pc->title(); |
103 if (!title.empty()) | 106 if (!title.empty()) |
104 tc->UpdateTitle(rvh, pc->page_id(), UTF16ToWideHack(title)); | 107 tc->UpdateTitle(rvh, pc->page_id(), UTF16ToWideHack(title)); |
105 | 108 |
(...skipping 19 matching lines...) Expand all Loading... | |
125 } | 128 } |
126 | 129 |
127 bool PrerenderManager::IsPrerenderElementFresh(const base::Time start) const { | 130 bool PrerenderManager::IsPrerenderElementFresh(const base::Time start) const { |
128 base::Time now = GetCurrentTime(); | 131 base::Time now = GetCurrentTime(); |
129 return (now - start < max_prerender_age_); | 132 return (now - start < max_prerender_age_); |
130 } | 133 } |
131 | 134 |
132 PrerenderContents* PrerenderManager::CreatePrerenderContents(const GURL& url) { | 135 PrerenderContents* PrerenderManager::CreatePrerenderContents(const GURL& url) { |
133 return new PrerenderContents(this, profile_, url); | 136 return new PrerenderContents(this, profile_, url); |
134 } | 137 } |
OLD | NEW |