Граф коммитов

432 Коммитов

Автор SHA1 Сообщение Дата
Jan Varga 150cf2ce62 Bug 1286798 - Part 41: Implement QuotaClient::AbortOperationsForProcess; r=asuth
Needed for snapshot reusing.
2018-11-29 21:49:27 +01:00
Jan Varga 8d2b3b583d Bug 1286798 - Part 39: Reduce number of hash lookups; r=asuth 2018-11-29 21:49:20 +01:00
Jan Varga f2c1577652 Bug 1286798 - Part 38: Cache items in an array; r=asuth
Items are now cached also in an array (besides a hashtable). This gives us very fast snapshot initizilization for datastores that fit into the prefill limit. String buffers are reference counted, so memory footprint is only affected by the size of nsString.
This patch also introduces a WriteOptimizer which is an abstraction for collecting, coalescing and applying write operations.
2018-11-29 21:49:17 +01:00
Jan Varga 05662ca09e Bug 1286798 - Part 37: Always preallocate quota when initializing a snapshot; r=asuth
Besides always preallocating quota we now also preallocate more. This mitigates number of additional sync calls.
2018-11-29 21:49:14 +01:00
Jan Varga 5809f14bbd Bug 1286798 - Part 36: Allow snapshot initialization to a specific load state; r=asuth
Before this patch, it was only possible to initialize a snapshot to the Partial state or AllOrderedItems state. Now there's a third state AllOrderedKeys.
This improves performance by eliminating sync calls to parent process when we know nothing about a key in content process (in that case we have to use a sync call to the parent process to see if there's a value for it).
With this patch we always try to send all keys to content when a snapshot is being initialized. For this to work efficiently, we cache the size of all keys.
Having cached size of all keys also allows us to just iterate the mValues hashtable when the size of keys is bigger than snapshot prefill threshold (instead of iterating over the mKeys array and joining with mValues for each particular key).
There's some additional cleanup in snapshot info construction and Datastore::SetItem/RemoveItem/Clear methods.
2018-11-29 21:49:10 +01:00
Jan Varga ec6ab2e194 Bug 1286798 - Part 35: Implement database shadowing; r=asuth,janv
This adds synchronization to the global database used by previous local storage implementation.

This patch was enhanced by asuth to bind attached database path.
Places has shown that argument binding is necessary.  (Profiles may include usernames in their path which can have cool emoji and such.)
2018-11-29 21:49:07 +01:00
Jan Varga 4afa59b9c8 Bug 1286798 - Part 34: Queue database operations until update batch ends; r=asuth
This avoids dispatching to the connection thread for every database operation and paves a way for database shadowing.
2018-11-29 21:49:04 +01:00
Jan Varga 06d1c01932 Bug 1286798 - Part 33: Restrict localStorage from being available on some pages; r=asuth
This matches the old implementation. localStorage shouldn't be available on some pages, for example about:home.
2018-11-29 21:49:01 +01:00
Jan Varga d87888fe25 Bug 1286798 - Part 31: Support for lazy loading of items; r=asuth,mrbkap,mccr8
There's now an upper limit for snapshot prefilling. The value is configurable and is currently set to 4096 bytes.
Snapshots can operate in multiple modes depending on if all items have been loaded or all keys have been received. This should provide the best performance for each specific state.
This patch also adds support for creating explicit snapshots which can be used for testing.
2018-11-29 21:48:54 +01:00
Jan Varga 34cd5113f1 Bug 1286798 - Part 30: Preserve key order when sending items to a content process; r=asuth
Keys needs to be redundantly stored in an array, so we can construct identical hashtable of values in a content process.
2018-11-29 21:48:51 +01:00
Jan Varga c4f55013cf Bug 1286798 - Part 29: Implement implicit snapshotting of databases; r=asuth,mccr8
This improves performance a lot in cases when multiple operations are invoked by a single JS function (number of sync IPC calls is reduced to a minimum). It also improves correctness since changes are not visible to other content processes until a JS function finishes.
The patch implements core infrastructure, all items are sent to content when a snapshot is initialized and everything is fully working. However, sending of all items at once is not optimal for bigger databases. Support for lazy loading of items is implemented in a following patch.
2018-11-29 21:48:47 +01:00
Jan Varga 54be9b7307 Bug 1286798 - Part 28: Add more QuotaClient::IsShuttingDownOnBackgroundThread() and MayProceed() checks; r=asuth
The shutdown and actor destroyed flag is now checked after each dispatch.
2018-11-29 21:48:44 +01:00
Jan Varga 1812608353 Bug 1286798 - Part 27: Share database actors; r=asuth
If a database actor already exists for given origin, reuse it instead of creating a new one. This improves memory footprint a bit and also eliminates some round trips to the parent process.
2018-11-29 21:48:41 +01:00
Jan Varga 0649224345 Bug 1286798 - Part 26: Implement a lazy data migration from old webappsstore.sqlite; r=asuth,janv
This patch was enhanced by asuth to bind attached database path.
Places has shown that argument binding is necessary.  (Profiles may include usernames in their path which can have cool emoji and such.)
2018-11-29 21:48:38 +01:00
Jan Varga 7981be440b Bug 1286798 - Part 25: Add checks for the group and global limit; r=asuth 2018-11-29 21:48:34 +01:00
Jan Varga 6e40a9dccb Bug 1286798 - Part 22: Add support for preloading of datastores; r=asuth
Datastores are preloaded only for content principals. The preloading is triggered as soon as possible to lower the chance of blocking the main thread in content process. If there is no physical database on disk for given origin, datastore is not created. Preloaded datastores are kept alive for 20 seconds.
2018-11-29 21:48:25 +01:00
Jan Varga d015b67aae Bug 1286798 - Part 20: Add checks for the 5 MB origin limit; r=asuth
The 5 MB limit is no longer applied to the whole group (eTLD+1). That will be controlled by quota manager.
2018-11-29 21:48:19 +01:00
Jan Varga 81c542fbe6 Bug 1286798 - Part 19: Implement a helper method for datastore preloading verification; r=asuth
A new type of request is introduced, PBackgroundLSSimpleRequest. This protocol is much simpler than PBackgroundLSRequest which needs to be cancelable.
2018-11-29 21:48:15 +01:00
Jan Varga b968ceb813 Bug 1286798 - Part 18: Verify that data is persisted on disk; r=asuth,mrbkap
New methods open() and close() are added to the Storage WebIDL interface. They are only available when a pref is set and are only intended for testing. There's also a new method resetStoragesForPrincipal() which is used as a callback for close() since datastores don't release directory locks immediately. resetStoragesForPrincipal() requests an exclusive lock for given origin, so it must wait for any exising shared locks to be released.
2018-11-29 21:48:11 +01:00
Jan Varga 944443d481 Bug 1286798 - Part 16: Adjust ClearDataService for new local storage implementation; r=asuth
This patch also adds support for creating LSObjects from chrome for any given origin which can be used for example by xpcshell tests.
2018-11-29 21:48:05 +01:00
Jan Varga 65acbea52d Bug 1286798 - Part 13: Preparation for quota checks; r=asuth 2018-11-29 21:47:55 +01:00
Jan Varga ae769dcc6b Bug 1286798 - Part 12: Honor the storage preference and cookie settings in all LocalStorage API methods; r=asuth 2018-11-29 21:47:52 +01:00
Jan Varga 9bbba97e91 Bug 1286798 - Part 11: Enable tests for session only mode (but only for the old local storage implementation); r=asuth
An attribute for checking if the next gen local storage implementation is enabled is exposed via a new interface nsILocalStorageManager which should be used for any other local storage specific stuff.
2018-11-29 21:47:48 +01:00
Jan Varga be167c5e0b Bug 1286798 - Part 10: Support for storage events; r=asuth,janv
Storage events are fired either directly after getting response from synchronous SetItem call or through observers. When a new onstorage event listener is added, we sycnhronously register an observer in the parent process. There's always only one observer actor per content process.
PBackgroundLSDatabase is now managed by a new PBackgroundLSObject protocol. PBackgroundLSObject is needed to eliminate the need to pass the principal info and document URI everytime a write operation occurs.
Preparation of an observer shares some states with preparation of a datastore, so common stuff now lives in LSRequestBase and preparation of a datastore now implements a nested state machine.

This patch was enhanced by asuth to drop observers only when the last storage listener is removed.
EventListenerRemoved is invoked on any removal, not just the final removal, so we need to make sure it's the final removal before dropping observer.
2018-11-29 21:47:45 +01:00
Jan Varga 08a07f2f36 Bug 1286798 - Part 9: Support for private browsing; r=asuth
Since we keep/cache data in memory anyway, private browsing support is mostly about avoiding any persistence related calls and clearing private browsing datastores when we get a notification. The separation between normal and private browsing datastores is done by the privateBrowsingId attribute which is part of the origin string.
2018-11-29 21:47:41 +01:00
Jan Varga 845fc3a991 Bug 1286798 - Part 8: Persist datastores to disk; r=asuth
Introduced a Connection and a ConnectioThread object.
All I/O requests are processed by a new single thread managed by ConnectionThread object.
Connection objects are prepared by the prepare datastore operation and then kept alive by datastores just like directory locks.
All datastore I/O operations are wrapped in a transaction which automaticaly commits after 5 seconds.
Datastore preparation now also loads all items from the database.
2018-11-29 21:47:38 +01:00
Jan Varga c934ad618d Bug 1286798 - Part 6: Fix a dead lock in the single process case; r=asuth,janv
Expose the nested main event target, so it can be used in the single process case by the parent side to process runnables which need to run on the main thread.
After this change we don't have use hacks like getting profile directory path on the child side and sending it to the parent. The parent side can now do it freely even in the single process case.

This patch was enhanced by asuth to not tunnel the nested main event target through IPC.
2018-11-29 21:47:30 +01:00
Jan Varga c5676a58c7 Bug 1286798 - Part 5: More integration with QuotaManager; r=asuth
Preparation of datastores now creates real database files on disk. The LocalStorage directory is protected by a directory lock.
Infrastructure for database schema upgrades is in place too.
Database actors are now explicitely tracked by the datastore. When the last actor finishes the directory lock is released.
Added also implementation for QuotaClient::GetUsageForOrigin() and QuotaClient::AbortOperations().
2018-11-29 21:47:27 +01:00
Jan Varga 9f71846e2a Bug 1286798 - Part 4: Basic integration with QuotaManager; r=asuth
This adds a new quota client implementation, but only implements ShutdownWorkThreads.
At shutdown we wait for all running operations to finish including database actors which are closed by using an extra IPC message which avoids races between the parent and child.
Databases are dropped on the child side as soon as they are not used (e.g. after unlinking by the cycle collector).
2018-11-29 21:47:24 +01:00
Jan Varga 60831f2e38 Bug 1286798 - Part 3: New basic (memory only) implementation of LocalStorage; r=asuth,mccr8
The implementation is based on a cache (datastore) living in the parent process and sync IPC calls initiated from content processes.
IPC communication is done using per principal/origin database actors which connect to the datastore.
The synchronous blocking of the main thread is done by creating a nested event target and spinning the event loop.
2018-11-29 21:47:20 +01:00
Jan Varga cca6633fac Bug 1539750 - LSNG: Add a timer for ShutdownWorkThreads; r=asuth, dr=chutten
Differential Revision: https://phabricator.services.mozilla.com/D25561
2019-04-01 09:57:48 +02:00
Jan Varga 73569a7b74 Bug 1541325 - LSNG: Result of SendFinish call is not checked; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D25909
2019-04-03 10:27:49 +02:00