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

Side by Side Diff: components/timers/alarm_timer.h

Issue 745123002: Link GCM heartbeat with wake on wifi preference (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix missing include Created 6 years 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
« no previous file with comments | « components/gcm_driver/gcm_driver_desktop.cc ('k') | components/timers/alarm_timer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef COMPONENTS_TIMER_ALARM_TIMER_H_ 5 #ifndef COMPONENTS_TIMER_ALARM_TIMER_H_
6 #define COMPONENTS_TIMER_ALARM_TIMER_H_ 6 #define COMPONENTS_TIMER_ALARM_TIMER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 AlarmTimer(bool retain_user_task, bool is_repeating); 55 AlarmTimer(bool retain_user_task, bool is_repeating);
56 56
57 AlarmTimer(const tracked_objects::Location& posted_from, 57 AlarmTimer(const tracked_objects::Location& posted_from,
58 base::TimeDelta delay, 58 base::TimeDelta delay,
59 const base::Closure& user_task, 59 const base::Closure& user_task,
60 bool is_repeating); 60 bool is_repeating);
61 61
62 ~AlarmTimer() override; 62 ~AlarmTimer() override;
63 63
64 bool can_wake_from_suspend() { return can_wake_from_suspend_; } 64 bool can_wake_from_suspend() const { return can_wake_from_suspend_; }
65
66 // Must be called by the delegate to indicate that the timer has fired and
67 // that the user task should be run.
68 void OnTimerFired();
65 69
66 // Timer overrides. 70 // Timer overrides.
67 void Stop() override; 71 void Stop() override;
68 void Reset() override; 72 void Reset() override;
69 73
70 // MessageLoop::DestructionObserver overrides. 74 // MessageLoop::DestructionObserver overrides.
71 void WillDestroyCurrentMessageLoop() override; 75 void WillDestroyCurrentMessageLoop() override;
72 76
73 // Must be called by the delegate to indicate that the timer has fired and
74 // that the user task should be run.
75 void OnTimerFired();
76
77 private: 77 private:
78 // Initializes the timer with the appropriate delegate. 78 // Initializes the timer with the appropriate delegate.
79 void Init(); 79 void Init();
80 80
81 // Delegate that will manage actually setting the timer. 81 // Delegate that will manage actually setting the timer.
82 scoped_refptr<Delegate> delegate_; 82 scoped_refptr<Delegate> delegate_;
83 83
84 // Keeps track of the user task we want to run. A new one is constructed 84 // Keeps track of the user task we want to run. A new one is constructed
85 // every time Reset() is called. 85 // every time Reset() is called.
86 scoped_ptr<base::PendingTask> pending_task_; 86 scoped_ptr<base::PendingTask> pending_task_;
87 87
88 // Tracks whether the timer has the ability to wake the system up from 88 // Tracks whether the timer has the ability to wake the system up from
89 // suspend. This is a runtime check because we won't know if the system 89 // suspend. This is a runtime check because we won't know if the system
90 // supports being woken up from suspend until the delegate actually tries to 90 // supports being woken up from suspend until the delegate actually tries to
91 // set it up. 91 // set it up.
92 bool can_wake_from_suspend_; 92 bool can_wake_from_suspend_;
93 93
94 // Pointer to the message loop that started the timer. Used to track the 94 // Pointer to the message loop that started the timer. Used to track the
95 // destruction of that message loop. 95 // destruction of that message loop.
96 base::MessageLoop* origin_message_loop_; 96 base::MessageLoop* origin_message_loop_;
97 97
98 base::WeakPtrFactory<AlarmTimer> weak_factory_; 98 base::WeakPtrFactory<AlarmTimer> weak_factory_;
99 99
100 DISALLOW_COPY_AND_ASSIGN(AlarmTimer); 100 DISALLOW_COPY_AND_ASSIGN(AlarmTimer);
101 }; 101 };
102 102
103 } // namespace timers 103 } // namespace timers
104 104
105 #endif // COMPONENTS_TIMER_ALARM_TIMER_H_ 105 #endif // COMPONENTS_TIMER_ALARM_TIMER_H_
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_driver_desktop.cc ('k') | components/timers/alarm_timer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698