Chromium Code Reviews| 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() { |
|
gavinp
2014/01/30 19:58:49
Methods in .cc files should be in the same order a
davidben
2014/01/30 21:01:51
Yeah, a lot of this file is rather horrifically ou
| |
| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 } | 384 } |
| 414 | 385 |
| 415 bool PrerenderContents::GetRouteId(int* route_id) const { | 386 bool PrerenderContents::GetRouteId(int* route_id) const { |
| 416 CHECK(route_id); | 387 CHECK(route_id); |
| 417 DCHECK_GE(route_id_, -1); | 388 DCHECK_GE(route_id_, -1); |
| 418 *route_id = route_id_; | 389 *route_id = route_id_; |
| 419 return route_id_ != -1; | 390 return route_id_ != -1; |
| 420 } | 391 } |
| 421 | 392 |
| 422 void PrerenderContents::SetFinalStatus(FinalStatus final_status) { | 393 void PrerenderContents::SetFinalStatus(FinalStatus final_status) { |
| 423 DCHECK(final_status >= FINAL_STATUS_USED && final_status < FINAL_STATUS_MAX); | 394 DCHECK_GE(final_status, FINAL_STATUS_USED); |
| 424 DCHECK(final_status_ == FINAL_STATUS_MAX); | 395 DCHECK_LT(final_status, FINAL_STATUS_MAX); |
| 396 | |
| 397 DCHECK_EQ(FINAL_STATUS_MAX, final_status_); | |
| 425 | 398 |
| 426 final_status_ = final_status; | 399 final_status_ = final_status; |
| 427 } | 400 } |
| 428 | 401 |
| 429 PrerenderContents::~PrerenderContents() { | 402 PrerenderContents::~PrerenderContents() { |
| 430 DCHECK_NE(FINAL_STATUS_MAX, final_status()); | 403 DCHECK_NE(FINAL_STATUS_MAX, final_status()); |
| 431 DCHECK( | 404 DCHECK( |
| 432 prerendering_has_been_cancelled() || final_status() == FINAL_STATUS_USED); | 405 prerendering_has_been_cancelled() || final_status() == FINAL_STATUS_USED); |
| 433 DCHECK_NE(ORIGIN_MAX, origin()); | 406 DCHECK_NE(ORIGIN_MAX, origin()); |
| 434 // Since a lot of prerenders terminate before any meaningful cookie action | 407 // Since a lot of prerenders terminate before any meaningful cookie action |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 default: | 476 default: |
| 504 NOTREACHED() << "Unexpected notification sent."; | 477 NOTREACHED() << "Unexpected notification sent."; |
| 505 break; | 478 break; |
| 506 } | 479 } |
| 507 } | 480 } |
| 508 | 481 |
| 509 void PrerenderContents::OnRenderViewHostCreated( | 482 void PrerenderContents::OnRenderViewHostCreated( |
| 510 RenderViewHost* new_render_view_host) { | 483 RenderViewHost* new_render_view_host) { |
| 511 } | 484 } |
| 512 | 485 |
| 513 size_t PrerenderContents::pending_prerender_count() const { | |
|
gavinp
2014/01/30 19:58:49
Nice to get rid of this style violation.
| |
| 514 return pending_prerenders_.size(); | |
| 515 } | |
| 516 | |
| 517 WebContents* PrerenderContents::CreateWebContents( | 486 WebContents* PrerenderContents::CreateWebContents( |
| 518 SessionStorageNamespace* session_storage_namespace) { | 487 SessionStorageNamespace* session_storage_namespace) { |
| 519 // TODO(ajwong): Remove the temporary map once prerendering is aware of | 488 // TODO(ajwong): Remove the temporary map once prerendering is aware of |
| 520 // multiple session storage namespaces per tab. | 489 // multiple session storage namespaces per tab. |
| 521 content::SessionStorageNamespaceMap session_storage_namespace_map; | 490 content::SessionStorageNamespaceMap session_storage_namespace_map; |
| 522 session_storage_namespace_map[std::string()] = session_storage_namespace; | 491 session_storage_namespace_map[std::string()] = session_storage_namespace; |
| 523 return WebContents::CreateWithSessionStorage( | 492 return WebContents::CreateWithSessionStorage( |
| 524 WebContents::CreateParams(profile_), session_storage_namespace_map); | 493 WebContents::CreateParams(profile_), session_storage_namespace_map); |
| 525 } | 494 } |
| 526 | 495 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 859 DCHECK_GE(cookie_status_, 0); | 828 DCHECK_GE(cookie_status_, 0); |
| 860 DCHECK_LT(cookie_status_, kNumCookieStatuses); | 829 DCHECK_LT(cookie_status_, kNumCookieStatuses); |
| 861 } | 830 } |
| 862 | 831 |
| 863 void PrerenderContents::AddResourceThrottle( | 832 void PrerenderContents::AddResourceThrottle( |
| 864 const base::WeakPtr<PrerenderResourceThrottle>& throttle) { | 833 const base::WeakPtr<PrerenderResourceThrottle>& throttle) { |
| 865 resource_throttles_.push_back(throttle); | 834 resource_throttles_.push_back(throttle); |
| 866 } | 835 } |
| 867 | 836 |
| 868 } // namespace prerender | 837 } // namespace prerender |
| OLD | NEW |