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

Side by Side Diff: chrome/browser/instant/instant_controller.cc

Issue 7812036: Update base/timer.h code to pass through Location from call sites. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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) 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/instant/instant_controller.h" 5 #include "chrome/browser/instant/instant_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 loader_manager_->active_loader()->url() : GURL(); 510 loader_manager_->active_loader()->url() : GURL();
511 } 511 }
512 512
513 void InstantController::InstantStatusChanged(InstantLoader* loader) { 513 void InstantController::InstantStatusChanged(InstantLoader* loader) {
514 if (!loader->http_status_ok()) { 514 if (!loader->http_status_ok()) {
515 // Status isn't ok, start a timer that when fires shows the result. This 515 // Status isn't ok, start a timer that when fires shows the result. This
516 // delays showing 403 pages and the like. 516 // delays showing 403 pages and the like.
517 show_timer_.Stop(); 517 show_timer_.Stop();
518 show_timer_.Start( 518 show_timer_.Start(
519 base::TimeDelta::FromMilliseconds(kShowDelayMS), 519 base::TimeDelta::FromMilliseconds(kShowDelayMS),
520 this, &InstantController::ShowTimerFired); 520 this, &InstantController::ShowTimerFired, FROM_HERE);
521 UpdateDisplayableLoader(); 521 UpdateDisplayableLoader();
522 return; 522 return;
523 } 523 }
524 524
525 ProcessInstantStatusChanged(loader); 525 ProcessInstantStatusChanged(loader);
526 } 526 }
527 527
528 void InstantController::SetSuggestedTextFor( 528 void InstantController::SetSuggestedTextFor(
529 InstantLoader* loader, 529 InstantLoader* loader,
530 const string16& text, 530 const string16& text,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 // happening) or the hosts differ, otherwise we'll delay the update. 658 // happening) or the hosts differ, otherwise we'll delay the update.
659 return (active_loader->url() == url) || 659 return (active_loader->url() == url) ||
660 (active_loader->url().host() != url.host()); 660 (active_loader->url().host() != url.host());
661 } 661 }
662 662
663 void InstantController::ScheduleUpdate(const GURL& url) { 663 void InstantController::ScheduleUpdate(const GURL& url) {
664 scheduled_url_ = url; 664 scheduled_url_ = url;
665 665
666 update_timer_.Stop(); 666 update_timer_.Stop();
667 update_timer_.Start(base::TimeDelta::FromMilliseconds(kUpdateDelayMS), 667 update_timer_.Start(base::TimeDelta::FromMilliseconds(kUpdateDelayMS),
668 this, &InstantController::ProcessScheduledUpdate); 668 this, &InstantController::ProcessScheduledUpdate,
669 FROM_HERE);
669 } 670 }
670 671
671 void InstantController::ProcessScheduledUpdate() { 672 void InstantController::ProcessScheduledUpdate() {
672 DCHECK(loader_manager_.get()); 673 DCHECK(loader_manager_.get());
673 674
674 // We only delay loading of sites that don't support instant, so we can ignore 675 // We only delay loading of sites that don't support instant, so we can ignore
675 // suggested_text here. 676 // suggested_text here.
676 string16 suggested_text; 677 string16 suggested_text;
677 UpdateLoader(NULL, scheduled_url_, last_transition_type_, string16(), false, 678 UpdateLoader(NULL, scheduled_url_, last_transition_type_, string16(), false,
678 &suggested_text); 679 &suggested_text);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 InstantLoader* new_loader = 715 InstantLoader* new_loader =
715 loader_manager_->UpdateLoader(template_url_id, &owned_loader); 716 loader_manager_->UpdateLoader(template_url_id, &owned_loader);
716 717
717 new_loader->SetOmniboxBounds(omnibox_bounds_); 718 new_loader->SetOmniboxBounds(omnibox_bounds_);
718 if (new_loader->Update(tab_contents_, template_url, url, transition_type, 719 if (new_loader->Update(tab_contents_, template_url, url, transition_type,
719 user_text, verbatim, suggested_text)) { 720 user_text, verbatim, suggested_text)) {
720 show_timer_.Stop(); 721 show_timer_.Stop();
721 if (!new_loader->http_status_ok()) { 722 if (!new_loader->http_status_ok()) {
722 show_timer_.Start( 723 show_timer_.Start(
723 base::TimeDelta::FromMilliseconds(kShowDelayMS), 724 base::TimeDelta::FromMilliseconds(kShowDelayMS),
724 this, &InstantController::ShowTimerFired); 725 this, &InstantController::ShowTimerFired, FROM_HERE);
725 } 726 }
726 } 727 }
727 UpdateDisplayableLoader(); 728 UpdateDisplayableLoader();
728 } 729 }
729 730
730 InstantController::PreviewCondition InstantController::GetPreviewConditionFor( 731 InstantController::PreviewCondition InstantController::GetPreviewConditionFor(
731 const AutocompleteMatch& match, const TemplateURL** template_url) { 732 const AutocompleteMatch& match, const TemplateURL** template_url) {
732 const TemplateURL* t_url = match.template_url; 733 const TemplateURL* t_url = match.template_url;
733 if (t_url) { 734 if (t_url) {
734 if (!t_url->id() || 735 if (!t_url->id() ||
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 if (destroy_factory_.empty()) { 788 if (destroy_factory_.empty()) {
788 MessageLoop::current()->PostTask( 789 MessageLoop::current()->PostTask(
789 FROM_HERE, destroy_factory_.NewRunnableMethod( 790 FROM_HERE, destroy_factory_.NewRunnableMethod(
790 &InstantController::DestroyLoaders)); 791 &InstantController::DestroyLoaders));
791 } 792 }
792 } 793 }
793 794
794 void InstantController::DestroyLoaders() { 795 void InstantController::DestroyLoaders() {
795 loaders_to_destroy_.reset(); 796 loaders_to_destroy_.reset();
796 } 797 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698