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/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 if (count) | 113 if (count) |
114 return false; | 114 return false; |
115 db_connections.erase(database_name); | 115 db_connections.erase(database_name); |
116 if (db_connections.empty()) | 116 if (db_connections.empty()) |
117 connections_.erase(origin_iterator); | 117 connections_.erase(origin_iterator); |
118 return true; | 118 return true; |
119 } | 119 } |
120 | 120 |
121 DatabaseConnectionsWrapper::DatabaseConnectionsWrapper() | 121 DatabaseConnectionsWrapper::DatabaseConnectionsWrapper() |
122 : waiting_for_dbs_to_close_(false), | 122 : waiting_for_dbs_to_close_(false), |
123 main_thread_(base::MessageLoopProxy::CreateForCurrentThread()) { | 123 main_thread_(base::MessageLoopProxy::current()) { |
124 } | 124 } |
125 | 125 |
126 DatabaseConnectionsWrapper::~DatabaseConnectionsWrapper() { | 126 DatabaseConnectionsWrapper::~DatabaseConnectionsWrapper() { |
127 } | 127 } |
128 | 128 |
129 void DatabaseConnectionsWrapper::WaitForAllDatabasesToClose() { | 129 void DatabaseConnectionsWrapper::WaitForAllDatabasesToClose() { |
130 // We assume that new databases won't be open while we're waiting. | 130 // We assume that new databases won't be open while we're waiting. |
131 DCHECK(main_thread_->BelongsToCurrentThread()); | 131 DCHECK(main_thread_->BelongsToCurrentThread()); |
132 if (HasOpenConnections()) { | 132 if (HasOpenConnections()) { |
133 AutoReset<bool> auto_reset(&waiting_for_dbs_to_close_, true); | 133 AutoReset<bool> auto_reset(&waiting_for_dbs_to_close_, true); |
(...skipping 27 matching lines...) Expand all Loading... |
161 origin_identifier, database_name)); | 161 origin_identifier, database_name)); |
162 return; | 162 return; |
163 } | 163 } |
164 base::AutoLock auto_lock(open_connections_lock_); | 164 base::AutoLock auto_lock(open_connections_lock_); |
165 open_connections_.RemoveConnection(origin_identifier, database_name); | 165 open_connections_.RemoveConnection(origin_identifier, database_name); |
166 if (waiting_for_dbs_to_close_ && open_connections_.IsEmpty()) | 166 if (waiting_for_dbs_to_close_ && open_connections_.IsEmpty()) |
167 MessageLoop::current()->Quit(); | 167 MessageLoop::current()->Quit(); |
168 } | 168 } |
169 | 169 |
170 } // namespace webkit_database | 170 } // namespace webkit_database |
OLD | NEW |