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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 void PrerenderContents::Observer::OnPrerenderCreatedMatchCompleteReplacement( | 188 void PrerenderContents::Observer::OnPrerenderCreatedMatchCompleteReplacement( |
189 PrerenderContents* contents, PrerenderContents* replacement) { | 189 PrerenderContents* contents, PrerenderContents* replacement) { |
190 } | 190 } |
191 | 191 |
192 PrerenderContents::Observer::Observer() { | 192 PrerenderContents::Observer::Observer() { |
193 } | 193 } |
194 | 194 |
195 PrerenderContents::Observer::~Observer() { | 195 PrerenderContents::Observer::~Observer() { |
196 } | 196 } |
197 | 197 |
198 PrerenderContents::PendingPrerenderInfo::PendingPrerenderInfo( | 198 void PrerenderContents::PrepareForUse() { |
199 base::WeakPtr<PrerenderHandle> weak_prerender_handle, | 199 SetFinalStatus(FINAL_STATUS_USED); |
200 Origin origin, | |
201 const GURL& url, | |
202 const content::Referrer& referrer, | |
203 const gfx::Size& size) | |
204 : weak_prerender_handle(weak_prerender_handle), | |
205 origin(origin), | |
206 url(url), | |
207 referrer(referrer), | |
208 size(size) { | |
209 } | |
210 | 200 |
211 PrerenderContents::PendingPrerenderInfo::~PendingPrerenderInfo() { | |
212 } | |
213 | |
214 void PrerenderContents::AddPendingPrerender( | |
215 scoped_ptr<PendingPrerenderInfo> pending_prerender_info) { | |
216 pending_prerenders_.push_back(pending_prerender_info.release()); | |
217 } | |
218 | |
219 void PrerenderContents::PrepareForUse() { | |
220 if (prerender_contents_.get()) { | 201 if (prerender_contents_.get()) { |
221 prerender_contents_->SendToAllFrames( | 202 prerender_contents_->SendToAllFrames( |
222 new PrerenderMsg_SetIsPrerendering(MSG_ROUTING_NONE, false)); | 203 new PrerenderMsg_SetIsPrerendering(MSG_ROUTING_NONE, false)); |
223 } | 204 } |
224 | 205 |
225 NotifyPrerenderStop(); | 206 NotifyPrerenderStop(); |
226 | 207 |
227 SessionStorageNamespace* session_storage_namespace = NULL; | |
228 if (prerender_contents_) { | |
229 // TODO(ajwong): This does not correctly handle storage for isolated apps. | |
230 session_storage_namespace = prerender_contents_-> | |
231 GetController().GetDefaultSessionStorageNamespace(); | |
232 } | |
233 prerender_manager_->StartPendingPrerenders( | |
234 child_id_, &pending_prerenders_, session_storage_namespace); | |
235 pending_prerenders_.clear(); | |
236 | |
237 content::BrowserThread::PostTask( | 208 content::BrowserThread::PostTask( |
238 content::BrowserThread::IO, | 209 content::BrowserThread::IO, |
239 FROM_HERE, | 210 FROM_HERE, |
240 base::Bind(&ResumeThrottles, resource_throttles_)); | 211 base::Bind(&ResumeThrottles, resource_throttles_)); |
241 resource_throttles_.clear(); | 212 resource_throttles_.clear(); |
242 } | 213 } |
243 | 214 |
244 PrerenderContents::PrerenderContents( | 215 PrerenderContents::PrerenderContents( |
245 PrerenderManager* prerender_manager, | 216 PrerenderManager* prerender_manager, |
246 Profile* profile, | 217 Profile* profile, |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 default: | 474 default: |
504 NOTREACHED() << "Unexpected notification sent."; | 475 NOTREACHED() << "Unexpected notification sent."; |
505 break; | 476 break; |
506 } | 477 } |
507 } | 478 } |
508 | 479 |
509 void PrerenderContents::OnRenderViewHostCreated( | 480 void PrerenderContents::OnRenderViewHostCreated( |
510 RenderViewHost* new_render_view_host) { | 481 RenderViewHost* new_render_view_host) { |
511 } | 482 } |
512 | 483 |
513 size_t PrerenderContents::pending_prerender_count() const { | |
514 return pending_prerenders_.size(); | |
515 } | |
516 | |
517 WebContents* PrerenderContents::CreateWebContents( | 484 WebContents* PrerenderContents::CreateWebContents( |
518 SessionStorageNamespace* session_storage_namespace) { | 485 SessionStorageNamespace* session_storage_namespace) { |
519 // TODO(ajwong): Remove the temporary map once prerendering is aware of | 486 // TODO(ajwong): Remove the temporary map once prerendering is aware of |
520 // multiple session storage namespaces per tab. | 487 // multiple session storage namespaces per tab. |
521 content::SessionStorageNamespaceMap session_storage_namespace_map; | 488 content::SessionStorageNamespaceMap session_storage_namespace_map; |
522 session_storage_namespace_map[std::string()] = session_storage_namespace; | 489 session_storage_namespace_map[std::string()] = session_storage_namespace; |
523 return WebContents::CreateWithSessionStorage( | 490 return WebContents::CreateWithSessionStorage( |
524 WebContents::CreateParams(profile_), session_storage_namespace_map); | 491 WebContents::CreateParams(profile_), session_storage_namespace_map); |
525 } | 492 } |
526 | 493 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 DCHECK_GE(cookie_status_, 0); | 826 DCHECK_GE(cookie_status_, 0); |
860 DCHECK_LT(cookie_status_, kNumCookieStatuses); | 827 DCHECK_LT(cookie_status_, kNumCookieStatuses); |
861 } | 828 } |
862 | 829 |
863 void PrerenderContents::AddResourceThrottle( | 830 void PrerenderContents::AddResourceThrottle( |
864 const base::WeakPtr<PrerenderResourceThrottle>& throttle) { | 831 const base::WeakPtr<PrerenderResourceThrottle>& throttle) { |
865 resource_throttles_.push_back(throttle); | 832 resource_throttles_.push_back(throttle); |
866 } | 833 } |
867 | 834 |
868 } // namespace prerender | 835 } // namespace prerender |
OLD | NEW |