Commit Graph

2 Commits

Author SHA1 Message Date
Lina Cambridge
2276deaa8d Bug 1539697 - Report more detailed errors in the mozStorage Rust binding. r=mak,tcsc
The `nsresult` codes that mozStorage returns are often too generic. For
example, `NS_ERROR_FAILURE` might be anything from a SQL syntax error
to an invalid column name in a trigger.

This commit adds a `Conn::call_and_wrap_error` helper that checks the
last SQLite error, and returns that instead of `nsresult`. Not all
errors are SQLite errors, however, so we only use this for mozStorage
methods that return `convertResultCode`.

Differential Revision: https://phabricator.services.mozilla.com/D25179

--HG--
extra : moz-landing-system : lando
2019-04-02 16:56:41 +00:00
Lina Cambridge
3e894ac30e Bug 1482608 - Add basic Rust bindings for mozStorage. r=nika,asuth,mak
This commit wraps just enough of the mozStorage API to support the
bookmarks mirror. It's not complete: for example, there's no way
to open, clone, or close a connection, because the mirror handles
that from JS. The wrapper also omits shutdown blocking and retrying on
`SQLITE_BUSY`.

This commit also changes the behavior of sync and async mozStorage
connections. Async (`mozIStorageAsyncConnection`) methods may be called
from any thread on any connection. Sync (`mozIStorageConnection`)
methods may be called from any thread on a sync connection, and from
background threads on an async connection. All connections now QI
to `mozIStorageConnection`, but attempting to call a sync method on
an async connection from the main thread throws.

Finally, this commit exposes an `OpenedConnection::unsafeRawConnection`
getter in Sqlite.jsm, for JS code to access the underlying connection.

Differential Revision: https://phabricator.services.mozilla.com/D20073

--HG--
extra : moz-landing-system : lando
2019-03-25 04:49:18 +00:00