Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor places connection management #718

merged 16 commits into from Mar 5, 2019
Changes from 15 commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now

@@ -4,6 +4,40 @@

[Full Changelog](

## Places

## What's New

- A massive rewrite of the Kotlin API has been completed. This distinguishes
reader and writer connections. A brief description of the new types follows.
Note that all the types have corresponding interfaces that allow for them to
be mocked during testing as needed. ([#718](
- `PlacesApi`: This is similar to a connection pool, it exists to give out
reader and writer connections via the functions `openReader` and
`getWriter`. The naming distinction is due to there only being a single
writer connection (which is actually opened when the `PlacesApi` is
created). This class generally should be a singleton.
- In addition to `openReader` and `getWriter`, this also includes the
`sync()` method, as that requires a special type of connection.
- `ReadablePlacesConnection`: This is a read-only connection to the places
database, implements all the methods of the API that do not require write
- Specifically, `getVisited`, `matchUrl`, `queryAutocomplete`, `interrupt`,
`getVisitedUrlsInRange`, and `getVisitInfos` all exist on this object.
- `WritablePlacesConnection`: This is a read-write connection, and as such,
contains not only the all reader methods mentioned above, but also the
methods requiring write access, such as:
- `noteObservation`, `wipeLocal`, `runMaintenance`, `pruneDestructively`,
`deleteEverything`, `deletePlace`, `deleteVisitsSince`, `deleteVisitsBetween`,
and `deleteVisit`.
- Note that the semantics of the various methods have not been changed, only
their location.

## Breaking Changes

- Almost the entire API has been rewritten. See "What's New" for
details. ([#718](

# 0.18.0 (_2019-02-27_)

[Full Changelog](
@@ -48,11 +48,18 @@ internal interface LibPlacesFFI : Library {
// String will work but either force us to leak them, or cause us to corrupt the heap (when we
// free them).

/** Create a new places connection */
fun places_connection_new(
/** Create a new places api */
fun places_api_new(
db_path: String,
encryption_key: String?,
out_err: RustError.ByReference
): PlacesApiHandle

/** Create a new places connection */
fun places_connection_new(
handle: PlacesApiHandle,
conn_type: Int,
out_err: RustError.ByReference
): PlacesConnectionHandle

fun places_note_observation(
@@ -166,16 +173,24 @@ internal interface LibPlacesFFI : Library {
/** Destroy strings returned from libplaces_ffi calls. */
fun places_destroy_string(s: Pointer)

/** Destroy connection created using `places_connection_new` */
fun places_api_return_write_conn(apiHandle: PlacesApiHandle,
writeHandle: PlacesConnectionHandle,
err: RustError.ByReference)

/** Destroy connection created using `places_connection_new` */
fun places_connection_destroy(handle: PlacesConnectionHandle, out_err: RustError.ByReference)

/** Destroy api created using `places_api_new` */
fun places_api_destroy(handle: PlacesApiHandle, out_err: RustError.ByReference)

/** Destroy handle created using `places_new_interrupt_handle` */
fun places_interrupt_handle_destroy(obj: RawPlacesInterruptHandle)

fun places_destroy_bytebuffer(bb: RustBuffer.ByValue)

internal typealias PlacesConnectionHandle = Long;
internal typealias PlacesApiHandle = Long;

// This doesn't use a handle to avoid unnecessary locking and
// because the type is panic safe, sync, and send.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.