blob: e8c3c47eaba47148c8fc73c3715e4ea90f8dafb0 [file] [log] [blame]
Sergey Ulanov7de7e9f2019-03-09 00:41:021// 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
10namespace 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.
22int FuchsiaVfsLock(sqlite3_file* sqlite_file, int file_lock);
23int FuchsiaVfsUnlock(sqlite3_file* sqlite_file, int file_lock);
24int FuchsiaVfsCheckReservedLock(sqlite3_file* sqlite_file, int* result);
25
26} // namespace sql
27
28#endif // SQL_VFS_WRAPPER_FUCHSIA_H_