OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/tools/test_shell/simple_database_system.h" | 5 #include "webkit/tools/test_shell/simple_database_system.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/platform_thread.h" |
10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
11 #include "third_party/sqlite/sqlite3.h" | 12 #include "third_party/sqlite/sqlite3.h" |
12 #include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" | 13 #include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" |
13 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 14 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
14 #include "webkit/database/database_util.h" | 15 #include "webkit/database/database_util.h" |
15 #include "webkit/database/vfs_backend.h" | 16 #include "webkit/database/vfs_backend.h" |
16 | 17 |
17 using webkit_database::DatabaseTracker; | 18 using webkit_database::DatabaseTracker; |
18 using webkit_database::DatabaseUtil; | 19 using webkit_database::DatabaseUtil; |
19 using webkit_database::VfsBackend; | 20 using webkit_database::VfsBackend; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // VFS does (apparently deleting a file can sometimes fail on Windows). | 60 // VFS does (apparently deleting a file can sometimes fail on Windows). |
60 // We sleep for 10ms between retries for the same reason. | 61 // We sleep for 10ms between retries for the same reason. |
61 const int kNumDeleteRetries = 3; | 62 const int kNumDeleteRetries = 3; |
62 int num_retries = 0; | 63 int num_retries = 0; |
63 int error_code = SQLITE_OK; | 64 int error_code = SQLITE_OK; |
64 FilePath file_name = GetFullFilePathForVfsFile(vfs_file_name); | 65 FilePath file_name = GetFullFilePathForVfsFile(vfs_file_name); |
65 do { | 66 do { |
66 error_code = VfsBackend::DeleteFile(file_name, sync_dir); | 67 error_code = VfsBackend::DeleteFile(file_name, sync_dir); |
67 } while ((++num_retries < kNumDeleteRetries) && | 68 } while ((++num_retries < kNumDeleteRetries) && |
68 (error_code == SQLITE_IOERR_DELETE) && | 69 (error_code == SQLITE_IOERR_DELETE) && |
69 (PlatformThread::Sleep(10), 1)); | 70 (base::PlatformThread::Sleep(10), 1)); |
70 | 71 |
71 return error_code; | 72 return error_code; |
72 } | 73 } |
73 | 74 |
74 long SimpleDatabaseSystem::GetFileAttributes(const string16& vfs_file_name) { | 75 long SimpleDatabaseSystem::GetFileAttributes(const string16& vfs_file_name) { |
75 return VfsBackend::GetFileAttributes( | 76 return VfsBackend::GetFileAttributes( |
76 GetFullFilePathForVfsFile(vfs_file_name)); | 77 GetFullFilePathForVfsFile(vfs_file_name)); |
77 } | 78 } |
78 | 79 |
79 long long SimpleDatabaseSystem::GetFileSize(const string16& vfs_file_name) { | 80 long long SimpleDatabaseSystem::GetFileSize(const string16& vfs_file_name) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 184 |
184 FilePath SimpleDatabaseSystem::GetFullFilePathForVfsFile( | 185 FilePath SimpleDatabaseSystem::GetFullFilePathForVfsFile( |
185 const string16& vfs_file_name) { | 186 const string16& vfs_file_name) { |
186 if (vfs_file_name.empty()) // temp file, used for vacuuming | 187 if (vfs_file_name.empty()) // temp file, used for vacuuming |
187 return FilePath(); | 188 return FilePath(); |
188 | 189 |
189 AutoLock file_names_auto_lock(file_names_lock_); | 190 AutoLock file_names_auto_lock(file_names_lock_); |
190 DCHECK(file_names_.find(vfs_file_name) != file_names_.end()); | 191 DCHECK(file_names_.find(vfs_file_name) != file_names_.end()); |
191 return file_names_[vfs_file_name]; | 192 return file_names_[vfs_file_name]; |
192 } | 193 } |
OLD | NEW |