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

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

Issue 7604002: Fix prerender history always having FINAL_STATUS_MAX on cancellation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Add comment Created 9 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <utility> 8 #include <utility>
9 9
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 } 496 }
497 497
498 void PrerenderContents::DidStopLoading() { 498 void PrerenderContents::DidStopLoading() {
499 has_stopped_loading_ = true; 499 has_stopped_loading_ = true;
500 } 500 }
501 501
502 void PrerenderContents::Destroy(FinalStatus final_status) { 502 void PrerenderContents::Destroy(FinalStatus final_status) {
503 if (prerendering_has_been_cancelled_) 503 if (prerendering_has_been_cancelled_)
504 return; 504 return;
505 505
506 prerendering_has_been_cancelled_ = true;
507 prerender_manager_->MoveEntryToPendingDelete(this);
508
509 if (child_id_ != -1 && route_id_ != -1) { 506 if (child_id_ != -1 && route_id_ != -1) {
510 // Cancel the prerender in the PrerenderTracker. This is needed 507 // Cancel the prerender in the PrerenderTracker. This is needed
511 // because destroy may be called directly from the UI thread without calling 508 // because destroy may be called directly from the UI thread without calling
512 // TryCancel(). This is difficult to completely avoid, since prerendering 509 // TryCancel(). This is difficult to completely avoid, since prerendering
513 // can be cancelled before a RenderView is created. 510 // can be cancelled before a RenderView is created.
514 bool is_cancelled = prerender_tracker_->TryCancel( 511 bool is_cancelled = prerender_tracker_->TryCancel(
515 child_id_, route_id_, final_status); 512 child_id_, route_id_, final_status);
516 CHECK(is_cancelled); 513 CHECK(is_cancelled);
517 514
518 // A different final status may have been set already from another thread. 515 // A different final status may have been set already from another thread.
519 // If so, use it instead. 516 // If so, use it instead.
520 if (!prerender_tracker_->GetFinalStatus(child_id_, route_id_, 517 if (!prerender_tracker_->GetFinalStatus(child_id_, route_id_,
521 &final_status)) { 518 &final_status)) {
522 NOTREACHED(); 519 NOTREACHED();
523 } 520 }
524 } 521 }
525 set_final_status(final_status); 522 set_final_status(final_status);
526 523
524 prerendering_has_been_cancelled_ = true;
525 // This has to be done after setting the final status, as it adds the
526 // prerender to the history.
527 prerender_manager_->MoveEntryToPendingDelete(this);
528
527 // We may destroy the PrerenderContents before we have initialized the 529 // We may destroy the PrerenderContents before we have initialized the
528 // RenderViewHost. Otherwise set the Observer's PrerenderContents to NULL to 530 // RenderViewHost. Otherwise set the Observer's PrerenderContents to NULL to
529 // avoid any more messages being sent. 531 // avoid any more messages being sent.
530 if (render_view_host_observer_.get()) 532 if (render_view_host_observer_.get())
531 render_view_host_observer_->set_prerender_contents(NULL); 533 render_view_host_observer_->set_prerender_contents(NULL);
532 } 534 }
533 535
534 base::ProcessMetrics* PrerenderContents::MaybeGetProcessMetrics() { 536 base::ProcessMetrics* PrerenderContents::MaybeGetProcessMetrics() {
535 if (process_metrics_.get() == NULL) { 537 if (process_metrics_.get() == NULL) {
536 // If a PrenderContents hasn't started prerending, don't be fully formed. 538 // If a PrenderContents hasn't started prerending, don't be fully formed.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 return NULL; 598 return NULL;
597 DictionaryValue* dict_value = new DictionaryValue(); 599 DictionaryValue* dict_value = new DictionaryValue();
598 dict_value->SetString("url", prerender_url_.spec()); 600 dict_value->SetString("url", prerender_url_.spec());
599 base::TimeTicks current_time = base::TimeTicks::Now(); 601 base::TimeTicks current_time = base::TimeTicks::Now();
600 base::TimeDelta duration = current_time - load_start_time_; 602 base::TimeDelta duration = current_time - load_start_time_;
601 dict_value->SetInteger("duration", duration.InSeconds()); 603 dict_value->SetInteger("duration", duration.InSeconds());
602 return dict_value; 604 return dict_value;
603 } 605 }
604 606
605 } // namespace prerender 607 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698