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

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

Issue 706993003: C++ readability review (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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
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_RTC_ALARM_H_ 5 #ifndef COMPONENTS_TIMER_RTC_ALARM_H_
6 #define COMPONENTS_TIMER_RTC_ALARM_H_ 6 #define COMPONENTS_TIMER_RTC_ALARM_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 scoped_refptr<base::MessageLoopProxy> origin_message_loop_; 66 scoped_refptr<base::MessageLoopProxy> origin_message_loop_;
67 67
68 // The parent timer that should be informed when the timer fires. We may end 68 // The parent timer that should be informed when the timer fires. We may end
69 // up outliving the parent so we need to ensure the reference is valid before 69 // up outliving the parent so we need to ensure the reference is valid before
70 // we try to call it. 70 // we try to call it.
71 base::WeakPtr<AlarmTimer> parent_; 71 base::WeakPtr<AlarmTimer> parent_;
72 72
73 // Manages watching file descriptors. 73 // Manages watching file descriptors.
74 scoped_ptr<base::MessageLoopForIO::FileDescriptorWatcher> fd_watcher_; 74 scoped_ptr<base::MessageLoopForIO::FileDescriptorWatcher> fd_watcher_;
75 75
76 // These two variables are used for coordinating between the thread that 76 // These two variables are used for coordinating between the thread that
gromer 2014/12/05 20:13:41 Comments that say what something is "used for" ten
Chirantan Ekbote 2014/12/31 00:58:29 Ack. I'll try and clean up the explanation.
77 // started the timer and the IO thread being used to watch the timer file 77 // started the timer and the IO thread being used to watch the timer file
78 // descriptor. When Reset() is called, the original thread increments 78 // descriptor. When Reset() is called, the original thread increments
79 // |origin_event_id_| and binds its value to ResetImpl(), which gets posted to 79 // |origin_event_id_| and binds its value to ResetImpl(), which gets posted to
80 // the IO thread. When the IO thread runs, it saves this value in 80 // the IO thread. When the IO thread runs, it saves this value in
81 // |io_event_id_|. Later, when the timer fires, the IO thread binds the value 81 // |io_event_id_|. Later, when the timer fires, the IO thread binds the value
82 // of |io_event_id_| to OnTimerFired() and posts it to the original thread. 82 // of |io_event_id_| to OnTimerFired() and posts it to the original thread.
83 // When the original thread runs OnTimerFired(), it calls 83 // When the original thread runs OnTimerFired(), it calls
84 // parent_->OnTimerFired() only if |origin_event_id_| matches the event id 84 // parent_->OnTimerFired() only if |origin_event_id_| matches the event id
85 // that was passed in to it. This is used to get around a race condition 85 // that was passed in to it. This is used to get around a race condition
86 // where the user resets the timer on the original thread, while the event is 86 // where the user resets the timer on the original thread, while the event is
87 // being fired on the IO thread at the same time. 87 // being fired on the IO thread at the same time.
88 int origin_event_id_; 88 int origin_event_id_;
89 int io_event_id_; 89 int io_event_id_;
90 90
91 DISALLOW_COPY_AND_ASSIGN(RtcAlarm); 91 DISALLOW_COPY_AND_ASSIGN(RtcAlarm);
92 }; 92 };
93 93
94
94 } // namespace timers 95 } // namespace timers
95 #endif // COMPONENTS_TIMER_RTC_ALARM_H_ 96 #endif // COMPONENTS_TIMER_RTC_ALARM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698