diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-29 19:58:30 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-29 19:58:30 +0000 |
commit | c93efc7c5e34959ff4f828f242381b0f6eacf6cf (patch) | |
tree | 0d4944abadc18f97ec089d80644dd15266e15caf /webkit/database/vfs_backend.cc | |
parent | 5bd97204ef6dfa26357cf128d8fbcab84fca42f0 (diff) | |
download | chromium_src-c93efc7c5e34959ff4f828f242381b0f6eacf6cf.zip chromium_src-c93efc7c5e34959ff4f828f242381b0f6eacf6cf.tar.gz chromium_src-c93efc7c5e34959ff4f828f242381b0f6eacf6cf.tar.bz2 |
Random style fixes in the database backend.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/340004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30497 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/database/vfs_backend.cc')
-rw-r--r-- | webkit/database/vfs_backend.cc | 117 |
1 files changed, 59 insertions, 58 deletions
diff --git a/webkit/database/vfs_backend.cc b/webkit/database/vfs_backend.cc index 8d84dbd..96e0b27 100644 --- a/webkit/database/vfs_backend.cc +++ b/webkit/database/vfs_backend.cc @@ -72,73 +72,74 @@ void VfsBackend::OpenFile(const FilePath& file_name, base::PlatformFile* target_dir_handle) { // Verify the flags for consistency and create the database // directory if it doesn't exist. - if (OpenFileFlagsAreConsistent(file_name, db_dir, desired_flags) && - file_util::CreateDirectory(db_dir)) { - int flags = 0; - flags |= base::PLATFORM_FILE_READ; - if (desired_flags & SQLITE_OPEN_READWRITE) - flags |= base::PLATFORM_FILE_WRITE; - - if (!(desired_flags & SQLITE_OPEN_MAIN_DB)) { - flags |= base::PLATFORM_FILE_EXCLUSIVE_READ | - base::PLATFORM_FILE_EXCLUSIVE_WRITE; - } + if (!OpenFileFlagsAreConsistent(file_name, db_dir, desired_flags) || + !file_util::CreateDirectory(db_dir)) + return; + + int flags = 0; + flags |= base::PLATFORM_FILE_READ; + if (desired_flags & SQLITE_OPEN_READWRITE) + flags |= base::PLATFORM_FILE_WRITE; + + if (!(desired_flags & SQLITE_OPEN_MAIN_DB)) { + flags |= base::PLATFORM_FILE_EXCLUSIVE_READ | + base::PLATFORM_FILE_EXCLUSIVE_WRITE; + } - flags |= ((desired_flags & SQLITE_OPEN_CREATE) ? - base::PLATFORM_FILE_OPEN_ALWAYS : base::PLATFORM_FILE_OPEN); + flags |= ((desired_flags & SQLITE_OPEN_CREATE) ? + base::PLATFORM_FILE_OPEN_ALWAYS : base::PLATFORM_FILE_OPEN); - if (desired_flags & SQLITE_OPEN_EXCLUSIVE) { - flags |= base::PLATFORM_FILE_EXCLUSIVE_READ | - base::PLATFORM_FILE_EXCLUSIVE_WRITE; - } + if (desired_flags & SQLITE_OPEN_EXCLUSIVE) { + flags |= base::PLATFORM_FILE_EXCLUSIVE_READ | + base::PLATFORM_FILE_EXCLUSIVE_WRITE; + } - if (desired_flags & SQLITE_OPEN_DELETEONCLOSE) { - flags |= base::PLATFORM_FILE_TEMPORARY | base::PLATFORM_FILE_HIDDEN | - base::PLATFORM_FILE_DELETE_ON_CLOSE; - } + if (desired_flags & SQLITE_OPEN_DELETEONCLOSE) { + flags |= base::PLATFORM_FILE_TEMPORARY | base::PLATFORM_FILE_HIDDEN | + base::PLATFORM_FILE_DELETE_ON_CLOSE; + } - // If this is a request for a handle to a temp file, get a unique file name - FilePath db_file_name; - if (file_name == db_dir) { - if (!file_util::CreateTemporaryFileInDir(db_dir, &db_file_name)) - db_file_name = FilePath(); - } else { - db_file_name = file_name; - } + // If this is a request for a handle to a temp file, get a unique file name. + FilePath db_file_name; + if (file_name == db_dir) { + if (!file_util::CreateTemporaryFileInDir(db_dir, &db_file_name)) + db_file_name = FilePath(); + } else { + db_file_name = file_name; + } - // Try to open/create the DB file. - base::PlatformFile file_handle = (db_file_name.empty() ? - base::kInvalidPlatformFileValue : - base::CreatePlatformFile(db_file_name.ToWStringHack(), flags, NULL)); - if (file_handle != base::kInvalidPlatformFileValue) { + // Try to open/create the DB file. + base::PlatformFile file_handle = (db_file_name.empty() ? + base::kInvalidPlatformFileValue : + base::CreatePlatformFile(db_file_name.ToWStringHack(), flags, NULL)); + if (file_handle != base::kInvalidPlatformFileValue) { #if defined(OS_WIN) - // Duplicate the file handle. - if (!DuplicateHandle(GetCurrentProcess(), file_handle, - handle, target_handle, 0, false, - DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) { - // file_handle is closed whether or not DuplicateHandle succeeds. - *target_handle = INVALID_HANDLE_VALUE; - } + // Duplicate the file handle. + if (!DuplicateHandle(GetCurrentProcess(), file_handle, + handle, target_handle, 0, false, + DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) { + // file_handle is closed whether or not DuplicateHandle succeeds. + *target_handle = INVALID_HANDLE_VALUE; + } #elif defined(OS_POSIX) - *target_handle = file_handle; - - int file_type = desired_flags & 0x00007F00; - bool creating_new_file = (desired_flags & SQLITE_OPEN_CREATE); - if (creating_new_file && ((file_type == SQLITE_OPEN_MASTER_JOURNAL) || - (file_type == SQLITE_OPEN_MAIN_JOURNAL))) { - // We return a handle to the containing directory because on POSIX - // systems the VFS might want to fsync it after changing a file. - // By returning it here, we avoid an extra IPC call. - *target_dir_handle = base::CreatePlatformFile( - db_dir.ToWStringHack(), - base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, NULL); - if (*target_dir_handle == base::kInvalidPlatformFileValue) { - base::ClosePlatformFile(*target_handle); - *target_handle = base::kInvalidPlatformFileValue; - } + *target_handle = file_handle; + + int file_type = desired_flags & 0x00007F00; + bool creating_new_file = (desired_flags & SQLITE_OPEN_CREATE); + if (creating_new_file && ((file_type == SQLITE_OPEN_MASTER_JOURNAL) || + (file_type == SQLITE_OPEN_MAIN_JOURNAL))) { + // We return a handle to the containing directory because on POSIX + // systems the VFS might want to fsync it after changing a file. + // By returning it here, we avoid an extra IPC call. + *target_dir_handle = base::CreatePlatformFile( + db_dir.ToWStringHack(), + base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, NULL); + if (*target_dir_handle == base::kInvalidPlatformFileValue) { + base::ClosePlatformFile(*target_handle); + *target_handle = base::kInvalidPlatformFileValue; } -#endif } +#endif } } |