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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 if (prerender_manager_->IsControlGroup(experiment_id())) | 314 if (prerender_manager_->IsControlGroup(experiment_id())) |
| 315 return; | 315 return; |
| 316 | 316 |
| 317 if (origin_ == ORIGIN_LOCAL_PREDICTOR && | 317 if (origin_ == ORIGIN_LOCAL_PREDICTOR && |
| 318 IsLocalPredictorPrerenderAlwaysControlEnabled()) { | 318 IsLocalPredictorPrerenderAlwaysControlEnabled()) { |
| 319 return; | 319 return; |
| 320 } | 320 } |
| 321 | 321 |
| 322 prerendering_has_started_ = true; | 322 prerendering_has_started_ = true; |
| 323 | 323 |
| 324 alias_session_storage_namespace = session_storage_namespace->CreateAlias(); | 324 prerender_contents_.reset(CreateWebContents(session_storage_namespace)); |
| 325 prerender_contents_.reset( | |
| 326 CreateWebContents(alias_session_storage_namespace.get())); | |
| 327 TabHelpers::AttachTabHelpers(prerender_contents_.get()); | 325 TabHelpers::AttachTabHelpers(prerender_contents_.get()); |
| 328 content::WebContentsObserver::Observe(prerender_contents_.get()); | 326 content::WebContentsObserver::Observe(prerender_contents_.get()); |
| 329 | 327 |
| 330 web_contents_delegate_.reset(new WebContentsDelegateImpl(this)); | 328 web_contents_delegate_.reset(new WebContentsDelegateImpl(this)); |
| 331 prerender_contents_.get()->SetDelegate(web_contents_delegate_.get()); | 329 prerender_contents_.get()->SetDelegate(web_contents_delegate_.get()); |
| 332 // Set the size of the prerender WebContents. | 330 // Set the size of the prerender WebContents. |
| 333 ResizeWebContents(prerender_contents_.get(), size_); | 331 ResizeWebContents(prerender_contents_.get(), size_); |
| 334 | 332 |
| 335 child_id_ = GetRenderViewHost()->GetProcess()->GetID(); | 333 child_id_ = GetRenderViewHost()->GetProcess()->GetID(); |
| 336 route_id_ = GetRenderViewHost()->GetRoutingID(); | 334 route_id_ = GetRenderViewHost()->GetRoutingID(); |
| 337 | 335 |
| 338 // Log transactions to see if we could merge session storage namespaces in | |
| 339 // the event of a mismatch. | |
| 340 alias_session_storage_namespace->AddTransactionLogProcessId(child_id_); | |
| 341 | |
| 342 // Add the RenderProcessHost to the Prerender Manager. | 336 // Add the RenderProcessHost to the Prerender Manager. |
| 343 prerender_manager()->AddPrerenderProcessHost( | 337 prerender_manager()->AddPrerenderProcessHost( |
| 344 GetRenderViewHost()->GetProcess()); | 338 GetRenderViewHost()->GetProcess()); |
| 345 | 339 |
| 346 // In the prerender tracker, create a Prerender Cookie Store to keep track of | 340 // In the prerender tracker, create a Prerender Cookie Store to keep track of |
| 347 // cookie changes performed by the prerender. Once the prerender is shown, | 341 // cookie changes performed by the prerender. Once the prerender is shown, |
| 348 // the cookie changes will be committed to the actual cookie store, | 342 // the cookie changes will be committed to the actual cookie store, |
| 349 // otherwise, they will be discarded. | 343 // otherwise, they will be discarded. |
| 350 // If |request_context| is NULL, the feature must be disabled, so the | 344 // If |request_context| is NULL, the feature must be disabled, so the |
| 351 // operation will not be performed. | 345 // operation will not be performed. |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 content::RenderProcessHost* host = host_iterator.GetCurrentValue(); | 574 content::RenderProcessHost* host = host_iterator.GetCurrentValue(); |
| 581 host->Send(new PrerenderMsg_OnPrerenderAddAlias(url)); | 575 host->Send(new PrerenderMsg_OnPrerenderAddAlias(url)); |
| 582 } | 576 } |
| 583 | 577 |
| 584 return true; | 578 return true; |
| 585 } | 579 } |
| 586 | 580 |
| 587 bool PrerenderContents::Matches( | 581 bool PrerenderContents::Matches( |
| 588 const GURL& url, | 582 const GURL& url, |
| 589 const SessionStorageNamespace* session_storage_namespace) const { | 583 const SessionStorageNamespace* session_storage_namespace) const { |
| 590 if (session_storage_namespace && | 584 if (session_storage_namespace && |
|
mmenke
2014/12/12 16:04:48
I believe the "session_storage_namespace &&" shoul
davidben
2014/12/12 20:41:19
There's still places that pass in NULL. Though I t
| |
| 591 session_storage_namespace_id_ != session_storage_namespace->id()) { | 585 session_storage_namespace_id_ != session_storage_namespace->id()) { |
| 592 return false; | 586 return false; |
| 593 } | 587 } |
| 594 return std::count_if(alias_urls_.begin(), alias_urls_.end(), | 588 return std::count_if(alias_urls_.begin(), alias_urls_.end(), |
| 595 std::bind2nd(std::equal_to<GURL>(), url)) != 0; | 589 std::bind2nd(std::equal_to<GURL>(), url)) != 0; |
| 596 } | 590 } |
| 597 | 591 |
| 598 void PrerenderContents::RenderProcessGone(base::TerminationStatus status) { | 592 void PrerenderContents::RenderProcessGone(base::TerminationStatus status) { |
| 599 Destroy(FINAL_STATUS_RENDERER_CRASHED); | 593 Destroy(FINAL_STATUS_RENDERER_CRASHED); |
| 600 } | 594 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 738 size_t private_bytes, shared_bytes; | 732 size_t private_bytes, shared_bytes; |
| 739 if (metrics->GetMemoryBytes(&private_bytes, &shared_bytes) && | 733 if (metrics->GetMemoryBytes(&private_bytes, &shared_bytes) && |
| 740 private_bytes > prerender_manager_->config().max_bytes) { | 734 private_bytes > prerender_manager_->config().max_bytes) { |
| 741 Destroy(FINAL_STATUS_MEMORY_LIMIT_EXCEEDED); | 735 Destroy(FINAL_STATUS_MEMORY_LIMIT_EXCEEDED); |
| 742 } | 736 } |
| 743 } | 737 } |
| 744 | 738 |
| 745 WebContents* PrerenderContents::ReleasePrerenderContents() { | 739 WebContents* PrerenderContents::ReleasePrerenderContents() { |
| 746 prerender_contents_->SetDelegate(NULL); | 740 prerender_contents_->SetDelegate(NULL); |
| 747 content::WebContentsObserver::Observe(NULL); | 741 content::WebContentsObserver::Observe(NULL); |
| 748 if (alias_session_storage_namespace.get()) | |
| 749 alias_session_storage_namespace->RemoveTransactionLogProcessId(child_id_); | |
| 750 return prerender_contents_.release(); | 742 return prerender_contents_.release(); |
| 751 } | 743 } |
| 752 | 744 |
| 753 RenderViewHost* PrerenderContents::GetRenderViewHostMutable() { | 745 RenderViewHost* PrerenderContents::GetRenderViewHostMutable() { |
| 754 return const_cast<RenderViewHost*>(GetRenderViewHost()); | 746 return const_cast<RenderViewHost*>(GetRenderViewHost()); |
| 755 } | 747 } |
| 756 | 748 |
| 757 const RenderViewHost* PrerenderContents::GetRenderViewHost() const { | 749 const RenderViewHost* PrerenderContents::GetRenderViewHost() const { |
| 758 if (!prerender_contents_.get()) | 750 if (!prerender_contents_.get()) |
| 759 return NULL; | 751 return NULL; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 801 | 793 |
| 802 NotifyPrerenderStop(); | 794 NotifyPrerenderStop(); |
| 803 | 795 |
| 804 BrowserThread::PostTask( | 796 BrowserThread::PostTask( |
| 805 BrowserThread::IO, | 797 BrowserThread::IO, |
| 806 FROM_HERE, | 798 FROM_HERE, |
| 807 base::Bind(&ResumeThrottles, resource_throttles_)); | 799 base::Bind(&ResumeThrottles, resource_throttles_)); |
| 808 resource_throttles_.clear(); | 800 resource_throttles_.clear(); |
| 809 } | 801 } |
| 810 | 802 |
| 811 SessionStorageNamespace* PrerenderContents::GetSessionStorageNamespace() const { | |
| 812 if (!prerender_contents()) | |
| 813 return NULL; | |
| 814 return prerender_contents()->GetController(). | |
| 815 GetDefaultSessionStorageNamespace(); | |
| 816 } | |
| 817 | |
| 818 void PrerenderContents::OnCancelPrerenderForPrinting() { | 803 void PrerenderContents::OnCancelPrerenderForPrinting() { |
| 819 Destroy(FINAL_STATUS_WINDOW_PRINT); | 804 Destroy(FINAL_STATUS_WINDOW_PRINT); |
| 820 } | 805 } |
| 821 | 806 |
| 822 void PrerenderContents::RecordCookieEvent(CookieEvent event, | 807 void PrerenderContents::RecordCookieEvent(CookieEvent event, |
| 823 bool is_main_frame_http_request, | 808 bool is_main_frame_http_request, |
| 824 bool is_third_party_cookie, | 809 bool is_third_party_cookie, |
| 825 bool is_for_blocking_resource, | 810 bool is_for_blocking_resource, |
| 826 base::Time earliest_create_date) { | 811 base::Time earliest_create_date) { |
| 827 // We don't care about sent cookies that were created after this prerender | 812 // We don't care about sent cookies that were created after this prerender |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 883 void PrerenderContents::AddResourceThrottle( | 868 void PrerenderContents::AddResourceThrottle( |
| 884 const base::WeakPtr<PrerenderResourceThrottle>& throttle) { | 869 const base::WeakPtr<PrerenderResourceThrottle>& throttle) { |
| 885 resource_throttles_.push_back(throttle); | 870 resource_throttles_.push_back(throttle); |
| 886 } | 871 } |
| 887 | 872 |
| 888 void PrerenderContents::AddNetworkBytes(int64 bytes) { | 873 void PrerenderContents::AddNetworkBytes(int64 bytes) { |
| 889 network_bytes_ += bytes; | 874 network_bytes_ += bytes; |
| 890 } | 875 } |
| 891 | 876 |
| 892 } // namespace prerender | 877 } // namespace prerender |
| OLD | NEW |