Skip to content

Commit

Permalink
Revert "Currently, base/timer.cc calls PostTask with FROM_HERE as the…
Browse files Browse the repository at this point in the history
… Location,

so the original code that created the delayed callback is lost."

This reverts commit 4cf5cf7. (r99284)

[email protected]

Review URL: http://codereview.chromium.org/7825026

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99290 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
[email protected] committed Sep 2, 2011
1 parent dd8d12a commit 6fd550b
Show file tree
Hide file tree
Showing 115 changed files with 178 additions and 235 deletions.
2 changes: 1 addition & 1 deletion base/system_monitor/system_monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SystemMonitor::SystemMonitor()

DCHECK(MessageLoop::current());
#if defined(ENABLE_BATTERY_MONITORING)
delayed_battery_check_.Start(FROM_HERE,
delayed_battery_check_.Start(
base::TimeDelta::FromMilliseconds(kDelayedBatteryCheckMs), this,
&SystemMonitor::BatteryCheck);
#endif // defined(ENABLE_BATTERY_MONITORING)
Expand Down
2 changes: 1 addition & 1 deletion base/timer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void BaseTimer_Helper::InitiateDelayedTask(TimerTask* timer_task) {
delayed_task_ = timer_task;
delayed_task_->timer_ = this;
MessageLoop::current()->PostDelayedTask(
timer_task->posted_from_, timer_task,
FROM_HERE, timer_task,
static_cast<int>(timer_task->delay_.InMillisecondsRoundedUp()));
}

Expand Down
34 changes: 9 additions & 25 deletions base/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,9 @@ class BASE_EXPORT BaseTimer_Helper {
// We have access to the timer_ member so we can orphan this task.
class TimerTask : public Task {
public:
TimerTask(const tracked_objects::Location& posted_from,
TimeDelta delay)
: posted_from_(posted_from),
timer_(NULL),
delay_(delay) {
explicit TimerTask(TimeDelta delay) : timer_(NULL), delay_(delay) {
}
virtual ~TimerTask() {}
tracked_objects::Location posted_from_;
BaseTimer_Helper* timer_;
TimeDelta delay_;
};
Expand All @@ -121,12 +116,9 @@ class BaseTimer : public BaseTimer_Helper {

// Call this method to start the timer. It is an error to call this method
// while the timer is already running.
void Start(const tracked_objects::Location& posted_from,
TimeDelta delay,
Receiver* receiver,
ReceiverMethod method) {
void Start(TimeDelta delay, Receiver* receiver, ReceiverMethod method) {
DCHECK(!IsRunning());
InitiateDelayedTask(new TimerTask(posted_from, delay, receiver, method));
InitiateDelayedTask(new TimerTask(delay, receiver, method));
}

// Call this method to stop the timer. It is a no-op if the timer is not
Expand All @@ -146,11 +138,8 @@ class BaseTimer : public BaseTimer_Helper {

class TimerTask : public BaseTimer_Helper::TimerTask {
public:
TimerTask(const tracked_objects::Location& posted_from,
TimeDelta delay,
Receiver* receiver,
ReceiverMethod method)
: BaseTimer_Helper::TimerTask(posted_from, delay),
TimerTask(TimeDelta delay, Receiver* receiver, ReceiverMethod method)
: BaseTimer_Helper::TimerTask(delay),
receiver_(receiver),
method_(method) {
}
Expand All @@ -173,7 +162,7 @@ class BaseTimer : public BaseTimer_Helper {
}

TimerTask* Clone() const {
return new TimerTask(posted_from_, delay_, receiver_, method_);
return new TimerTask(delay_, receiver_, method_);
}

private:
Expand Down Expand Up @@ -232,12 +221,8 @@ class DelayTimer {
public:
typedef void (Receiver::*ReceiverMethod)();

DelayTimer(const tracked_objects::Location& posted_from,
TimeDelta delay,
Receiver* receiver,
ReceiverMethod method)
: posted_from_(posted_from),
receiver_(receiver),
DelayTimer(TimeDelta delay, Receiver* receiver, ReceiverMethod method)
: receiver_(receiver),
method_(method),
delay_(delay) {
}
Expand All @@ -257,7 +242,7 @@ class DelayTimer {

// The timer isn't running, or will expire too late, so restart it.
timer_.Stop();
timer_.Start(posted_from_, delay, this, &DelayTimer<Receiver>::Check);
timer_.Start(delay, this, &DelayTimer<Receiver>::Check);
}

void Check() {
Expand All @@ -274,7 +259,6 @@ class DelayTimer {
(receiver_->*method_)();
}

tracked_objects::Location posted_from_;
Receiver *const receiver_;
const ReceiverMethod method_;
const TimeDelta delay_;
Expand Down
18 changes: 9 additions & 9 deletions base/timer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OneShotTimerTester {
delay_ms_(milliseconds) {
}
void Start() {
timer_.Start(FROM_HERE, TimeDelta::FromMilliseconds(delay_ms_), this,
timer_.Start(TimeDelta::FromMilliseconds(delay_ms_), this,
&OneShotTimerTester::Run);
}
private:
Expand All @@ -39,7 +39,7 @@ class OneShotSelfDeletingTimerTester {
timer_(new base::OneShotTimer<OneShotSelfDeletingTimerTester>()) {
}
void Start() {
timer_->Start(FROM_HERE, TimeDelta::FromMilliseconds(10), this,
timer_->Start(TimeDelta::FromMilliseconds(10), this,
&OneShotSelfDeletingTimerTester::Run);
}
private:
Expand All @@ -59,7 +59,7 @@ class RepeatingTimerTester {
}

void Start() {
timer_.Start(FROM_HERE, TimeDelta::FromMilliseconds(10), this,
timer_.Start(TimeDelta::FromMilliseconds(10), this,
&RepeatingTimerTester::Run);
}
private:
Expand Down Expand Up @@ -176,7 +176,7 @@ void RunTest_DelayTimer_NoCall(MessageLoop::Type message_loop_type) {

// If Delay is never called, the timer shouldn't go off.
DelayTimerTarget target;
base::DelayTimer<DelayTimerTarget> timer(FROM_HERE,
base::DelayTimer<DelayTimerTarget> timer(
TimeDelta::FromMilliseconds(1), &target, &DelayTimerTarget::Signal);

bool did_run = false;
Expand All @@ -191,7 +191,7 @@ void RunTest_DelayTimer_OneCall(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);

DelayTimerTarget target;
base::DelayTimer<DelayTimerTarget> timer(FROM_HERE,
base::DelayTimer<DelayTimerTarget> timer(
TimeDelta::FromMilliseconds(1), &target, &DelayTimerTarget::Signal);
timer.Reset();

Expand Down Expand Up @@ -225,16 +225,16 @@ void RunTest_DelayTimer_Reset(MessageLoop::Type message_loop_type) {

// If Delay is never called, the timer shouldn't go off.
DelayTimerTarget target;
base::DelayTimer<DelayTimerTarget> timer(FROM_HERE,
base::DelayTimer<DelayTimerTarget> timer(
TimeDelta::FromMilliseconds(50), &target, &DelayTimerTarget::Signal);
timer.Reset();

ResetHelper reset_helper(&timer, &target);

base::OneShotTimer<ResetHelper> timers[20];
for (size_t i = 0; i < arraysize(timers); ++i) {
timers[i].Start(FROM_HERE, TimeDelta::FromMilliseconds(i * 10),
&reset_helper, &ResetHelper::Reset);
timers[i].Start(TimeDelta::FromMilliseconds(i * 10), &reset_helper,
&ResetHelper::Reset);
}

bool did_run = false;
Expand All @@ -260,7 +260,7 @@ void RunTest_DelayTimer_Deleted(MessageLoop::Type message_loop_type) {

{
base::DelayTimer<DelayTimerFatalTarget> timer(
FROM_HERE, TimeDelta::FromMilliseconds(50), &target,
TimeDelta::FromMilliseconds(50), &target,
&DelayTimerFatalTarget::Signal);
timer.Reset();
}
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/autocomplete/autocomplete.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,6 @@ void AutocompleteController::CheckIfDone() {

void AutocompleteController::StartExpireTimer() {
if (result_.HasCopiedMatches())
expire_timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kExpireTimeMS),
expire_timer_.Start(base::TimeDelta::FromMilliseconds(kExpireTimeMS),
this, &AutocompleteController::ExpireCopiedEntries);
}
3 changes: 1 addition & 2 deletions chrome/browser/autocomplete/search_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,7 @@ void SearchProvider::StartOrStopSuggestQuery(bool minimal_changes) {
// Kick off a timer that will start the URL fetch if it completes before
// the user types another character.
int delay = query_suggest_immediately_ ? 0 : kQueryDelayMs;
timer_.Start(FROM_HERE, TimeDelta::FromMilliseconds(delay), this,
&SearchProvider::Run);
timer_.Start(TimeDelta::FromMilliseconds(delay), this, &SearchProvider::Run);
}

bool SearchProvider::IsQuerySuitableForSuggest() const {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/bookmarks/bookmark_drop_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void BookmarkDropInfo::Update(const views::DropTargetEvent& event) {
scroll_up_ = (last_y_ <= top_margin_ + views::kAutoscrollSize);
if (scroll_up_ || scroll_down) {
if (!scroll_timer_.IsRunning()) {
scroll_timer_.Start(FROM_HERE,
scroll_timer_.Start(
base::TimeDelta::FromMilliseconds(views::kAutoscrollRowTimerMS),
this,
&BookmarkDropInfo::Scroll);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/browser_process_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ void BrowserProcessImpl::Observe(int type,

#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
void BrowserProcessImpl::StartAutoupdateTimer() {
autoupdate_timer_.Start(FROM_HERE,
autoupdate_timer_.Start(
base::TimeDelta::FromHours(kUpdateCheckIntervalHours),
this,
&BrowserProcessImpl::OnAutoupdateTimer);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/cros/login_library.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class LoginLibraryImpl : public LoginLibrary {
// just kills us so settings may be lost. See http://crosbug.com/13102
local_state_->CommitPendingWrite();
timer_.Start(
FROM_HERE, base::TimeDelta::FromSeconds(3), this,
base::TimeDelta::FromSeconds(3), this,
&JobRestartRequest::RestartJob);
// Post task on file thread thus it occurs last on task queue, so it
// would be executed after committing pending write on file thread.
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/chromeos/cros/power_library.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ class PowerLibraryStubImpl : public PowerLibrary {
battery_percentage_(20),
pause_count_(0) {
timer_.Start(
FROM_HERE,
base::TimeDelta::FromMilliseconds(100),
this,
&PowerLibraryStubImpl::Update);
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/chromeos/customization_document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ void ServicesCustomizationDocument::OnURLFetchComplete(
NetworkLibrary* network = CrosLibrary::Get()->GetNetworkLibrary();
if (!network->Connected() && num_retries_ < kMaxFetchRetries) {
num_retries_++;
retry_timer_.Start(FROM_HERE,
base::TimeDelta::FromSeconds(kRetriesDelayInSec),
retry_timer_.Start(base::TimeDelta::FromSeconds(kRetriesDelayInSec),
this, &ServicesCustomizationDocument::StartFileFetch);
return;
}
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/chromeos/login/network_screen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ void NetworkScreen::StopWaitingForConnection(const string16& network_id) {
void NetworkScreen::WaitForConnection(const string16& network_id) {
if (network_id_ != network_id || !connection_timer_.IsRunning()) {
connection_timer_.Stop();
connection_timer_.Start(FROM_HERE,
base::TimeDelta::FromSeconds(kConnectionTimeoutSec),
connection_timer_.Start(base::TimeDelta::FromSeconds(kConnectionTimeoutSec),
this,
&NetworkScreen::OnConnectionTimeout);
}
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/chromeos/login/screen_locker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,7 @@ class LockerInputEventObserver : public MessageLoopForUI::Observer {
explicit LockerInputEventObserver(ScreenLocker* screen_locker)
: screen_locker_(screen_locker),
ALLOW_THIS_IN_INITIALIZER_LIST(
timer_(FROM_HERE,
base::TimeDelta::FromSeconds(kScreenSaverIdleTimeout), this,
timer_(base::TimeDelta::FromSeconds(kScreenSaverIdleTimeout), this,
&LockerInputEventObserver::StartScreenSaver)) {
}

Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/chromeos/login/update_screen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ void UpdateScreen::UpdateStatusChanged(UpdateLibrary* library) {
actor_->ShowCurtain(false);
VLOG(1) << "Initiate reboot after update";
CrosLibrary::Get()->GetUpdateLibrary()->RebootAfterUpdate();
reboot_timer_.Start(FROM_HERE,
base::TimeDelta::FromSeconds(reboot_check_delay_),
reboot_timer_.Start(base::TimeDelta::FromSeconds(reboot_check_delay_),
this,
&UpdateScreen::OnWaitForRebootTimeElapsed);
} else {
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/chromeos/login/web_page_screen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ void WebPageScreen::OnNetworkTimeout() {

void WebPageScreen::StartTimeoutTimer() {
StopTimeoutTimer();
timeout_timer_.Start(FROM_HERE,
TimeDelta::FromSeconds(kNetworkTimeoutSec),
timeout_timer_.Start(TimeDelta::FromSeconds(kNetworkTimeoutSec),
this,
&WebPageScreen::OnNetworkTimeout);
}
Expand Down
6 changes: 2 additions & 4 deletions chrome/browser/chromeos/login/web_page_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ void WebPageView::Init() {
connecting_label_->SetVisible(false);
AddChildView(connecting_label_ );

start_timer_.Start(FROM_HERE,
TimeDelta::FromMilliseconds(kStartDelayMs),
start_timer_.Start(TimeDelta::FromMilliseconds(kStartDelayMs),
this,
&WebPageView::ShowWaitingControls);
}
Expand All @@ -151,8 +150,7 @@ void WebPageView::ShowPageContent() {
// TODO(nkostylev): Show throbber as an overlay until page has been rendered.
start_timer_.Stop();
if (!stop_timer_.IsRunning()) {
stop_timer_.Start(FROM_HERE,
TimeDelta::FromMilliseconds(kStopDelayMs),
stop_timer_.Start(TimeDelta::FromMilliseconds(kStopDelayMs),
this,
&WebPageView::ShowRenderedPage);
}
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/chromeos/login/wizard_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ void WizardController::SetCurrentScreenSmooth(WizardScreen* new_current,

if (use_smoothing) {
smooth_show_timer_.Start(
FROM_HERE,
base::TimeDelta::FromMilliseconds(kShowDelayMs),
this,
&WizardController::ShowCurrentScreen);
Expand Down
6 changes: 2 additions & 4 deletions chrome/browser/chromeos/setting_level_bubble.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ void SettingLevelBubble::ShowBubble(double percent, bool enabled) {
view_->SetEnabled(enabled);
}

hide_timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kBubbleShowTimeoutMs),
hide_timer_.Start(base::TimeDelta::FromMilliseconds(kBubbleShowTimeoutMs),
this, &SettingLevelBubble::OnHideTimeout);
}

Expand Down Expand Up @@ -233,8 +232,7 @@ void SettingLevelBubble::UpdateTargetPercent(double percent) {
target_time_ = now + TimeDelta::FromMilliseconds(duration_ms);

if (!is_animating_) {
animation_timer_.Start(FROM_HERE,
TimeDelta::FromMilliseconds(kAnimationIntervalMs),
animation_timer_.Start(TimeDelta::FromMilliseconds(kAnimationIntervalMs),
this,
&SettingLevelBubble::OnAnimationTimeout);
is_animating_ = true;
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/status/clock_menu_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void ClockMenuButton::UpdateTextAndSetNextTimer() {
// called just a teeny bit early, then it will skip the next minute.
seconds_left += kTimerSlopSeconds;

timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(seconds_left), this,
timer_.Start(base::TimeDelta::FromSeconds(seconds_left), this,
&ClockMenuButton::UpdateTextAndSetNextTimer);
}

Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/chromeos/status/memory_menu_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ MemoryMenuButton::~MemoryMenuButton() {
void MemoryMenuButton::UpdateTextAndSetNextTimer() {
UpdateText();

timer_.Start(FROM_HERE,
base::TimeDelta::FromSeconds(kUpdateIntervalSeconds), this,
timer_.Start(base::TimeDelta::FromSeconds(kUpdateIntervalSeconds), this,
&MemoryMenuButton::UpdateTextAndSetNextTimer);
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/upgrade_detector_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void UpgradeDetectorChromeos::UpdateStatusChanged(

// Setup timer to to move along the upgrade advisory system.
upgrade_notification_timer_.Start(
FROM_HERE, base::TimeDelta::FromMilliseconds(kNotifyCycleTimeMs),
base::TimeDelta::FromMilliseconds(kNotifyCycleTimeMs),
this, &UpgradeDetectorChromeos::NotifyOnUpgrade);
}

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/component_updater/component_updater_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ ComponentUpdateService::Status CrxUpdateService::Start() {
Source<ComponentUpdateService>(this),
NotificationService::NoDetails());

timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(config_->InitialDelay()),
timer_.Start(base::TimeDelta::FromSeconds(config_->InitialDelay()),
this, &CrxUpdateService::ProcessPendingItems);
return kOk;
}
Expand Down Expand Up @@ -374,7 +374,7 @@ void CrxUpdateService::ScheduleNextRun(bool step_delay) {
return;
}

timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(delay),
timer_.Start(base::TimeDelta::FromSeconds(delay),
this, &CrxUpdateService::ProcessPendingItems);
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/enumerate_modules_model_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ EnumerateModulesModel::EnumerateModulesModel()
suspected_bad_modules_detected_(0) {
const CommandLine& cmd_line = *CommandLine::ForCurrentProcess();
if (cmd_line.HasSwitch(switches::kConflictingModulesCheck)) {
check_modules_timer_.Start(FROM_HERE,
check_modules_timer_.Start(
base::TimeDelta::FromMilliseconds(kModuleCheckDelayMs),
this, &EnumerateModulesModel::ScanNow);
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/extension_updater.cc
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ void ExtensionUpdater::ScheduleNextCheck(const TimeDelta& target_delay) {
prefs_->SetInt64(kNextExtensionsUpdateCheck, next.ToInternalValue());
prefs_->ScheduleSavePersistentPrefs();

timer_.Start(FROM_HERE, actual_delay, this, &ExtensionUpdater::TimerFired);
timer_.Start(actual_delay, this, &ExtensionUpdater::TimerFired);
}

void ExtensionUpdater::TimerFired() {
Expand Down
Loading

0 comments on commit 6fd550b

Please sign in to comment.