base: Add shared lock support to base::File::Lock().

base::File::{Lock, Unlock}() currently always take exclusive locks. This
isn't sufficient for implementing some locking protocols, such as the
protocol used by SQLite to coordinate access to its database files.

We currently get away with this functionality gap because Chrome uses
SQLite's built-in VFS implementations, which bypass base::File and
access the underlying libraries directly. However, shared lock support
becomes necessary if we want to implement a SQLite VFS on top of
base::File.

Fortunately, all underlying platforms support requesting both shared and
exclusive locks on files. This CL exposes this support by adding a bit
of plumbing and corresponding tests.

Bug: 925739
Change-Id: I9934a9cbfdba3a9ad158486c48ab10a763a1a498
Reviewed-on: https://chromium-review.googlesource.com/c/1438122
Commit-Queue: Victor Costan <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Cr-Commit-Position: refs/heads/master@{#626672}
4 files changed