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

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

Issue 2561963002: base: Remove the string logging from CHECK(). (Closed)
Patch Set: checkstring: rebase Created 4 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 (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.h" 5 #include "base/synchronization/waitable_event.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 13 matching lines...) Expand all
24 reset_policy == ResetPolicy::MANUAL, 24 reset_policy == ResetPolicy::MANUAL,
25 initial_state == InitialState::SIGNALED, 25 initial_state == InitialState::SIGNALED,
26 nullptr)) { 26 nullptr)) {
27 // We're probably going to crash anyways if this is ever NULL, so we might as 27 // We're probably going to crash anyways if this is ever NULL, so we might as
28 // well make our stack reports more informative by crashing here. 28 // well make our stack reports more informative by crashing here.
29 CHECK(handle_.IsValid()); 29 CHECK(handle_.IsValid());
30 } 30 }
31 31
32 WaitableEvent::WaitableEvent(win::ScopedHandle handle) 32 WaitableEvent::WaitableEvent(win::ScopedHandle handle)
33 : handle_(std::move(handle)) { 33 : handle_(std::move(handle)) {
34 CHECK(handle_.IsValid()) << "Tried to create WaitableEvent from NULL handle"; 34 // Tried to create WaitableEvent from NULL handle
35 CHECK(handle_.IsValid());
35 } 36 }
36 37
37 WaitableEvent::~WaitableEvent() = default; 38 WaitableEvent::~WaitableEvent() = default;
38 39
39 void WaitableEvent::Reset() { 40 void WaitableEvent::Reset() {
40 ResetEvent(handle_.Get()); 41 ResetEvent(handle_.Get());
41 } 42 }
42 43
43 void WaitableEvent::Signal() { 44 void WaitableEvent::Signal() {
44 SetEvent(handle_.Get()); 45 SetEvent(handle_.Get());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 130
130 // static 131 // static
131 size_t WaitableEvent::WaitMany(WaitableEvent** events, size_t count) { 132 size_t WaitableEvent::WaitMany(WaitableEvent** events, size_t count) {
132 DCHECK(count) << "Cannot wait on no events"; 133 DCHECK(count) << "Cannot wait on no events";
133 134
134 base::ThreadRestrictions::AssertWaitAllowed(); 135 base::ThreadRestrictions::AssertWaitAllowed();
135 // Record an event (the first) that this thread is blocking upon. 136 // Record an event (the first) that this thread is blocking upon.
136 base::debug::ScopedEventWaitActivity event_activity(events[0]); 137 base::debug::ScopedEventWaitActivity event_activity(events[0]);
137 138
138 HANDLE handles[MAXIMUM_WAIT_OBJECTS]; 139 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
139 CHECK_LE(count, static_cast<size_t>(MAXIMUM_WAIT_OBJECTS)) 140 // Can only wait on |MAXIMUM_WAIT_OBJECTS| with WaitMany
140 << "Can only wait on " << MAXIMUM_WAIT_OBJECTS << " with WaitMany"; 141 CHECK_LE(count, static_cast<size_t>(MAXIMUM_WAIT_OBJECTS));
141 142
142 for (size_t i = 0; i < count; ++i) 143 for (size_t i = 0; i < count; ++i)
143 handles[i] = events[i]->handle(); 144 handles[i] = events[i]->handle();
144 145
145 // The cast is safe because count is small - see the CHECK above. 146 // The cast is safe because count is small - see the CHECK above.
146 DWORD result = 147 DWORD result =
147 WaitForMultipleObjects(static_cast<DWORD>(count), 148 WaitForMultipleObjects(static_cast<DWORD>(count),
148 handles, 149 handles,
149 FALSE, // don't wait for all the objects 150 FALSE, // don't wait for all the objects
150 INFINITE); // no timeout 151 INFINITE); // no timeout
151 if (result >= WAIT_OBJECT_0 + count) { 152 if (result >= WAIT_OBJECT_0 + count) {
152 DPLOG(FATAL) << "WaitForMultipleObjects failed"; 153 DPLOG(FATAL) << "WaitForMultipleObjects failed";
153 return 0; 154 return 0;
154 } 155 }
155 156
156 return result - WAIT_OBJECT_0; 157 return result - WAIT_OBJECT_0;
157 } 158 }
158 159
159 } // namespace base 160 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698