summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete_popup.cc
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-03 18:18:14 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-03 18:18:14 +0000
commit2d31666a58e746b7a1d415c99e5f68ad9256d236 (patch)
tree144c99d4b80df0f0f9a3ded83f9d21a8b36f17cc /chrome/browser/autocomplete/autocomplete_popup.cc
parent90d6958fe2374a00d3c8583cf4d3b8a509ae8e90 (diff)
downloadchromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.zip
chromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.tar.gz
chromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.tar.bz2
Minor cleanup to OneShotTimer and RepeatingTimer: moves more of the member variables into the Task subclass.
Also included in this change: deprecate MessageLoop::timer_manager(), and change consumers over to use OneShotTimer or RepeatingTimer. R=beng BUG=1346553 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1684 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_popup.cc')
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup.cc23
1 files changed, 10 insertions, 13 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_popup.cc b/chrome/browser/autocomplete/autocomplete_popup.cc
index b272143..ca2dcbc 100644
--- a/chrome/browser/autocomplete/autocomplete_popup.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup.cc
@@ -721,10 +721,6 @@ AutocompletePopupModel::AutocompletePopupModel(const ChromeFont& font,
profile_(profile),
query_in_progress_(false),
update_pending_(false),
- // Creating the Timers directly instead of using StartTimer() ensures
- // they won't actually start running until we use ResetTimer().
- coalesce_timer_(new Timer(kPopupCoalesceMs, this, false)),
- max_delay_timer_(new Timer(kPopupUpdateMaxDelayMs, this, true)),
hovered_line_(kNoMatch),
selected_line_(kNoMatch) {
}
@@ -773,10 +769,9 @@ void AutocompletePopupModel::StartAutocomplete(
input_ = input;
// If we're starting a brand new query, stop caring about any old query.
- TimerManager* const tm = MessageLoop::current()->timer_manager();
if (!minimal_changes && query_in_progress_) {
update_pending_ = false;
- tm->StopTimer(coalesce_timer_.get());
+ coalesce_timer_.Stop();
}
// Start the new query.
@@ -785,8 +780,9 @@ void AutocompletePopupModel::StartAutocomplete(
// If we're not ready to show results and the max update interval timer isn't
// already running, start it now.
- if (query_in_progress_ && !tm->IsTimerRunning(max_delay_timer_.get()))
- tm->ResetTimer(max_delay_timer_.get());
+ if (query_in_progress_ && !max_delay_timer_.IsRunning())
+ max_delay_timer_.Start(TimeDelta::FromMilliseconds(kPopupUpdateMaxDelayMs),
+ this, &AutocompletePopupModel::Run);
SetDefaultMatchAndUpdate(!query_in_progress_);
}
@@ -1030,7 +1026,9 @@ void AutocompletePopupModel::SetDefaultMatchAndUpdate(bool immediately) {
} else if (!update_pending_) {
// Coalesce the results for the next kPopupCoalesceMs milliseconds.
update_pending_ = true;
- MessageLoop::current()->timer_manager()->ResetTimer(coalesce_timer_.get());
+ coalesce_timer_.Stop();
+ coalesce_timer_.Start(TimeDelta::FromMilliseconds(kPopupCoalesceMs), this,
+ &AutocompletePopupModel::Run);
}
// Update the edit with the possibly new data for this match.
@@ -1087,12 +1085,11 @@ void AutocompletePopupModel::CommitLatestResults(bool force) {
// The max update interval timer either needs to be reset (if more updates
// are to come) or stopped (when we're done with the query). The coalesce
// timer should always just be stopped.
- TimerManager* const tm = MessageLoop::current()->timer_manager();
- tm->StopTimer(coalesce_timer_.get());
+ coalesce_timer_.Stop();
if (query_in_progress_)
- tm->ResetTimer(max_delay_timer_.get());
+ max_delay_timer_.Reset();
else
- tm->StopTimer(max_delay_timer_.get());
+ max_delay_timer_.Stop();
}
bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match,