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

Side by Side Diff: base/synchronization/waitable_event_watcher_posix.cc

Issue 614103004: replace 'virtual ... OVERRIDE' with '... override' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: process base/ 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/synchronization/waitable_event_watcher.h" 5 #include "base/synchronization/waitable_event_watcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // ----------------------------------------------------------------------------- 58 // -----------------------------------------------------------------------------
59 class AsyncWaiter : public WaitableEvent::Waiter { 59 class AsyncWaiter : public WaitableEvent::Waiter {
60 public: 60 public:
61 AsyncWaiter(MessageLoop* message_loop, 61 AsyncWaiter(MessageLoop* message_loop,
62 const base::Closure& callback, 62 const base::Closure& callback,
63 Flag* flag) 63 Flag* flag)
64 : message_loop_(message_loop), 64 : message_loop_(message_loop),
65 callback_(callback), 65 callback_(callback),
66 flag_(flag) { } 66 flag_(flag) { }
67 67
68 virtual bool Fire(WaitableEvent* event) OVERRIDE { 68 bool Fire(WaitableEvent* event) override {
69 // Post the callback if we haven't been cancelled. 69 // Post the callback if we haven't been cancelled.
70 if (!flag_->value()) { 70 if (!flag_->value()) {
71 message_loop_->PostTask(FROM_HERE, callback_); 71 message_loop_->PostTask(FROM_HERE, callback_);
72 } 72 }
73 73
74 // We are removed from the wait-list by the WaitableEvent itself. It only 74 // We are removed from the wait-list by the WaitableEvent itself. It only
75 // remains to delete ourselves. 75 // remains to delete ourselves.
76 delete this; 76 delete this;
77 77
78 // We can always return true because an AsyncWaiter is never in two 78 // We can always return true because an AsyncWaiter is never in two
79 // different wait-lists at the same time. 79 // different wait-lists at the same time.
80 return true; 80 return true;
81 } 81 }
82 82
83 // See StopWatching for discussion 83 // See StopWatching for discussion
84 virtual bool Compare(void* tag) OVERRIDE { 84 bool Compare(void* tag) override { return tag == flag_.get(); }
85 return tag == flag_.get();
86 }
87 85
88 private: 86 private:
89 MessageLoop *const message_loop_; 87 MessageLoop *const message_loop_;
90 base::Closure callback_; 88 base::Closure callback_;
91 scoped_refptr<Flag> flag_; 89 scoped_refptr<Flag> flag_;
92 }; 90 };
93 91
94 // ----------------------------------------------------------------------------- 92 // -----------------------------------------------------------------------------
95 // For async waits we need to make a callback in a MessageLoop thread. We do 93 // For async waits we need to make a callback in a MessageLoop thread. We do
96 // this by posting a callback, which calls the delegate and keeps track of when 94 // this by posting a callback, which calls the delegate and keeps track of when
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // ----------------------------------------------------------------------------- 260 // -----------------------------------------------------------------------------
263 // This is called when the MessageLoop which the callback will be run it is 261 // This is called when the MessageLoop which the callback will be run it is
264 // deleted. We need to cancel the callback as if we had been deleted, but we 262 // deleted. We need to cancel the callback as if we had been deleted, but we
265 // will still be deleted at some point in the future. 263 // will still be deleted at some point in the future.
266 // ----------------------------------------------------------------------------- 264 // -----------------------------------------------------------------------------
267 void WaitableEventWatcher::WillDestroyCurrentMessageLoop() { 265 void WaitableEventWatcher::WillDestroyCurrentMessageLoop() {
268 StopWatching(); 266 StopWatching();
269 } 267 }
270 268
271 } // namespace base 269 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698