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

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

Issue 10004001: Add virtual and OVERRIDE to base/ implementation files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win Fix -> Missing header Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 9 #include "base/message_loop.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // ----------------------------------------------------------------------------- 53 // -----------------------------------------------------------------------------
54 class AsyncWaiter : public WaitableEvent::Waiter { 54 class AsyncWaiter : public WaitableEvent::Waiter {
55 public: 55 public:
56 AsyncWaiter(MessageLoop* message_loop, 56 AsyncWaiter(MessageLoop* message_loop,
57 const base::Closure& callback, 57 const base::Closure& callback,
58 Flag* flag) 58 Flag* flag)
59 : message_loop_(message_loop), 59 : message_loop_(message_loop),
60 callback_(callback), 60 callback_(callback),
61 flag_(flag) { } 61 flag_(flag) { }
62 62
63 bool Fire(WaitableEvent* event) { 63 virtual bool Fire(WaitableEvent* event) OVERRIDE {
64 // Post the callback if we haven't been cancelled. 64 // Post the callback if we haven't been cancelled.
65 if (!flag_->value()) { 65 if (!flag_->value()) {
66 message_loop_->PostTask(FROM_HERE, callback_); 66 message_loop_->PostTask(FROM_HERE, callback_);
67 } 67 }
68 68
69 // We are removed from the wait-list by the WaitableEvent itself. It only 69 // We are removed from the wait-list by the WaitableEvent itself. It only
70 // remains to delete ourselves. 70 // remains to delete ourselves.
71 delete this; 71 delete this;
72 72
73 // We can always return true because an AsyncWaiter is never in two 73 // We can always return true because an AsyncWaiter is never in two
74 // different wait-lists at the same time. 74 // different wait-lists at the same time.
75 return true; 75 return true;
76 } 76 }
77 77
78 // See StopWatching for discussion 78 // See StopWatching for discussion
79 bool Compare(void* tag) { 79 virtual bool Compare(void* tag) OVERRIDE {
80 return tag == flag_.get(); 80 return tag == flag_.get();
81 } 81 }
82 82
83 private: 83 private:
84 MessageLoop *const message_loop_; 84 MessageLoop *const message_loop_;
85 base::Closure callback_; 85 base::Closure callback_;
86 scoped_refptr<Flag> flag_; 86 scoped_refptr<Flag> flag_;
87 }; 87 };
88 88
89 // ----------------------------------------------------------------------------- 89 // -----------------------------------------------------------------------------
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 // ----------------------------------------------------------------------------- 256 // -----------------------------------------------------------------------------
257 // This is called when the MessageLoop which the callback will be run it is 257 // This is called when the MessageLoop which the callback will be run it is
258 // deleted. We need to cancel the callback as if we had been deleted, but we 258 // deleted. We need to cancel the callback as if we had been deleted, but we
259 // will still be deleted at some point in the future. 259 // will still be deleted at some point in the future.
260 // ----------------------------------------------------------------------------- 260 // -----------------------------------------------------------------------------
261 void WaitableEventWatcher::WillDestroyCurrentMessageLoop() { 261 void WaitableEventWatcher::WillDestroyCurrentMessageLoop() {
262 StopWatching(); 262 StopWatching();
263 } 263 }
264 264
265 } // namespace base 265 } // namespace base
OLDNEW
« no previous file with comments | « base/synchronization/waitable_event_unittest.cc ('k') | base/synchronization/waitable_event_watcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698