| 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 "webkit/support/simple_database_system.h" | 5 #include "webkit/support/simple_database_system.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/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 base::WaitableEvent done_event(false, false); | 49 base::WaitableEvent done_event(false, false); |
| 50 db_thread_proxy_->PostTask( | 50 db_thread_proxy_->PostTask( |
| 51 FROM_HERE, | 51 FROM_HERE, |
| 52 base::Bind(&SimpleDatabaseSystem::ThreadCleanup, | 52 base::Bind(&SimpleDatabaseSystem::ThreadCleanup, |
| 53 base::Unretained(this), &done_event)); | 53 base::Unretained(this), &done_event)); |
| 54 done_event.Wait(); | 54 done_event.Wait(); |
| 55 instance_ = NULL; | 55 instance_ = NULL; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void SimpleDatabaseSystem::databaseOpened(const WebKit::WebDatabase& database) { | 58 void SimpleDatabaseSystem::databaseOpened(const WebKit::WebDatabase& database) { |
| 59 string16 origin_identifier = database.securityOrigin().databaseIdentifier(); | 59 base::string16 origin_identifier = |
| 60 string16 database_name = database.name(); | 60 database.securityOrigin().databaseIdentifier(); |
| 61 base::string16 database_name = database.name(); |
| 61 open_connections_->AddOpenConnection(origin_identifier, database_name); | 62 open_connections_->AddOpenConnection(origin_identifier, database_name); |
| 62 db_thread_proxy_->PostTask( | 63 db_thread_proxy_->PostTask( |
| 63 FROM_HERE, | 64 FROM_HERE, |
| 64 base::Bind(&SimpleDatabaseSystem::DatabaseOpened, | 65 base::Bind(&SimpleDatabaseSystem::DatabaseOpened, |
| 65 base::Unretained(this), | 66 base::Unretained(this), |
| 66 origin_identifier, | 67 origin_identifier, |
| 67 database_name, database.displayName(), | 68 database_name, database.displayName(), |
| 68 database.estimatedSize())); | 69 database.estimatedSize())); |
| 69 } | 70 } |
| 70 | 71 |
| 71 void SimpleDatabaseSystem::databaseModified( | 72 void SimpleDatabaseSystem::databaseModified( |
| 72 const WebKit::WebDatabase& database) { | 73 const WebKit::WebDatabase& database) { |
| 73 db_thread_proxy_->PostTask( | 74 db_thread_proxy_->PostTask( |
| 74 FROM_HERE, | 75 FROM_HERE, |
| 75 base::Bind(&SimpleDatabaseSystem::DatabaseModified, | 76 base::Bind(&SimpleDatabaseSystem::DatabaseModified, |
| 76 base::Unretained(this), | 77 base::Unretained(this), |
| 77 database.securityOrigin().databaseIdentifier(), | 78 database.securityOrigin().databaseIdentifier(), |
| 78 database.name())); | 79 database.name())); |
| 79 } | 80 } |
| 80 | 81 |
| 81 void SimpleDatabaseSystem::databaseClosed(const WebKit::WebDatabase& database) { | 82 void SimpleDatabaseSystem::databaseClosed(const WebKit::WebDatabase& database) { |
| 82 string16 origin_identifier = database.securityOrigin().databaseIdentifier(); | 83 base::string16 origin_identifier = |
| 83 string16 database_name = database.name(); | 84 database.securityOrigin().databaseIdentifier(); |
| 85 base::string16 database_name = database.name(); |
| 84 db_thread_proxy_->PostTask( | 86 db_thread_proxy_->PostTask( |
| 85 FROM_HERE, | 87 FROM_HERE, |
| 86 base::Bind(&SimpleDatabaseSystem::DatabaseClosed, | 88 base::Bind(&SimpleDatabaseSystem::DatabaseClosed, |
| 87 base::Unretained(this), origin_identifier, database_name)); | 89 base::Unretained(this), origin_identifier, database_name)); |
| 88 } | 90 } |
| 89 | 91 |
| 90 base::PlatformFile SimpleDatabaseSystem::OpenFile( | 92 base::PlatformFile SimpleDatabaseSystem::OpenFile( |
| 91 const string16& vfs_file_name, int desired_flags) { | 93 const base::string16& vfs_file_name, int desired_flags) { |
| 92 base::PlatformFile result = base::kInvalidPlatformFileValue; | 94 base::PlatformFile result = base::kInvalidPlatformFileValue; |
| 93 base::WaitableEvent done_event(false, false); | 95 base::WaitableEvent done_event(false, false); |
| 94 db_thread_proxy_->PostTask( | 96 db_thread_proxy_->PostTask( |
| 95 FROM_HERE, | 97 FROM_HERE, |
| 96 base::Bind(&SimpleDatabaseSystem::VfsOpenFile, | 98 base::Bind(&SimpleDatabaseSystem::VfsOpenFile, |
| 97 base::Unretained(this), | 99 base::Unretained(this), |
| 98 vfs_file_name, desired_flags, | 100 vfs_file_name, desired_flags, |
| 99 &result, &done_event)); | 101 &result, &done_event)); |
| 100 done_event.Wait(); | 102 done_event.Wait(); |
| 101 return result; | 103 return result; |
| 102 } | 104 } |
| 103 | 105 |
| 104 int SimpleDatabaseSystem::DeleteFile( | 106 int SimpleDatabaseSystem::DeleteFile( |
| 105 const string16& vfs_file_name, bool sync_dir) { | 107 const base::string16& vfs_file_name, bool sync_dir) { |
| 106 int result = SQLITE_OK; | 108 int result = SQLITE_OK; |
| 107 base::WaitableEvent done_event(false, false); | 109 base::WaitableEvent done_event(false, false); |
| 108 db_thread_proxy_->PostTask( | 110 db_thread_proxy_->PostTask( |
| 109 FROM_HERE, | 111 FROM_HERE, |
| 110 base::Bind(&SimpleDatabaseSystem::VfsDeleteFile, | 112 base::Bind(&SimpleDatabaseSystem::VfsDeleteFile, |
| 111 base::Unretained(this), | 113 base::Unretained(this), |
| 112 vfs_file_name, sync_dir, | 114 vfs_file_name, sync_dir, |
| 113 &result, &done_event)); | 115 &result, &done_event)); |
| 114 done_event.Wait(); | 116 done_event.Wait(); |
| 115 return result; | 117 return result; |
| 116 } | 118 } |
| 117 | 119 |
| 118 uint32 SimpleDatabaseSystem::GetFileAttributes(const string16& vfs_file_name) { | 120 uint32 SimpleDatabaseSystem::GetFileAttributes( |
| 121 const base::string16& vfs_file_name) { |
| 119 uint32 result = 0; | 122 uint32 result = 0; |
| 120 base::WaitableEvent done_event(false, false); | 123 base::WaitableEvent done_event(false, false); |
| 121 db_thread_proxy_->PostTask( | 124 db_thread_proxy_->PostTask( |
| 122 FROM_HERE, | 125 FROM_HERE, |
| 123 base::Bind(&SimpleDatabaseSystem::VfsGetFileAttributes, | 126 base::Bind(&SimpleDatabaseSystem::VfsGetFileAttributes, |
| 124 base::Unretained(this), vfs_file_name, &result, &done_event)); | 127 base::Unretained(this), vfs_file_name, &result, &done_event)); |
| 125 done_event.Wait(); | 128 done_event.Wait(); |
| 126 return result; | 129 return result; |
| 127 } | 130 } |
| 128 | 131 |
| 129 int64 SimpleDatabaseSystem::GetFileSize(const string16& vfs_file_name) { | 132 int64 SimpleDatabaseSystem::GetFileSize(const base::string16& vfs_file_name) { |
| 130 int64 result = 0; | 133 int64 result = 0; |
| 131 base::WaitableEvent done_event(false, false); | 134 base::WaitableEvent done_event(false, false); |
| 132 db_thread_proxy_->PostTask( | 135 db_thread_proxy_->PostTask( |
| 133 FROM_HERE, | 136 FROM_HERE, |
| 134 base::Bind(&SimpleDatabaseSystem::VfsGetFileSize, | 137 base::Bind(&SimpleDatabaseSystem::VfsGetFileSize, |
| 135 base::Unretained(this), vfs_file_name, &result, &done_event)); | 138 base::Unretained(this), vfs_file_name, &result, &done_event)); |
| 136 done_event.Wait(); | 139 done_event.Wait(); |
| 137 return result; | 140 return result; |
| 138 } | 141 } |
| 139 | 142 |
| 140 int64 SimpleDatabaseSystem::GetSpaceAvailable( | 143 int64 SimpleDatabaseSystem::GetSpaceAvailable( |
| 141 const string16& origin_identifier) { | 144 const base::string16& origin_identifier) { |
| 142 int64 result = 0; | 145 int64 result = 0; |
| 143 base::WaitableEvent done_event(false, false); | 146 base::WaitableEvent done_event(false, false); |
| 144 db_thread_proxy_->PostTask( | 147 db_thread_proxy_->PostTask( |
| 145 FROM_HERE, | 148 FROM_HERE, |
| 146 base::Bind(&SimpleDatabaseSystem::VfsGetSpaceAvailable, | 149 base::Bind(&SimpleDatabaseSystem::VfsGetSpaceAvailable, |
| 147 base::Unretained(this), origin_identifier, | 150 base::Unretained(this), origin_identifier, |
| 148 &result, &done_event)); | 151 &result, &done_event)); |
| 149 done_event.Wait(); | 152 done_event.Wait(); |
| 150 return result; | 153 return result; |
| 151 } | 154 } |
| 152 | 155 |
| 153 void SimpleDatabaseSystem::ClearAllDatabases() { | 156 void SimpleDatabaseSystem::ClearAllDatabases() { |
| 154 open_connections_->WaitForAllDatabasesToClose(); | 157 open_connections_->WaitForAllDatabasesToClose(); |
| 155 db_thread_proxy_->PostTask( | 158 db_thread_proxy_->PostTask( |
| 156 FROM_HERE, | 159 FROM_HERE, |
| 157 base::Bind(&SimpleDatabaseSystem::ResetTracker, base::Unretained(this))); | 160 base::Bind(&SimpleDatabaseSystem::ResetTracker, base::Unretained(this))); |
| 158 } | 161 } |
| 159 | 162 |
| 160 void SimpleDatabaseSystem::SetDatabaseQuota(int64 quota) { | 163 void SimpleDatabaseSystem::SetDatabaseQuota(int64 quota) { |
| 161 if (!db_thread_proxy_->BelongsToCurrentThread()) { | 164 if (!db_thread_proxy_->BelongsToCurrentThread()) { |
| 162 db_thread_proxy_->PostTask( | 165 db_thread_proxy_->PostTask( |
| 163 FROM_HERE, | 166 FROM_HERE, |
| 164 base::Bind(&SimpleDatabaseSystem::SetDatabaseQuota, | 167 base::Bind(&SimpleDatabaseSystem::SetDatabaseQuota, |
| 165 base::Unretained(this), quota)); | 168 base::Unretained(this), quota)); |
| 166 return; | 169 return; |
| 167 } | 170 } |
| 168 quota_per_origin_ = quota; | 171 quota_per_origin_ = quota; |
| 169 } | 172 } |
| 170 | 173 |
| 171 void SimpleDatabaseSystem::DatabaseOpened(const string16& origin_identifier, | 174 void SimpleDatabaseSystem::DatabaseOpened( |
| 172 const string16& database_name, | 175 const base::string16& origin_identifier, |
| 173 const string16& description, | 176 const base::string16& database_name, |
| 174 int64 estimated_size) { | 177 const base::string16& description, |
| 178 int64 estimated_size) { |
| 175 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 179 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 176 int64 database_size = 0; | 180 int64 database_size = 0; |
| 177 db_tracker_->DatabaseOpened( | 181 db_tracker_->DatabaseOpened( |
| 178 origin_identifier, database_name, description, | 182 origin_identifier, database_name, description, |
| 179 estimated_size, &database_size); | 183 estimated_size, &database_size); |
| 180 OnDatabaseSizeChanged(origin_identifier, database_name, | 184 OnDatabaseSizeChanged(origin_identifier, database_name, |
| 181 database_size); | 185 database_size); |
| 182 } | 186 } |
| 183 | 187 |
| 184 void SimpleDatabaseSystem::DatabaseModified(const string16& origin_identifier, | 188 void SimpleDatabaseSystem::DatabaseModified( |
| 185 const string16& database_name) { | 189 const base::string16& origin_identifier, |
| 190 const base::string16& database_name) { |
| 186 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 191 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 187 db_tracker_->DatabaseModified(origin_identifier, database_name); | 192 db_tracker_->DatabaseModified(origin_identifier, database_name); |
| 188 } | 193 } |
| 189 | 194 |
| 190 void SimpleDatabaseSystem::DatabaseClosed(const string16& origin_identifier, | 195 void SimpleDatabaseSystem::DatabaseClosed( |
| 191 const string16& database_name) { | 196 const base::string16& origin_identifier, |
| 197 const base::string16& database_name) { |
| 192 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 198 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 193 db_tracker_->DatabaseClosed(origin_identifier, database_name); | 199 db_tracker_->DatabaseClosed(origin_identifier, database_name); |
| 194 open_connections_->RemoveOpenConnection(origin_identifier, database_name); | 200 open_connections_->RemoveOpenConnection(origin_identifier, database_name); |
| 195 } | 201 } |
| 196 | 202 |
| 197 void SimpleDatabaseSystem::OnDatabaseSizeChanged( | 203 void SimpleDatabaseSystem::OnDatabaseSizeChanged( |
| 198 const string16& origin_identifier, | 204 const base::string16& origin_identifier, |
| 199 const string16& database_name, | 205 const base::string16& database_name, |
| 200 int64 database_size) { | 206 int64 database_size) { |
| 201 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 207 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 202 // We intentionally call into webkit on our background db_thread_ | 208 // We intentionally call into webkit on our background db_thread_ |
| 203 // to better emulate what happens in chrome where this method is | 209 // to better emulate what happens in chrome where this method is |
| 204 // invoked on the background ipc thread. | 210 // invoked on the background ipc thread. |
| 205 WebKit::WebDatabase::updateDatabaseSize( | 211 WebKit::WebDatabase::updateDatabaseSize( |
| 206 origin_identifier, database_name, database_size); | 212 origin_identifier, database_name, database_size); |
| 207 } | 213 } |
| 208 | 214 |
| 209 void SimpleDatabaseSystem::OnDatabaseScheduledForDeletion( | 215 void SimpleDatabaseSystem::OnDatabaseScheduledForDeletion( |
| 210 const string16& origin_identifier, | 216 const base::string16& origin_identifier, |
| 211 const string16& database_name) { | 217 const base::string16& database_name) { |
| 212 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 218 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 213 // We intentionally call into webkit on our background db_thread_ | 219 // We intentionally call into webkit on our background db_thread_ |
| 214 // to better emulate what happens in chrome where this method is | 220 // to better emulate what happens in chrome where this method is |
| 215 // invoked on the background ipc thread. | 221 // invoked on the background ipc thread. |
| 216 WebKit::WebDatabase::closeDatabaseImmediately( | 222 WebKit::WebDatabase::closeDatabaseImmediately( |
| 217 origin_identifier, database_name); | 223 origin_identifier, database_name); |
| 218 } | 224 } |
| 219 | 225 |
| 220 void SimpleDatabaseSystem::VfsOpenFile( | 226 void SimpleDatabaseSystem::VfsOpenFile( |
| 221 const string16& vfs_file_name, int desired_flags, | 227 const base::string16& vfs_file_name, int desired_flags, |
| 222 base::PlatformFile* file_handle, base::WaitableEvent* done_event ) { | 228 base::PlatformFile* file_handle, base::WaitableEvent* done_event ) { |
| 223 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 229 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 224 base::FilePath file_name = GetFullFilePathForVfsFile(vfs_file_name); | 230 base::FilePath file_name = GetFullFilePathForVfsFile(vfs_file_name); |
| 225 if (file_name.empty()) { | 231 if (file_name.empty()) { |
| 226 VfsBackend::OpenTempFileInDirectory( | 232 VfsBackend::OpenTempFileInDirectory( |
| 227 db_tracker_->DatabaseDirectory(), desired_flags, file_handle); | 233 db_tracker_->DatabaseDirectory(), desired_flags, file_handle); |
| 228 } else { | 234 } else { |
| 229 VfsBackend::OpenFile(file_name, desired_flags, file_handle); | 235 VfsBackend::OpenFile(file_name, desired_flags, file_handle); |
| 230 } | 236 } |
| 231 done_event->Signal(); | 237 done_event->Signal(); |
| 232 } | 238 } |
| 233 | 239 |
| 234 void SimpleDatabaseSystem::VfsDeleteFile( | 240 void SimpleDatabaseSystem::VfsDeleteFile( |
| 235 const string16& vfs_file_name, bool sync_dir, | 241 const base::string16& vfs_file_name, bool sync_dir, |
| 236 int* result, base::WaitableEvent* done_event) { | 242 int* result, base::WaitableEvent* done_event) { |
| 237 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 243 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 238 // We try to delete the file multiple times, because that's what the default | 244 // We try to delete the file multiple times, because that's what the default |
| 239 // VFS does (apparently deleting a file can sometimes fail on Windows). | 245 // VFS does (apparently deleting a file can sometimes fail on Windows). |
| 240 // We sleep for 10ms between retries for the same reason. | 246 // We sleep for 10ms between retries for the same reason. |
| 241 const int kNumDeleteRetries = 3; | 247 const int kNumDeleteRetries = 3; |
| 242 int num_retries = 0; | 248 int num_retries = 0; |
| 243 *result = SQLITE_OK; | 249 *result = SQLITE_OK; |
| 244 base::FilePath file_name = GetFullFilePathForVfsFile(vfs_file_name); | 250 base::FilePath file_name = GetFullFilePathForVfsFile(vfs_file_name); |
| 245 do { | 251 do { |
| 246 *result = VfsBackend::DeleteFile(file_name, sync_dir); | 252 *result = VfsBackend::DeleteFile(file_name, sync_dir); |
| 247 } while ((++num_retries < kNumDeleteRetries) && | 253 } while ((++num_retries < kNumDeleteRetries) && |
| 248 (*result == SQLITE_IOERR_DELETE) && | 254 (*result == SQLITE_IOERR_DELETE) && |
| 249 (base::PlatformThread::Sleep( | 255 (base::PlatformThread::Sleep( |
| 250 base::TimeDelta::FromMilliseconds(10)), | 256 base::TimeDelta::FromMilliseconds(10)), |
| 251 1)); | 257 1)); |
| 252 | 258 |
| 253 done_event->Signal(); | 259 done_event->Signal(); |
| 254 } | 260 } |
| 255 | 261 |
| 256 void SimpleDatabaseSystem::VfsGetFileAttributes( | 262 void SimpleDatabaseSystem::VfsGetFileAttributes( |
| 257 const string16& vfs_file_name, | 263 const base::string16& vfs_file_name, |
| 258 uint32* result, base::WaitableEvent* done_event) { | 264 uint32* result, base::WaitableEvent* done_event) { |
| 259 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 265 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 260 *result = VfsBackend::GetFileAttributes( | 266 *result = VfsBackend::GetFileAttributes( |
| 261 GetFullFilePathForVfsFile(vfs_file_name)); | 267 GetFullFilePathForVfsFile(vfs_file_name)); |
| 262 done_event->Signal(); | 268 done_event->Signal(); |
| 263 } | 269 } |
| 264 | 270 |
| 265 void SimpleDatabaseSystem::VfsGetFileSize( | 271 void SimpleDatabaseSystem::VfsGetFileSize( |
| 266 const string16& vfs_file_name, | 272 const base::string16& vfs_file_name, |
| 267 int64* result, base::WaitableEvent* done_event) { | 273 int64* result, base::WaitableEvent* done_event) { |
| 268 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 274 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 269 *result = VfsBackend::GetFileSize(GetFullFilePathForVfsFile(vfs_file_name)); | 275 *result = VfsBackend::GetFileSize(GetFullFilePathForVfsFile(vfs_file_name)); |
| 270 done_event->Signal(); | 276 done_event->Signal(); |
| 271 } | 277 } |
| 272 | 278 |
| 273 void SimpleDatabaseSystem::VfsGetSpaceAvailable( | 279 void SimpleDatabaseSystem::VfsGetSpaceAvailable( |
| 274 const string16& origin_identifier, | 280 const base::string16& origin_identifier, |
| 275 int64* result, base::WaitableEvent* done_event) { | 281 int64* result, base::WaitableEvent* done_event) { |
| 276 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 282 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 277 // This method isn't actually part of the "vfs" interface, but it is | 283 // This method isn't actually part of the "vfs" interface, but it is |
| 278 // used from within webcore and handled here in the same fashion. | 284 // used from within webcore and handled here in the same fashion. |
| 279 OriginInfo info; | 285 OriginInfo info; |
| 280 if (db_tracker_->GetOriginInfo(origin_identifier, &info)) { | 286 if (db_tracker_->GetOriginInfo(origin_identifier, &info)) { |
| 281 int64 space_available = quota_per_origin_ - info.TotalSize(); | 287 int64 space_available = quota_per_origin_ - info.TotalSize(); |
| 282 *result = space_available < 0 ? 0 : space_available; | 288 *result = space_available < 0 ? 0 : space_available; |
| 283 } else { | 289 } else { |
| 284 NOTREACHED(); | 290 NOTREACHED(); |
| 285 *result = 0; | 291 *result = 0; |
| 286 } | 292 } |
| 287 done_event->Signal(); | 293 done_event->Signal(); |
| 288 } | 294 } |
| 289 | 295 |
| 290 base::FilePath SimpleDatabaseSystem::GetFullFilePathForVfsFile( | 296 base::FilePath SimpleDatabaseSystem::GetFullFilePathForVfsFile( |
| 291 const string16& vfs_file_name) { | 297 const base::string16& vfs_file_name) { |
| 292 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 298 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 293 if (vfs_file_name.empty()) // temp file, used for vacuuming | 299 if (vfs_file_name.empty()) // temp file, used for vacuuming |
| 294 return base::FilePath(); | 300 return base::FilePath(); |
| 295 return DatabaseUtil::GetFullFilePathForVfsFile( | 301 return DatabaseUtil::GetFullFilePathForVfsFile( |
| 296 db_tracker_.get(), vfs_file_name); | 302 db_tracker_.get(), vfs_file_name); |
| 297 } | 303 } |
| 298 | 304 |
| 299 void SimpleDatabaseSystem::ResetTracker() { | 305 void SimpleDatabaseSystem::ResetTracker() { |
| 300 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 306 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 301 db_tracker_->CloseTrackerDatabaseAndClearCaches(); | 307 db_tracker_->CloseTrackerDatabaseAndClearCaches(); |
| 302 file_util::Delete(db_tracker_->DatabaseDirectory(), true); | 308 file_util::Delete(db_tracker_->DatabaseDirectory(), true); |
| 303 } | 309 } |
| 304 | 310 |
| 305 void SimpleDatabaseSystem::ThreadCleanup(base::WaitableEvent* done_event) { | 311 void SimpleDatabaseSystem::ThreadCleanup(base::WaitableEvent* done_event) { |
| 306 ResetTracker(); | 312 ResetTracker(); |
| 307 db_tracker_->RemoveObserver(this); | 313 db_tracker_->RemoveObserver(this); |
| 308 db_tracker_ = NULL; | 314 db_tracker_ = NULL; |
| 309 done_event->Signal(); | 315 done_event->Signal(); |
| 310 } | 316 } |
| 311 | 317 |
| OLD | NEW |