Sergey Ulanov | 7de7e9f | 2019-03-09 00:41:02 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors. All rights reserved. |
| 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 |
| 20 | // currently locked files. It support only exclusive locking, i.e. only one |
| 21 | // client can acquire SHARED_LOCK. |
| 22 | int FuchsiaVfsLock(sqlite3_file* sqlite_file, int file_lock); |
| 23 | int FuchsiaVfsUnlock(sqlite3_file* sqlite_file, int file_lock); |
| 24 | int FuchsiaVfsCheckReservedLock(sqlite3_file* sqlite_file, int* result); |
| 25 | |
| 26 | } // namespace sql |
| 27 | |
| 28 | #endif // SQL_VFS_WRAPPER_FUCHSIA_H_ |