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

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

Issue 233353003: Only commit cookie changes in prerenders after a prerender is shown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Add browser tests, fix a bug in what was changed yesterday. Created 6 years, 7 months 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 | Annotate | Revision Log
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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 PrerenderManager* prerender_manager = PrerenderManagerFactory::GetForProfile( 282 PrerenderManager* prerender_manager = PrerenderManagerFactory::GetForProfile(
283 Profile::FromBrowserContext(web_contents->GetBrowserContext())); 283 Profile::FromBrowserContext(web_contents->GetBrowserContext()));
284 if (!prerender_manager) 284 if (!prerender_manager)
285 return NULL; 285 return NULL;
286 return prerender_manager->GetPrerenderContents(web_contents); 286 return prerender_manager->GetPrerenderContents(web_contents);
287 } 287 }
288 288
289 void PrerenderContents::StartPrerendering( 289 void PrerenderContents::StartPrerendering(
290 int creator_child_id, 290 int creator_child_id,
291 const gfx::Size& size, 291 const gfx::Size& size,
292 SessionStorageNamespace* session_storage_namespace) { 292 SessionStorageNamespace* session_storage_namespace,
293 net::URLRequestContextGetter* request_context) {
293 DCHECK(profile_ != NULL); 294 DCHECK(profile_ != NULL);
294 DCHECK(!size.IsEmpty()); 295 DCHECK(!size.IsEmpty());
295 DCHECK(!prerendering_has_started_); 296 DCHECK(!prerendering_has_started_);
296 DCHECK(prerender_contents_.get() == NULL); 297 DCHECK(prerender_contents_.get() == NULL);
297 DCHECK_EQ(-1, creator_child_id_); 298 DCHECK_EQ(-1, creator_child_id_);
298 DCHECK(size_.IsEmpty()); 299 DCHECK(size_.IsEmpty());
299 DCHECK_EQ(1U, alias_urls_.size()); 300 DCHECK_EQ(1U, alias_urls_.size());
300 301
301 creator_child_id_ = creator_child_id; 302 creator_child_id_ = creator_child_id;
302 session_storage_namespace_id_ = session_storage_namespace->id(); 303 session_storage_namespace_id_ = session_storage_namespace->id();
(...skipping 27 matching lines...) Expand all
330 // Set the size of the prerender WebContents. 331 // Set the size of the prerender WebContents.
331 apps::ResizeWebContents(prerender_contents_.get(), size_); 332 apps::ResizeWebContents(prerender_contents_.get(), size_);
332 333
333 child_id_ = GetRenderViewHost()->GetProcess()->GetID(); 334 child_id_ = GetRenderViewHost()->GetProcess()->GetID();
334 route_id_ = GetRenderViewHost()->GetRoutingID(); 335 route_id_ = GetRenderViewHost()->GetRoutingID();
335 336
336 // Log transactions to see if we could merge session storage namespaces in 337 // Log transactions to see if we could merge session storage namespaces in
337 // the event of a mismatch. 338 // the event of a mismatch.
338 alias_session_storage_namespace->AddTransactionLogProcessId(child_id_); 339 alias_session_storage_namespace->AddTransactionLogProcessId(child_id_);
339 340
341 // Add this prerender to the prerender tracker. This will create a
342 // Prerender Cookie Store to keep track of cookie changes performed by the
343 // prerender. Once the prerender is shown, the cookie changes will be
344 // committed to the actual cookie store, otherwise, they will be discarded.
345 prerender_manager()->prerender_tracker()->AddPrerender(
346 GetRenderViewHost()->GetProcess(),
347 request_context,
348 base::Bind(&PrerenderContents::Destroy,
349 AsWeakPtr(),
350 FINAL_STATUS_COOKIE_CONFLICT));
351
340 NotifyPrerenderStart(); 352 NotifyPrerenderStart();
341 353
342 // Close ourselves when the application is shutting down. 354 // Close ourselves when the application is shutting down.
343 notification_registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, 355 notification_registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
344 content::NotificationService::AllSources()); 356 content::NotificationService::AllSources());
345 357
346 // Register to inform new RenderViews that we're prerendering. 358 // Register to inform new RenderViews that we're prerendering.
347 notification_registrar_.Add( 359 notification_registrar_.Add(
348 this, content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, 360 this, content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED,
349 content::Source<WebContents>(prerender_contents_.get())); 361 content::Source<WebContents>(prerender_contents_.get()));
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 void PrerenderContents::AddResourceThrottle( 888 void PrerenderContents::AddResourceThrottle(
877 const base::WeakPtr<PrerenderResourceThrottle>& throttle) { 889 const base::WeakPtr<PrerenderResourceThrottle>& throttle) {
878 resource_throttles_.push_back(throttle); 890 resource_throttles_.push_back(throttle);
879 } 891 }
880 892
881 void PrerenderContents::AddNetworkBytes(int64 bytes) { 893 void PrerenderContents::AddNetworkBytes(int64 bytes) {
882 network_bytes_ += bytes; 894 network_bytes_ += bytes;
883 } 895 }
884 896
885 } // namespace prerender 897 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698