| OLD | NEW |
| 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 "webkit/database/database_connections.h" | 5 #include "webkit/database/database_connections.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 125 } |
| 126 | 126 |
| 127 DatabaseConnectionsWrapper::~DatabaseConnectionsWrapper() { | 127 DatabaseConnectionsWrapper::~DatabaseConnectionsWrapper() { |
| 128 } | 128 } |
| 129 | 129 |
| 130 void DatabaseConnectionsWrapper::WaitForAllDatabasesToClose() { | 130 void DatabaseConnectionsWrapper::WaitForAllDatabasesToClose() { |
| 131 // We assume that new databases won't be open while we're waiting. | 131 // We assume that new databases won't be open while we're waiting. |
| 132 DCHECK(main_thread_->BelongsToCurrentThread()); | 132 DCHECK(main_thread_->BelongsToCurrentThread()); |
| 133 if (HasOpenConnections()) { | 133 if (HasOpenConnections()) { |
| 134 AutoReset<bool> auto_reset(&waiting_for_dbs_to_close_, true); | 134 AutoReset<bool> auto_reset(&waiting_for_dbs_to_close_, true); |
| 135 MessageLoop::ScopedNestableTaskAllower nestable(MessageLoop::current()); | 135 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); |
| 136 MessageLoop::current()->Run(); | 136 MessageLoop::current()->Run(); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 bool DatabaseConnectionsWrapper::HasOpenConnections() { | 140 bool DatabaseConnectionsWrapper::HasOpenConnections() { |
| 141 DCHECK(main_thread_->BelongsToCurrentThread()); | 141 DCHECK(main_thread_->BelongsToCurrentThread()); |
| 142 base::AutoLock auto_lock(open_connections_lock_); | 142 base::AutoLock auto_lock(open_connections_lock_); |
| 143 return !open_connections_.IsEmpty(); | 143 return !open_connections_.IsEmpty(); |
| 144 } | 144 } |
| 145 | 145 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 163 origin_identifier, database_name)); | 163 origin_identifier, database_name)); |
| 164 return; | 164 return; |
| 165 } | 165 } |
| 166 base::AutoLock auto_lock(open_connections_lock_); | 166 base::AutoLock auto_lock(open_connections_lock_); |
| 167 open_connections_.RemoveConnection(origin_identifier, database_name); | 167 open_connections_.RemoveConnection(origin_identifier, database_name); |
| 168 if (waiting_for_dbs_to_close_ && open_connections_.IsEmpty()) | 168 if (waiting_for_dbs_to_close_ && open_connections_.IsEmpty()) |
| 169 MessageLoop::current()->Quit(); | 169 MessageLoop::current()->Quit(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 } // namespace webkit_database | 172 } // namespace webkit_database |
| OLD | NEW |