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

Side by Side Diff: base/timer/timer.cc

Issue 641943002: components: Introduce AlarmTimer class and use it for GCM heartbeat (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gyp files Created 6 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/timer/timer.h" 5 #include "base/timer/timer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // runs. 53 // runs.
54 void Abandon() { 54 void Abandon() {
55 timer_ = NULL; 55 timer_ = NULL;
56 } 56 }
57 57
58 private: 58 private:
59 Timer* timer_; 59 Timer* timer_;
60 }; 60 };
61 61
62 Timer::Timer(bool retain_user_task, bool is_repeating) 62 Timer::Timer(bool retain_user_task, bool is_repeating)
63 : scheduled_task_(NULL), 63 : is_repeating_(is_repeating),
64 thread_id_(0),
65 is_repeating_(is_repeating),
66 retain_user_task_(retain_user_task), 64 retain_user_task_(retain_user_task),
67 is_running_(false) { 65 is_running_(false),
66 scheduled_task_(NULL),
67 thread_id_(0) {
68 } 68 }
69 69
70 Timer::Timer(const tracked_objects::Location& posted_from, 70 Timer::Timer(const tracked_objects::Location& posted_from,
71 TimeDelta delay, 71 TimeDelta delay,
72 const base::Closure& user_task, 72 const base::Closure& user_task,
73 bool is_repeating) 73 bool is_repeating)
74 : scheduled_task_(NULL), 74 : posted_from_(posted_from),
75 posted_from_(posted_from),
76 delay_(delay), 75 delay_(delay),
77 user_task_(user_task), 76 user_task_(user_task),
78 thread_id_(0),
79 is_repeating_(is_repeating), 77 is_repeating_(is_repeating),
80 retain_user_task_(true), 78 retain_user_task_(true),
81 is_running_(false) { 79 is_running_(false),
80 scheduled_task_(NULL),
81 thread_id_(0) {
82 } 82 }
83 83
84 Timer::~Timer() { 84 Timer::~Timer() {
85 StopAndAbandon(); 85 StopAndAbandon();
86 } 86 }
87 87
88 bool Timer::IsRunning() const { 88 bool Timer::IsRunning() const {
89 return is_running_; 89 return is_running_;
90 } 90 }
91 91
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 PostNewScheduledTask(delay_); 197 PostNewScheduledTask(delay_);
198 else 198 else
199 Stop(); 199 Stop();
200 200
201 task.Run(); 201 task.Run();
202 202
203 // No more member accesses here: *this could be deleted at this point. 203 // No more member accesses here: *this could be deleted at this point.
204 } 204 }
205 205
206 } // namespace base 206 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698