Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: chrome/browser/prerender/prerender_contents.cc

Issue 757723002: [Tests not passing yet] Remove prerender sessionStorage namespace merging. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_contents.h ('k') | chrome/browser/prerender/prerender_events.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698