| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |