summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorchirantan <chirantan@chromium.org>2015-07-17 11:27:58 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-17 18:29:54 +0000
commitae0e25d6671def1a1a4ecf7536e55d3100027ce4 (patch)
tree0d137b60bdfc34e8db3a842fad7e82e80117a622 /components
parent0ee02e6e52469f9260395f2ddd22bf4d6e75b828 (diff)
downloadchromium_src-ae0e25d6671def1a1a4ecf7536e55d3100027ce4.zip
chromium_src-ae0e25d6671def1a1a4ecf7536e55d3100027ce4.tar.gz
chromium_src-ae0e25d6671def1a1a4ecf7536e55d3100027ce4.tar.bz2
Return early if an AlarmTimer is stopped when it is not running
The AlarmTimer calls Stop() in its destructor. If it turns out that the AlarmTimer was created but never used, which can happen during tests, and the MessageLoop on which the AlarmTimer was created is not a MessageLoopForIO, then the Stop() function will end up creating a thread just to call Stop(). Instead, we can just return early from Stop() if the AlarmTimer isn't actually running. BUG=509138 Review URL: https://codereview.chromium.org/1237833004 Cr-Commit-Position: refs/heads/master@{#339287}
Diffstat (limited to 'components')
-rw-r--r--components/timers/alarm_timer_chromeos.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/components/timers/alarm_timer_chromeos.cc b/components/timers/alarm_timer_chromeos.cc
index ebef8ca..8797345 100644
--- a/components/timers/alarm_timer_chromeos.cc
+++ b/components/timers/alarm_timer_chromeos.cc
@@ -351,6 +351,9 @@ void AlarmTimer::Init() {
}
void AlarmTimer::Stop() {
+ if (!base::Timer::is_running())
+ return;
+
if (!can_wake_from_suspend_) {
base::Timer::Stop();
return;