0

457 Commits

Author SHA1 Message Date
9d45d566bc [sync] PrefModelAssociator: propagate write flags from pref service
This CL plumbs the proper write flags through to PrefModelAssociator.

Fixed: 1404937
Change-Id: I2c4f95b26a7746e2755fb854bb951a93331936e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4440927
Reviewed-by: Marc Treib <treib@chromium.org>
Reviewed-by: Dominic Battre <battre@chromium.org>
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Ankush Singh <ankushkush@google.com>
Cr-Commit-Position: refs/heads/main@{#1133025}
2023-04-20 10:14:49 +00:00
33dbf1b820 [Code Health] Replace SetIntPath() with SetByDottedPath()
Replaces the use of Value::SetIntPath() with
Value::Dict::SetByDottedPath(). This require changing other similar
values (e.g Value::SetStringKey() to Value::Dict::Set())

No functionality changed.

Bug: 1187001
Change-Id: I83708e72cf0243c28cf2e7aae8705a3cf3fafe5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4356431
Commit-Queue: Emilia Paz <emiliapaz@chromium.org>
Reviewed-by: Olivier Robin <olivierrobin@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1119992}
2023-03-21 16:43:14 +00:00
e9909597c9 [Code Health] Use Value::Dict::empty() in //chrome and //components
Replaces the use of Value::DictEmpty() with Value::Dict::empty(). No
functionality changed.

Bug: 1187001
Change-Id: I4845f1464cea3db0b4c946d77717c7a95a901428
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4322878
Commit-Queue: Emilia Paz <emiliapaz@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Reviewed-by: Takumi Fujimoto <takumif@chromium.org>
Reviewed-by: Daniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1117777}
2023-03-15 21:57:54 +00:00
62d0624a09 [Code Health] Remove Settings.JsonDataReadSizeKilobytes.*
Although the histogram is expired, we are still receiving data from
one of its "variant" on the serverside. In particular:
Settings.JsonDataReadSizeKilobytes.Network_Persistent_State

This is because the "Network_Persistent_State" suffix is not in
histogram_suffixes_list.xml, so it is not being detected as
expired, and is hence being sent.

Since the histogram is intended to be expired, just remove it.

For reference, documented old values @ go/etqpo (Google-internal).

Bug: 1423446
Change-Id: Ia7be074927eaae6f2f46ec1b53b23237aad64e9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4327823
Commit-Queue: Luc Nguyen <lucnguyen@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Auto-Submit: Luc Nguyen <lucnguyen@google.com>
Cr-Commit-Position: refs/heads/main@{#1116706}
2023-03-14 00:14:58 +00:00
f3385c73a6 Avoid out param in ImportantFileWriter::SerializeData
This CL removes the use of an out param in
ImportantFileWriter::SerializeData in favour of returning an optional.

Additionally, this CL removes usages of JSONStringValueSerializer from
the files in question.

Bug: 1421354
Change-Id: I32e59e2e49c4e226eae85cbcfe280ab34c39a661
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4321452
Reviewed-by: Colin Blundell <blundell@chromium.org>
Commit-Queue: Claudio DeSouza <cdesouza@igalia.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Matt Menke <mmenke@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1116324}
2023-03-13 12:36:23 +00:00
87de21fcc6 Collect debug data for crbug.com/1419591
This CL introduces debug data collection for crbug.com/1419591, a crash
in ScopedDictPrefUpdate::Get.

Bug: 1419591
Change-Id: Iffa13b71599043cb0a78053a57d9db8209429f50
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4303246
Reviewed-by: Gabriel Charette <gab@chromium.org>
Auto-Submit: Dominic Battré <battre@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1113382}
2023-03-06 15:44:48 +00:00
c3e8508e0e Switch to simpler base::WriteFile() variants (85/N)
This CL is part of a batch of CLs to replace the use of the less
friendly base::WriteFile call with simpler variants, which are easier to
read, and less prone to mistakes.

Changes in this particular CL address files under the path
/components/prefs.

This CL was uploaded by git cl split.

R=gab@chromium.org

AX-Relnotes: n/a.
Bug: 418837
Change-Id: I9df41c2bd5bfa2f11f03b2bf83c3c0ed7c557cb0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4288223
Auto-Submit: Claudio DeSouza <cdesouza@igalia.com>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1110354}
2023-02-27 16:07:15 +00:00
406bc1ef72 Revert "Reland "CHECK on duplicate AddObserver() calls in ObserverList""
This reverts commit 41b2b7a997.

Reason for revert:
Causing top 3 crashes of ChromeOS M112 dev. See associated bugs.

Original change's description:
> Reland "CHECK on duplicate AddObserver() calls in ObserverList"
>
> This is a reland of commit 5d8d0d2168
>
> Remove the failing test. See patchset 1..2.
>
> Original change's description:
> > CHECK on duplicate AddObserver() calls in ObserverList
> >
> > There're observed crashes because of duplicate AddObserver() calls. See
> > crbug.com/1410397#c2. This may lead to obscure bugs if not captured,
> > therefore replace NOTREACHED with a CHECK so that it will always crash
> > on release builds.
> >
> > Bug: None
> > Change-Id: I23053675d33d2d6fc9cb2ecc7d083f03b6ec60c0
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4197957
> > Reviewed-by: Peter Boström <pbos@chromium.org>
> > Commit-Queue: Keren Zhu <kerenzhu@chromium.org>
> > Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> > Cr-Commit-Position: refs/heads/main@{#1097657}
>
> Bug: None
> Change-Id: I88e819cc101cadc5e24f9780e2fa686a883c1297
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4197922
> Commit-Queue: Keren Zhu <kerenzhu@chromium.org>
> Owners-Override: Daniel Cheng <dcheng@chromium.org>
> Reviewed-by: Dominic Battré <battre@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1097919}

Bug: chromium:1418060, b:270154290, b:270155382, b:270169601
Change-Id: I1b8a34a37f9bd9ce2cfc7c0371270e9b25a5e05e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4273997
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Dominic Battré <battre@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Reviewed-by: Keren Zhu <kerenzhu@chromium.org>
Auto-Submit: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1108196}
2023-02-22 07:32:22 +00:00
c4ceca45e3 PrefModelAssociator: Use PrefStore directly instead of PrefService
PrefModelAssociator is the "bridge" between Sync and the native
Preferences model. It synchronizes user pref values (as opposed to
policy-controlled values, default values, etc) between this Chrome
instance and the Sync server.

Before this CL, PrefModelAssociator was hooked up to PrefService.
After this CL, it's instead hooked up directly to the user-controlled
PrefStore.

This is simpler/more natural in some ways:
Only user prefs should be synced, so hooking up directly to those
makes sense. E.g. PrefModelAssociator now no longer needs to filter
out pref changes if the pref has a non-user-controlled value.

There is one behavior change, when the user-controlled value of a pref
is changed while a "higher-level" pref value also exists (e.g. policy-
or extension-controlled):
Before this CL, the pref change would be ignored.
After this CL, the user pref value will still get sent to the Sync
server.
This should be a very rare situation and not have any notable impact.

Bug: 1404937
Change-Id: Ia9e72effb14b52dd470007bed902441bf6f0aeb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4219172
Reviewed-by: Maksim Moskvitin <mmoskvitin@google.com>
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1105099}
2023-02-14 16:56:34 +00:00
c8ec00cdc1 Update PrefService::GetPreferenceValues to new Value API
Bug: 646113
Change-Id: I099dae1ddd425b774055a847e8c392e986f346ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4229691
Auto-Submit: Avi Drissman <avi@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Roger McFarlane <rogerm@chromium.org>
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1102793}
2023-02-08 17:46:48 +00:00
d2a736f985 Remove base::Value::Type::DICTIONARY
It is deprecated in favor of base::Value::Type::DICT, so change uses
of it to the new name and remove the enum value.

Fixed: 1291670
Change-Id: I26136fcb723e7dff1f5ffe3990d7011b18c16a43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4198081
Auto-Submit: Avi Drissman <avi@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1098238}
2023-01-28 02:31:26 +00:00
41b2b7a997 Reland "CHECK on duplicate AddObserver() calls in ObserverList"
This is a reland of commit 5d8d0d2168

Remove the failing test. See patchset 1..2.

Original change's description:
> CHECK on duplicate AddObserver() calls in ObserverList
>
> There're observed crashes because of duplicate AddObserver() calls. See
> crbug.com/1410397#c2. This may lead to obscure bugs if not captured,
> therefore replace NOTREACHED with a CHECK so that it will always crash
> on release builds.
>
> Bug: None
> Change-Id: I23053675d33d2d6fc9cb2ecc7d083f03b6ec60c0
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4197957
> Reviewed-by: Peter Boström <pbos@chromium.org>
> Commit-Queue: Keren Zhu <kerenzhu@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1097657}

Bug: None
Change-Id: I88e819cc101cadc5e24f9780e2fa686a883c1297
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4197922
Commit-Queue: Keren Zhu <kerenzhu@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1097919}
2023-01-27 15:55:11 +00:00
12be03159f Update header includes for /base/functional in /components
bind.h, callback.h, callback_forward.h, and callback_helpers.h
moved into /base/functional/. Update the include paths to
directly include them in their new location.

Bug: 1364441
Change-Id: I3179c6b5879e1e2d5a5f4990484b9a85f8548809
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4152595
Auto-Submit: Avi Drissman <avi@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1091229}
2023-01-11 09:16:09 +00:00
c70f40654b Update Value::Append() call in components/prefs/pref_member_unittest.cc
Switch it to Value::List::Append(), as Value::Append() is deprecated.

Bug: 1404827
Change-Id: Id1f7342259bac3e7c871abe415571700f732ccf5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4150988
Commit-Queue: Matt Menke <mmenke@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1090837}
2023-01-10 15:35:28 +00:00
e672a665ff task posting v3: remove includes of runner handles and IWYU task runners
Turns out there's a lot of includes, so these will have to be removed
before deleting the implementation of the task runner handles.

To allow the deletion of the task runner handle headers, add
the sequenced/thread task runner handles where they are used in
the codebase with scripts.

This was done with an automated change, with a few touchups afterwards.
The code for the mass-refactor changes are here:
python:
https://paste.googleplex.com/5534570878337024
shell:
https://paste.googleplex.com/6466750748033024

In terms of touchups:
- add sequenced/thread task runner handles to
  the third_party/blink/public/DEPS, because multiple files were using
  it transitively anyways.
- rewrite certain parts of the codebase which used
  ThreadTaskRunnerHandles instead of CurrentDefaultHandles.
- fix a compile issue with forward-declaration in
  extensions/browser/extension_file_task_runner.h.

AX-Relnotes: n/a.
Bug: 1026641
Change-Id: I737ef32aee4e77c21eaa3a2bdc403a28322cf1b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4133323
Owners-Override: Gabriel Charette <gab@chromium.org>
Commit-Queue: Sean Maher <spvw@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1090532}
2023-01-09 21:42:28 +00:00
7b290b8574 Remove ListValue and DictionaryValue from json_pref_store_unittest.cc.
Both are deprecated.

Bug: 1187062
Change-Id: Idf3c4badd4f10d68cc2a5eec0a3ed90458f9809e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4134446
Commit-Queue: Matt Menke <mmenke@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1088673}
2023-01-04 12:51:51 +00:00
b598de99d1 Remove ScopedUserPrefUpdate
This class has been migrated to replacements using the modern value
APIs: ScopedDictPrefUpdate and ScopedListPrefUpdate.

Bug: 1302562
Change-Id: Idd38869384f6571b10541e00f5250107bd39eee5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4120746
Commit-Queue: Ted Choc <tedchoc@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Auto-Submit: Ari Chivukula <arichiv@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1087373}
2022-12-28 18:34:47 +00:00
58a7e65ecf Remove DictionaryPrefUpdate.
All consumers have been migrated to ScopedDictPrefUpdate.

Fixed: 1362719
Change-Id: Ie94aceb5d15bcc02d0eb61a2bbdde11ca0d5c1d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4112537
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1086789}
2022-12-23 21:07:39 +00:00
666d68fad9 [Code Health Rotation] Migrate ListValue/DictionaryValue usage in components
Romves some usage of deprecated base::ListValue and base::DictionaryValue, replacing them with base::Value.

This CL also removed unused declarations.

Bug: 1187062, 1187061
Change-Id: I970e9ab9d2aa7d463609035b82133bd282294d11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4122593
Reviewed-by: Colin Blundell <blundell@chromium.org>
Commit-Queue: Jonathan Njeunje <njeunje@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1086760}
2022-12-23 16:26:22 +00:00
4d05a1d59c [CodeHealth] Migrate DictionaryValue and ListValue in components/prefs
Refactoring for the base::Value migration. This CL migrates deprecated
base::DictionaryValue to base::Value::Dict, and base::ListValue to
base::Value::List.

Bug: 1187062, 1187061
Change-Id: I42d68d1c414a1161ee3b900d9e9caae3edda148a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4117938
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Shunya Shishido <sisidovski@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1085818}
2022-12-21 08:11:22 +00:00
3167b41ac1 [CodehHalth] Remove DictionaryValue::SetInteger
This CL migrates from `DictionaryValue` and `SetInteger()` to
`base::Value::Dict` and `Set()`, or `Value::SetIntPath()` in
components/sync_preferences/pref_model_associator_unittest.cc

Bug: 1187026
Change-Id: Iab5ae213553b15b42c816096a65d5d76a3a0d001
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4113185
Commit-Queue: Shunya Shishido <sisidovski@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1084860}
2022-12-19 07:35:33 +00:00
d04323764a [Code Health] Some replacements of base::DictionaryValue for prefs
Bug: 1187023
Change-Id: I1d6a76c691b62f7c8b97c42213e47f60b11c0aac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4095228
Reviewed-by: proberge <proberge@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Nan Lin <linnan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1084540}
2022-12-16 21:58:24 +00:00
ef3a221dce Avoid an unnecessary copy in TestingPrefServiceBase::SetPref().
Since TestingPrefServiceBase::SetPref() already owns the
std::unique_ptr<base::Value> argument, just convert it to base::Value
instead of cloning it.

Change-Id: I7bbef6d43951ee383a0071cafa8fa52872a62625
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4109930
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1084491}
2022-12-16 20:16:17 +00:00
a539a158cb Task posting v3: refactor base::PostTaskAndReplyWithResult
Change all instances of base::PostTaskAndReplyWithResult(task_runner
to task_runner->PostTaskAndReplyWithResult(.

This also removes includes of base/task/task_runner_util.h, but only
in the files with 'base::PostTaskAndReplyWithResult' which don't refer
to PostTaskAndReplyWithResult in other places.

Code was refactored with the following scripts:
python script:
https://paste.googleplex.com/5117849478627328
shell script:
https://paste.googleplex.com/4961540519231488

Bug: 1026641
Change-Id: Ifb34b3b9078440dda5902b0d694cb8d3f315dfe7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3892903
Commit-Queue: Sean Maher <spvw@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1076288}
2022-11-28 18:13:41 +00:00
86bad7d8ba Add missing ostream includes.
These compilation units had a transitive dependency on ostream via
base/numerics/safe_conversions.h. The ostream include in
safe_conversions.h is however unused and should be removed.

This CL was uploaded by git cl split.

R=battre@chromium.org

Bug: 1270812, 1372522
Change-Id: Iec69dd485d658c0766e1d3bceee44f250ce1974e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4057312
Auto-Submit: Jean-Philippe Gravel <jpgravel@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Jean-Philippe Gravel <jpgravel@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1076004}
2022-11-27 20:20:57 +00:00
52fa5a7f26 task posting v3: moving away from SequencedTaskRunnerHandle
To continue the migration away from TaskRunnerHandles, the codebase
was refactored using the following scripts:
shell script:
https://paste.googleplex.com/4673967729147904
python:
https://paste.googleplex.com/5302682490241024

This will do a few sed-like modifications, changing calls to methods of
SequencedTaskRunnerHandle to calls to methods of
SequencedTaskRunner::CurrentDefaultHandle, and swapping includes.

Bug: 1026641
AX-Relnotes: n/a.
Change-Id: I49e50a2bd1e78b00e7c067219fff96d2e0bc0b46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3983373
Commit-Queue: Gabriel Charette <gab@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1071032}
2022-11-14 15:53:25 +00:00
4ec04f3492 Don't check state of "PrefStoreBackgroundSerialization" before FeatureList is available.
Context: crbug.com/1364606#c12

This is a prerequisite to land https://crrev.com/c/4006674, which will
DCHECK when the state of a feature is accessed before the FeatureList
is available.

Bug: 1358639, 1364606
Change-Id: Ie52c5a9b1711243d559952c3c6862fc095bcf1e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4023028
Commit-Queue: Francois Pierre Doray <fdoray@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1070402}
2022-11-11 19:06:05 +00:00
c481797489 Serialize prefs json on background thread
Bug: 1364606
Change-Id: I025eeaf6dd3de1cbcc55cefebd11199b937c4a11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4014807
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Patrick Noland <pnoland@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1069979}
2022-11-10 20:55:43 +00:00
2eb35a15c8 Prefs cleanup: Remove unused ClearMutableValues()
PrefService::ClearMutableValues() (and thus all the various, mostly
empty, implementations in the PrefStore subclasses) was unused, so this
CL removes it.

Bug: none
Change-Id: I95722d6aec4c8fc68dc7560f6f6693310edf74d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4005952
Commit-Queue: Dominic Battré <battre@chromium.org>
Auto-Submit: Marc Treib <treib@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1068034}
2022-11-07 10:37:00 +00:00
4d4e24099b DanglingPtr: Mark all of them as untriaged [1/N]
This patch must be a no-op with all the common build flags.

Add the "DanglingUntriaged" raw_ptr annotation. It indicates a
raw_ptr becomes dangling, and it should be triaged/fixed. This will also disable dangling protection for those pointers, once enabled.

These were identified by running the CQ bots with DPD activated (both build + runtime here: https://crrev.com/c/3941825)

Bug: 1291138
Change-Id: I07e3d85b1c629f7d49c928f1fca42a538c64ef3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3959615
Owners-Override: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Pâris Meuleman <pmeuleman@chromium.org>
Commit-Queue: Ali Hijazi <ahijazi@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1061867}
2022-10-20 22:59:31 +00:00
21c16e238b [Code Health] Migrate ProxyConfigDictionary to base::Value::Dict
This cl migrates ProxyConfigDictionary (see
components/proxy_config/proxy_config_dictionary.h) to use
base::Value::Dict, most of the changes are directly propagated from
there. Besides that it expands TestingPrefServiceBase (see
components/prefs/testing_pref_service.h) interface with setters taking
base::Value::Dict and base::Value::List which allows to avoid manual
conversion to the base::Value on the call side in many tests.

LOW_COVERAGE_REASON=Code Health type migration, nothing new to test

Bug: 1187061, 1187001
Change-Id: I0dbca1a78b3c0a4f313f364f3d2fc35378ccf273
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3922202
Reviewed-by: Colin Blundell <blundell@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Andrey Davydov <andreydav@google.com>
Cr-Commit-Position: refs/heads/main@{#1053030}
2022-09-29 16:19:45 +00:00
e01119d3d3 prefs: Avoid unique pointer round trip
Currently, WriteablePrefStore takes `std::unique_ptr<base::Value>`
arguments for `SetValue` and `SetValueSilently`. However, the
implementations actually store `base::Value`. This leads to a lot of
unnecessary memory allocations and releases for values that are
created on the heap just to be moved away immediately.

This CL changes the API of WriteablePrefStore to accept `base::Value`.
This avoids the superfluous allocations and release.

Bug: 1368265
Change-Id: I698f5e4efa5006db0c62436add745712001c9b11
Tests: Existing unit tests
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3913938
Commit-Queue: Roland Bock <rbock@google.com>
Owners-Override: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1052757}
2022-09-29 01:21:41 +00:00
030db2487b Delete ListPrefUpdate, migrating remaining consumers.
Migrating a couple remaining consumers. All other consumers have been
migrated to ScopedListPrefUpdate, or SetList().

Bug: 1362719
Change-Id: I3180b00a4595ba51c9a13c809a2f9f9199a4d4f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3911639
Commit-Queue: Matt Menke <mmenke@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1052218}
2022-09-28 04:42:12 +00:00
24a7c86cae prefs: Use StringPiece instead of string& to avoid allocation
Currently, PrefService::GetValue and related functions take path
arguments as `const std::string&`. Since most call sites actually
pass `const char*` parameters, this leads to a lot of string constructions and (potentially) memory allocations, depending on the size of the string.

This CL replaces the argument type with `base::StringPiece`, which reduces the Android binary size by about 11kB.

In order to look up `base::StringPiece` keys in
`std::set<std::string>` or `std::map<std::string, base::Value>` we
need to replace the Compare function object with `std::less<void>`, which allows transparent comparison.
This is defined in the new header components/prefs/pref_name_set.h

Bug: 1366031
Change-Id: I386f032849fb75c8416047e48ecc92b567faf450
Tests: Existing unit tests
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3902702
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Igor <igorcov@chromium.org>
Reviewed-by: Sean Topping <seantopping@chromium.org>
Commit-Queue: Roland Bock <rbock@google.com>
Reviewed-by: Dominic Battré <battre@chromium.org>
Reviewed-by: Michael Bai <michaelbai@chromium.org>
Reviewed-by: Aga Wronska <agawronska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1051089}
2022-09-26 07:29:48 +00:00
c9abb516a3 Fallback to the default value in PrefService::GetPreferenceValue
pref_registry_->defaults() is a better fallback than nullptr.

Note that this could only ever have an effect in case

pref_registry_->defaults()
   != pref_value_store_->GetStore(DEFAULT_STORE)

So in the long run, we might want to add a guarantee for equality.

Bug: 1364529
Change-Id: I63f380fab0839afc1e1931629a9c804f2fed687c
Tests: Existing unit tests
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3899758
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Roland Bock <rbock@google.com>
Cr-Commit-Position: refs/heads/main@{#1050840}
2022-09-23 22:57:49 +00:00
55e0fc607b [Code Health] Convert Value::GetListDeprecated() to Value::GetList() in /components/prefs.
This CL also converts to the new "for" loop syntax in a few files.

This CL was uploaded by git cl split.

R=battre@chromium.org

Bug: 1303949
Change-Id: Ia02ac0d6c78a957993d7bac0811442b32b3ed8cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3908340
Auto-Submit: David Bertoni <dbertoni@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1049527}
2022-09-21 08:15:20 +00:00
e90d88cbe8 Add IsDefaultValuePreference to PrefService.
This CL adds a method to the bridge that allows checking whether
a pref with a specified key is using its default value.
This needed in the process of migrating existing SharedPreferences
to PrefService prefs (as an equivalent of the "contains" method).

Bug: 1362553
Change-Id: I986d7e662215c906dbdd7231dfb09f47e56f935a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3904382
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Jan Keitel <jkeitel@google.com>
Cr-Commit-Position: refs/heads/main@{#1049049}
2022-09-20 12:25:27 +00:00
5a64a24cc7 Fix typos from an earlier CL.
https://chromium-review.googlesource.com/c/chromium/src/+/3900657 had
a typo duplicated a few times.

Bug: 1362719
Change-Id: Ie38962562a2994d7ab1d75fd07ac3bd96bb6be3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3899186
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1048238}
2022-09-16 22:15:04 +00:00
62e0b4055f [Prefs] Add replacement classes for Dict/ListPrefUpdate.
The new ScopedDictPrefUpdate and ScopedListPrefUpdate class only
expose Value::Dicts and Value::Lists, respectively. This makes it
more straightforward to use the new Dict/List classes, and prevents
callers from using deprecated value manipulation methods with the
APIs.

The new API also returns references instead of pointers, to prevent
unnecessary null checking.

Bug: 1362719
Change-Id: I322f4b037571c39beb741a4434d0cee1eb1276d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3900657
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1048082}
2022-09-16 17:15:10 +00:00
fc4f656789 Remove defaults from PrefService::GetString/Bool/Int/Double
As of today, PrefService::GetString yields a std::string value. In case
the requested path contains a string, this is a copy of the actual pref
value. Otherwise it is a freshly constructed string.

However, the documentation clearly assumes that the requested pref has
to be a string value. There is no unit test that validates the behavior
for non-string values. And an analysis has revealed no usage that would
rely on the fallback either.

PrefService::GetString is therefore needlessly expensive.

Following the same logic as go/trust-your-prefs, note that if, there were a call site that called GetString with a key that did not point to a string, it would /always/ receive an empty string and needs to be refactored.

This CL removes the fallback for PrefService::GetString and makes it
return a reference to the stored value.
It also removes the fallbacks in GetBool, GetInt, and GetDouble for the
same reasons.

Bug: 1344857
Change-Id: Ibd70e206d75e23d84f7e6ef5e0307c1518e56515
Tests: Existing unit tests
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3810628
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Roland Bock <rbock@google.com>
Cr-Commit-Position: refs/heads/main@{#1047861}
2022-09-16 06:49:40 +00:00
8ba1bad80d Update copyright headers in components/
The methodology used to generate this CL is documented in
https://crbug.com/1098010#c34.

No-Try: true
No-Presubmit: true
Bug: 1098010
Change-Id: If6a3370b0b2849d889ce797596fe1ccbad2f3fe6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3891619
Auto-Submit: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1046502}
2022-09-13 19:22:36 +00:00
2bf1d23185 Drop PrefService::GetValueDict and GetValueList
This concludes the go/trust-your-prefs migration.

Bug: 1334665
Change-Id: I91c6ec9d8e3312470452110f922467521569a49e
Tests: Code still compiles (removed unused functions)
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3891021
Quick-Run: Roland Bock <rbock@google.com>
Commit-Queue: Roland Bock <rbock@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Roland Bock <rbock@google.com>
Cr-Commit-Position: refs/heads/main@{#1046005}
2022-09-12 20:47:58 +00:00
6edc4b7de3 Replace PrefService::GetValueDict and PrefService::GetValueList
Semi-final step go/trust-your-prefs#heading=h.jjuz6fybcx8y

Introduce
 - PrefService::GetDict and
 - PrefService::GetList

as drop-in replacements for

 - PrefService::GetValueDict and
 - PrefService::GetValueList

and replace all known call sites via

sed -i 's/\bGetValueDict\b/GetDict/g' $(ag -l -s '\bGetValueDict\b')
sed -i 's/\bGetValueList\b/GetList/g' $(ag -l -s '\bGetValueList\b')

The final step will be to remove GetValueDict and GetValueList in a
follow-up CL.

Bug: 1334665
Test: Existing unit tests
Change-Id: I093e81af89628a02216501e59c1de7f1e5e22b9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3887802
Auto-Submit: Roland Bock <rbock@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1045895}
2022-09-12 17:33:01 +00:00
b7f43fd50a Remove PrefService::GetDictionary
PrefService::GetDict has been replaced by PrefService::GetValueDict.

Bug: 1334665
Test: Existing unit tests
Change-Id: I3665cd6999d9a80d3dfbcbd4e6b187a6c1f42c0b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3883783
Commit-Queue: Roland Bock <rbock@google.com>
Quick-Run: Roland Bock <rbock@google.com>
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1045043}
2022-09-09 12:13:12 +00:00
e11ce9e364 Remove PrefService::GetList
PrefService::GetList has been replaced by PrefService::GetValueList.

Bug: 1334665
Test: Existing unit tests
Change-Id: I248ca69c34ccb0282f820f8badfe32b867bc6df0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3870847
Commit-Queue: Dominic Battré <battre@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1043246}
2022-09-05 16:49:20 +00:00
bbbf9ac9ff Remove unused function ChangePrefValueStore from PrefService
PrefService::ChangePrefValueStore and
PrefServiceFactory::ChangePrefValueStore are unused.
This CL removes them.

Bug: None
Change-Id: I690cf48c39f7c44cd8685a647fd87484ce2a0a1e
Tests: Removed unit tests
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3855565
Reviewed-by: Dominic Battré <battre@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Roland Bock <rbock@google.com>
Cr-Commit-Position: refs/heads/main@{#1042914}
2022-09-03 12:48:57 +00:00
9be8476809 Remove unused PrefValueStore::Delegate
Currently PrefValueStore::Delegate is unused.
This CL therefore removes it.

Bug: None
Change-Id: Ibf1e01b08d0ad4ad8877cdf69cfb612e46ba14c9
Tests: Existing unit tests for the PrefValueStore
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3849359
Reviewed-by: Dominic Battré <battre@chromium.org>
Reviewed-by: Anqing Zhao <anqing@chromium.org>
Commit-Queue: Roland Bock <rbock@google.com>
Cr-Commit-Position: refs/heads/main@{#1042737}
2022-09-02 19:49:45 +00:00
e5346551e4 Reland "Remove PrefService::Get"
This is a reland of commit 0dbb10a87d

The code that caused the revert was migrated in
crrev.com/c/3798165/4..5


Original change's description:
> Remove PrefService::Get
>
> PrefService::Get has been replaced by PrefService::GetValue.
>
> Bug: 1334665
> Test: Existing unit tests
> Change-Id: Iec3458bdde235172ca86549328e24006dd584727
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3827209
> Commit-Queue: Roland Bock <rbock@google.com>
> Reviewed-by: Dominic Battré <battre@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1038763}

Bug: 1334665
Change-Id: I939a9254af25727aa97b95cabdb859b62798c79d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3857319
Commit-Queue: Roland Bock <rbock@google.com>
Reviewed-by: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1040951}
2022-08-30 14:34:45 +00:00
9a2e54ed94 Revert "Remove PrefService::Get"
This reverts commit 0dbb10a87d.

Reason for revert: compilation failure at https://ci.chromium.org/p/chrome/builders/ci/linux-chromeos-chrome/24095

Original change's description:
> Remove PrefService::Get
>
> PrefService::Get has been replaced by PrefService::GetValue.
>
> Bug: 1334665
> Test: Existing unit tests
> Change-Id: Iec3458bdde235172ca86549328e24006dd584727
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3827209
> Commit-Queue: Roland Bock <rbock@google.com>
> Reviewed-by: Dominic Battré <battre@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1038763}

Bug: 1334665
Change-Id: Idded32f1dbb3ec8aecf455f85fc052039a830941
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3853602
Auto-Submit: David Baron <dbaron@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: David Baron <dbaron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1038787}
2022-08-24 15:19:50 +00:00
0dbb10a87d Remove PrefService::Get
PrefService::Get has been replaced by PrefService::GetValue.

Bug: 1334665
Test: Existing unit tests
Change-Id: Iec3458bdde235172ca86549328e24006dd584727
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3827209
Commit-Queue: Roland Bock <rbock@google.com>
Reviewed-by: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1038763}
2022-08-24 14:35:48 +00:00