| 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/vfs_backend.h" | 5 #include "webkit/database/vfs_backend.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "third_party/sqlite/sqlite3.h" | 10 #include "third_party/sqlite/sqlite3.h" |
| 11 | 11 |
| 12 namespace webkit_database { | 12 namespace webkit_database { |
| 13 | 13 |
| 14 static const int kFileTypeMask = 0x00007F00; | 14 static const int kFileTypeMask = 0x00007F00; |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 bool VfsBackend::FileTypeIsMainDB(int desired_flags) { | |
| 18 return (desired_flags & kFileTypeMask) == SQLITE_OPEN_MAIN_DB; | |
| 19 } | |
| 20 | |
| 21 // static | |
| 22 bool VfsBackend::FileTypeIsJournal(int desired_flags) { | |
| 23 int file_type = desired_flags & kFileTypeMask; | |
| 24 return ((file_type == SQLITE_OPEN_MAIN_JOURNAL) || | |
| 25 (file_type == SQLITE_OPEN_TEMP_JOURNAL) || | |
| 26 (file_type == SQLITE_OPEN_SUBJOURNAL) || | |
| 27 (file_type == SQLITE_OPEN_MASTER_JOURNAL)); | |
| 28 } | |
| 29 | |
| 30 // static | |
| 31 bool VfsBackend::OpenTypeIsReadWrite(int desired_flags) { | 17 bool VfsBackend::OpenTypeIsReadWrite(int desired_flags) { |
| 32 return (desired_flags & SQLITE_OPEN_READWRITE) != 0; | 18 return (desired_flags & SQLITE_OPEN_READWRITE) != 0; |
| 33 } | 19 } |
| 34 | 20 |
| 35 // static | 21 // static |
| 36 bool VfsBackend::OpenFileFlagsAreConsistent(int desired_flags) { | 22 bool VfsBackend::OpenFileFlagsAreConsistent(int desired_flags) { |
| 37 const int file_type = desired_flags & kFileTypeMask; | 23 const int file_type = desired_flags & kFileTypeMask; |
| 38 const bool is_exclusive = (desired_flags & SQLITE_OPEN_EXCLUSIVE) != 0; | 24 const bool is_exclusive = (desired_flags & SQLITE_OPEN_EXCLUSIVE) != 0; |
| 39 const bool is_delete = (desired_flags & SQLITE_OPEN_DELETEONCLOSE) != 0; | 25 const bool is_delete = (desired_flags & SQLITE_OPEN_DELETEONCLOSE) != 0; |
| 40 const bool is_create = (desired_flags & SQLITE_OPEN_CREATE) != 0; | 26 const bool is_create = (desired_flags & SQLITE_OPEN_CREATE) != 0; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 return attributes; | 158 return attributes; |
| 173 } | 159 } |
| 174 | 160 |
| 175 // static | 161 // static |
| 176 int64 VfsBackend::GetFileSize(const FilePath& file_path) { | 162 int64 VfsBackend::GetFileSize(const FilePath& file_path) { |
| 177 int64 size = 0; | 163 int64 size = 0; |
| 178 return (file_util::GetFileSize(file_path, &size) ? size : 0); | 164 return (file_util::GetFileSize(file_path, &size) ? size : 0); |
| 179 } | 165 } |
| 180 | 166 |
| 181 } // namespace webkit_database | 167 } // namespace webkit_database |
| OLD | NEW |