Pref service: Bypass the encapsulation

Desktop / Chromium - Sam McNally [chromium.org] - 13 July 2017 23:10 EDT

The previous approach of encapsulating the pref service from chrome regressed memory. Remove that encapsulation by moving the source of truth back into the browser "service" and using those PrefStores directly from the pref service, bypassing any mojo messages.

Remove the control and registration interfaces which are no longer needed since the pref service is directly provided with its PrefStores. Also move the pref service to the UI thread, where the PrefStores already live.

Other services may still access prefs via the pref service using the existing sync API (with a local copy of requested prefs), but are responsible for managing the increased memory footprint that could result.

Change PersistentPrefStoreImpl to never start a pref read; the embedder is reponsible for ensuring the underlying PersistentPrefStore is either already initialised, or is in the process of being initialised. Change PersistentPrefStoreImpl to always observe the underlying PersistentPrefStore to detect changes originating from inside the embedder. Duplicate the update filtering from the per-connection class to ensure that each client continues to receive each update from other clients exactly once and never be notified about changes it instigated.

Bug: 654988 Change-Id: I7eb9e427c9f66d1eb4526d6ea8d9ca6e61c87262 Reviewed-on: https://chromium-review.googlesource.com/554653 Commit-Queue: Sam McNally

538fca1 Pref service: Bypass the encapsulation.
ash/shell.cc | 2 +-
chrome/browser/BUILD.gn | 2 +
chrome/browser/browser_process_impl.cc | 18 +-
.../browser_process_platform_part_chromeos.cc | 2 +-
chrome/browser/extensions/test_extension_prefs.cc | 3 +-
.../browser/prefs/active_profile_pref_service.cc | 10 +-
chrome/browser/prefs/active_profile_pref_service.h | 8 +-
chrome/browser/prefs/browser_prefs.cc | 26 ---
chrome/browser/prefs/browser_prefs.h | 7 -
.../browser/prefs/chrome_pref_service_factory.cc | 10 +-
chrome/browser/prefs/chrome_pref_service_factory.h | 8 +-
.../prefs/in_process_service_factory_factory.cc | 43 ++++
.../prefs/in_process_service_factory_factory.h | 35 +++
chrome/browser/prefs/pref_service_syncable_util.cc | 7 +-
chrome/browser/prefs/pref_service_syncable_util.h | 12 +-
chrome/browser/prefs/profile_pref_store_manager.cc | 50 +----
chrome/browser/prefs/profile_pref_store_manager.h | 8 +-
.../prefs/profile_pref_store_manager_unittest.cc | 97 ++-------
.../profiles/off_the_record_profile_impl.cc | 35 +--
.../browser/profiles/off_the_record_profile_impl.h | 2 -
chrome/browser/profiles/profile.h | 4 -
chrome/browser/profiles/profile_browsertest.cc | 3 -
chrome/browser/profiles/profile_impl.cc | 44 ++--
chrome/browser/profiles/profile_impl.h | 2 -
chrome/browser/ui/app_list/test/fake_profile.cc | 6 -
chrome/browser/ui/app_list/test/fake_profile.h | 1 -
chrome/common/chrome_features.cc | 14 --
chrome/common/chrome_features.h | 2 -
chrome/test/base/testing_profile.cc | 9 +-
chrome/test/base/testing_profile.h | 1 -
components/prefs/pref_value_store.h | 7 +
components/sync_preferences/BUILD.gn | 1 +
.../sync_preferences/pref_service_syncable.cc | 73 +------
.../sync_preferences/pref_service_syncable.h | 18 +-
.../pref_service_syncable_factory.cc | 12 +-
.../pref_service_syncable_factory.h | 11 +-
.../prefs/ios_chrome_pref_service_factory.cc | 3 +-
services/preferences/BUILD.gn | 5 +-
services/preferences/manifest.json | 6 +-
.../preferences/persistent_pref_store_factory.cc | 56 -----
.../preferences/persistent_pref_store_factory.h | 28 ---
services/preferences/persistent_pref_store_impl.cc | 27 ++-
services/preferences/persistent_pref_store_impl.h | 4 +
.../persistent_pref_store_impl_unittest.cc | 72 -------
.../preferences/pref_service_factory_unittest.cc | 234 +++++++--------------
.../{public/cpp => }/pref_store_impl.cc | 30 +--
.../preferences/{public/cpp => }/pref_store_impl.h | 25 +--
.../cpp/tests => }/pref_store_impl_unittest.cc | 28 +--
services/preferences/pref_store_manager_impl.cc | 194 ++++++-----------
services/preferences/pref_store_manager_impl.h | 76 +++----
services/preferences/public/cpp/BUILD.gn | 7 +-
services/preferences/public/cpp/DEPS | 1 +
.../public/cpp/in_process_service_factory.cc | 107 ++++++++++
.../public/cpp/in_process_service_factory.h | 56 +++++
.../public/cpp/persistent_pref_store_client.cc | 75 ++-----
.../public/cpp/persistent_pref_store_client.h | 17 --
.../preferences/public/cpp/pref_service_factory.cc | 39 +---
.../preferences/public/cpp/pref_service_factory.h | 2 -
.../preferences/public/cpp/pref_service_main.cc | 20 +-
.../preferences/public/cpp/pref_service_main.h | 18 +-
.../preferences/public/cpp/registering_delegate.cc | 50 -----
.../preferences/public/cpp/registering_delegate.h | 48 -----
services/preferences/public/cpp/tests/BUILD.gn | 1 -
.../public/interfaces/preferences.mojom | 54 +----
.../preferences/scoped_pref_connection_builder.cc | 49 ++---
.../preferences/scoped_pref_connection_builder.h | 23 +-
services/preferences/shared_pref_registry.cc | 34 +--
services/preferences/shared_pref_registry.h | 8 +-
.../tracked_persistent_pref_store_factory.cc | 5 +-
.../tracked_persistent_pref_store_factory.h | 3 +-
services/preferences/unittest_manifest.json | 2 +-
71 files changed, 658 insertions(+), 1342 deletions(-)

Upstream: git.chromium.org


  • Share