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

Side by Side Diff: storage/common/database/database_connections.cc

Issue 2031703002: Migrate WaitableEvent to enum-based constructor in storage/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "storage/common/database/database_connections.h" 5 #include "storage/common/database/database_connections.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 const std::string& origin_identifier, 146 const std::string& origin_identifier,
147 const base::string16& database_name) { 147 const base::string16& database_name) {
148 base::AutoLock auto_lock(open_connections_lock_); 148 base::AutoLock auto_lock(open_connections_lock_);
149 open_connections_.RemoveConnection(origin_identifier, database_name); 149 open_connections_.RemoveConnection(origin_identifier, database_name);
150 if (waiting_to_close_event_ && open_connections_.IsEmpty()) 150 if (waiting_to_close_event_ && open_connections_.IsEmpty())
151 waiting_to_close_event_->Signal(); 151 waiting_to_close_event_->Signal();
152 } 152 }
153 153
154 bool DatabaseConnectionsWrapper::WaitForAllDatabasesToClose( 154 bool DatabaseConnectionsWrapper::WaitForAllDatabasesToClose(
155 base::TimeDelta timeout) { 155 base::TimeDelta timeout) {
156 base::WaitableEvent waitable_event(true, false); 156 base::WaitableEvent waitable_event(
157 base::WaitableEvent::ResetPolicy::MANUAL,
158 base::WaitableEvent::InitialState::NOT_SIGNALED);
157 { 159 {
158 base::AutoLock auto_lock(open_connections_lock_); 160 base::AutoLock auto_lock(open_connections_lock_);
159 if (open_connections_.IsEmpty()) 161 if (open_connections_.IsEmpty())
160 return true; 162 return true;
161 waiting_to_close_event_ = &waitable_event; 163 waiting_to_close_event_ = &waitable_event;
162 } 164 }
163 waitable_event.TimedWait(timeout); 165 waitable_event.TimedWait(timeout);
164 { 166 {
165 base::AutoLock auto_lock(open_connections_lock_); 167 base::AutoLock auto_lock(open_connections_lock_);
166 waiting_to_close_event_ = nullptr; 168 waiting_to_close_event_ = nullptr;
167 return open_connections_.IsEmpty(); 169 return open_connections_.IsEmpty();
168 } 170 }
169 } 171 }
170 172
171 } // namespace storage 173 } // namespace storage
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698