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

Unified Diff: base/synchronization/waitable_event_win.cc

Issue 593973002: Use ScopedHandle for the private members of WaitableEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/synchronization/waitable_event.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/synchronization/waitable_event_win.cc
diff --git a/base/synchronization/waitable_event_win.cc b/base/synchronization/waitable_event_win.cc
index 04746b597b4cd7757268fc3466738903f65c9df4..ec2d84f2679ad840cb460f1247fee5825f269a19 100644
--- a/base/synchronization/waitable_event_win.cc
+++ b/base/synchronization/waitable_event_win.cc
@@ -17,30 +17,27 @@ WaitableEvent::WaitableEvent(bool manual_reset, bool signaled)
: handle_(CreateEvent(NULL, manual_reset, signaled, NULL)) {
// We're probably going to crash anyways if this is ever NULL, so we might as
// well make our stack reports more informative by crashing here.
- CHECK(handle_);
+ CHECK(handle_.IsValid());
}
WaitableEvent::WaitableEvent(HANDLE handle)
: handle_(handle) {
- CHECK(handle) << "Tried to create WaitableEvent from NULL handle";
+ CHECK(handle_.IsValid()) << "Tried to create WaitableEvent from NULL handle";
}
WaitableEvent::~WaitableEvent() {
- CloseHandle(handle_);
}
HANDLE WaitableEvent::Release() {
- HANDLE rv = handle_;
- handle_ = INVALID_HANDLE_VALUE;
- return rv;
+ return handle_.Take();
}
void WaitableEvent::Reset() {
- ResetEvent(handle_);
+ ResetEvent(handle_.Get());
}
void WaitableEvent::Signal() {
- SetEvent(handle_);
+ SetEvent(handle_.Get());
}
bool WaitableEvent::IsSignaled() {
@@ -49,7 +46,7 @@ bool WaitableEvent::IsSignaled() {
void WaitableEvent::Wait() {
base::ThreadRestrictions::AssertWaitAllowed();
- DWORD result = WaitForSingleObject(handle_, INFINITE);
+ DWORD result = WaitForSingleObject(handle_.Get(), INFINITE);
// It is most unexpected that this should ever fail. Help consumers learn
// about it if it should ever fail.
DCHECK_EQ(WAIT_OBJECT_0, result) << "WaitForSingleObject failed";
@@ -62,7 +59,8 @@ bool WaitableEvent::TimedWait(const TimeDelta& max_time) {
// is in milliseconds. If there are 5.5ms left, should the delay be 5 or 6?
// It should be 6 to avoid returning too early.
double timeout = ceil(max_time.InMillisecondsF());
- DWORD result = WaitForSingleObject(handle_, static_cast<DWORD>(timeout));
+ DWORD result = WaitForSingleObject(handle_.Get(),
+ static_cast<DWORD>(timeout));
switch (result) {
case WAIT_OBJECT_0:
return true;
« no previous file with comments | « base/synchronization/waitable_event.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698