Avi Drissman | 69b874f | 2022-09-15 19:11:14 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors |
Sergey Ulanov | 7de7e9f | 2019-03-09 00:41:02 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef SQL_VFS_WRAPPER_FUCHSIA_H_ |
| 6 | #define SQL_VFS_WRAPPER_FUCHSIA_H_ |
| 7 | |
| 8 | #include "third_party/sqlite/sqlite3.h" |
| 9 | |
| 10 | namespace sql { |
| 11 | |
| 12 | // Fuchsia doesn't provide a file locking mechanism like flock(). These |
| 13 | // functions are used to simulate file locking. On Fuchsia profile directories |
| 14 | // are not expected to be shared with other processes and therefore only one |
| 15 | // browser process may access sqlite files. These functions are designed to |
| 16 | // handle the case when the same sqlite database is open more than once from the |
| 17 | // same browser process. In most cases databases do not need to be open more |
| 18 | // than once, i.e. contention is expected to be rare, so the main goal of the |
| 19 | // design is simplicity and not performance. The manager maintains a list of all |
Bryant Chandler | 41d66e78 | 2022-02-16 15:44:01 | [diff] [blame] | 20 | // currently locked files. |
| 21 | int Lock(sqlite3_file* sqlite_file, int file_lock); |
| 22 | int Unlock(sqlite3_file* sqlite_file, int file_lock); |
| 23 | int CheckReservedLock(sqlite3_file* sqlite_file, int* result); |
Sergey Ulanov | 7de7e9f | 2019-03-09 00:41:02 | [diff] [blame] | 24 | |
| 25 | } // namespace sql |
| 26 | |
Bryant Chandler | 41d66e78 | 2022-02-16 15:44:01 | [diff] [blame] | 27 | #endif // SQL_VFS_WRAPPER_FUCHSIA_H_ |