Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Issue 266553002: Add TrackedPreferenceValidationDelegate (Closed)

Created:
6 years, 7 months ago by grt (UTC plus 2)
Modified:
6 years, 6 months ago
CC:
chromium-reviews, gab
Visibility:
Public.

Description

Add TrackedPreferenceValidationDelegate, by which the creator of a profile pref store may observe the validation of tracked preferences. BUG= Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=272880

Patch Set 1 #

Patch Set 2 : fix compile error, fix ternary operator wrapping, added doc comment #

Patch Set 3 : fix observer data ownership in tests #

Patch Set 4 : sync to r268187 #

Patch Set 5 : fix expectations for android and cros #

Total comments: 33

Patch Set 6 : merge to r270423 #

Patch Set 7 : erikwright comments #

Patch Set 8 : more comments #

Patch Set 9 : test fix #

Total comments: 11

Patch Set 10 : observer to delegate #

Patch Set 11 : sync to r272759 #

Total comments: 6

Patch Set 12 : mnissler nits #

Total comments: 2

Patch Set 13 : undo git cl format #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+398 lines, -35 lines) Patch
M chrome/browser/prefs/chrome_pref_service_factory.h View 1 2 3 4 5 6 7 8 9 2 chunks +2 lines, -0 lines 0 comments Download
M chrome/browser/prefs/chrome_pref_service_factory.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +10 lines, -8 lines 0 comments Download
A chrome/browser/prefs/mock_validation_delegate.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +75 lines, -0 lines 0 comments Download
A chrome/browser/prefs/mock_validation_delegate.cc View 1 2 3 4 5 6 7 8 9 1 chunk +62 lines, -0 lines 0 comments Download
M chrome/browser/prefs/pref_hash_filter.h View 1 2 3 4 5 6 7 8 9 2 chunks +4 lines, -1 line 0 comments Download
M chrome/browser/prefs/pref_hash_filter.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +10 lines, -5 lines 0 comments Download
M chrome/browser/prefs/pref_hash_filter_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 11 chunks +93 lines, -0 lines 1 comment Download
M chrome/browser/prefs/profile_pref_store_manager.h View 1 2 3 4 5 6 7 8 9 2 chunks +5 lines, -2 lines 0 comments Download
M chrome/browser/prefs/profile_pref_store_manager.cc View 1 2 3 4 5 6 7 8 9 10 5 chunks +7 lines, -1 line 0 comments Download
M chrome/browser/prefs/profile_pref_store_manager_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 chunks +35 lines, -2 lines 2 comments Download
M chrome/browser/prefs/tracked/tracked_atomic_preference.h View 1 2 3 4 5 6 7 8 9 2 chunks +10 lines, -6 lines 0 comments Download
M chrome/browser/prefs/tracked/tracked_atomic_preference.cc View 1 2 3 4 5 6 7 8 9 2 chunks +9 lines, -2 lines 0 comments Download
A chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h View 1 2 3 4 5 6 7 8 9 1 chunk +46 lines, -0 lines 3 comments Download
M chrome/browser/prefs/tracked/tracked_split_preference.h View 1 2 3 4 5 6 7 8 9 2 chunks +10 lines, -6 lines 0 comments Download
M chrome/browser/prefs/tracked/tracked_split_preference.cc View 1 2 3 4 5 6 7 8 9 2 chunks +9 lines, -2 lines 0 comments Download
M chrome/browser/profiles/profile_impl.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +5 lines, -0 lines 0 comments Download
M chrome/browser/profiles/profile_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +3 lines, -0 lines 0 comments Download
M chrome/chrome_browser.gypi View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -0 lines 0 comments Download
M chrome/chrome_tests_unit.gypi View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 36 (0 generated)
grt (UTC plus 2)
erikwright: primary review gab: OWNERS review Formatting courtesy of git cl format.
6 years, 7 months ago (2014-04-30 17:10:58 UTC) #1
erikwright (departed)
LGTM with some nits. Please augment the comments everywhere there is an Observer pointer parameter ...
6 years, 7 months ago (2014-05-14 00:39:25 UTC) #2
grt (UTC plus 2)
patch set 6 is a sync. patch set 7 contains most of the requested changes. ...
6 years, 7 months ago (2014-05-14 18:57:22 UTC) #3
grt (UTC plus 2)
patch set 6 is a sync. patch set 7 contains most of the requested changes. ...
6 years, 7 months ago (2014-05-14 18:57:22 UTC) #4
erikwright (departed)
SLGTM. I do prefer the method->constructor parameter change to be implemented. https://codereview.chromium.org/266553002/diff/80001/chrome/browser/prefs/mock_validation_observer.h File chrome/browser/prefs/mock_validation_observer.h (right): ...
6 years, 7 months ago (2014-05-14 21:24:05 UTC) #5
grt (UTC plus 2)
Thanks. PTAL. https://codereview.chromium.org/266553002/diff/80001/chrome/browser/prefs/mock_validation_observer.h File chrome/browser/prefs/mock_validation_observer.h (right): https://codereview.chromium.org/266553002/diff/80001/chrome/browser/prefs/mock_validation_observer.h#newcode31 chrome/browser/prefs/mock_validation_observer.h:31: std::string pref_path; On 2014/05/14 21:24:06, erikwright wrote: ...
6 years, 7 months ago (2014-05-15 01:43:11 UTC) #6
grt (UTC plus 2)
https://codereview.chromium.org/266553002/diff/80001/chrome/browser/prefs/pref_hash_filter_unittest.cc File chrome/browser/prefs/pref_hash_filter_unittest.cc (right): https://codereview.chromium.org/266553002/diff/80001/chrome/browser/prefs/pref_hash_filter_unittest.cc#newcode347 chrome/browser/prefs/pref_hash_filter_unittest.cc:347: mock_validation_observer.PassAs<TrackedPreferenceValidationObserver>(), On 2014/05/14 18:57:22, grt wrote: > On 2014/05/14 ...
6 years, 7 months ago (2014-05-15 02:07:00 UTC) #7
erikwright (departed)
LGTM.
6 years, 7 months ago (2014-05-15 13:33:32 UTC) #8
grt (UTC plus 2)
The CQ bit was checked by grt@chromium.org
6 years, 7 months ago (2014-05-15 13:36:17 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/grt@chromium.org/266553002/180001
6 years, 7 months ago (2014-05-15 13:36:49 UTC) #10
grt (UTC plus 2)
+mnissler for OWNERS review (and -gab since he's away). Thanks.
6 years, 7 months ago (2014-05-15 13:47:15 UTC) #11
erikwright (departed)
https://codereview.chromium.org/266553002/diff/80001/chrome/browser/prefs/mock_validation_observer.h File chrome/browser/prefs/mock_validation_observer.h (right): https://codereview.chromium.org/266553002/diff/80001/chrome/browser/prefs/mock_validation_observer.h#newcode31 chrome/browser/prefs/mock_validation_observer.h:31: std::string pref_path; > > Rationale: a method could be ...
6 years, 7 months ago (2014-05-15 13:49:02 UTC) #12
Mattias Nissler (ping if slow)
The code looks mostly good, except for the ownership weirdness I've pointed out in the ...
6 years, 7 months ago (2014-05-15 14:32:24 UTC) #13
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). Please consider checking whether the failures are ...
6 years, 7 months ago (2014-05-15 14:34:59 UTC) #14
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 7 months ago (2014-05-15 14:39:05 UTC) #15
commit-bot: I haz the power
Try jobs failed on following builders: chromium_presubmit on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/chromium_presubmit/builds/67872)
6 years, 7 months ago (2014-05-15 14:39:05 UTC) #16
erikwright (departed)
https://codereview.chromium.org/266553002/diff/180001/chrome/browser/prefs/pref_hash_filter.h File chrome/browser/prefs/pref_hash_filter.h (right): https://codereview.chromium.org/266553002/diff/180001/chrome/browser/prefs/pref_hash_filter.h#newcode67 chrome/browser/prefs/pref_hash_filter.h:67: scoped_ptr<TrackedPreferenceValidationObserver> observer, On 2014/05/15 14:32:25, Mattias Nissler wrote: > ...
6 years, 7 months ago (2014-05-15 14:44:50 UTC) #17
Mattias Nissler (ping if slow)
https://codereview.chromium.org/266553002/diff/180001/chrome/browser/prefs/pref_hash_filter.h File chrome/browser/prefs/pref_hash_filter.h (right): https://codereview.chromium.org/266553002/diff/180001/chrome/browser/prefs/pref_hash_filter.h#newcode67 chrome/browser/prefs/pref_hash_filter.h:67: scoped_ptr<TrackedPreferenceValidationObserver> observer, On 2014/05/15 14:44:51, erikwright wrote: > On ...
6 years, 7 months ago (2014-05-15 14:55:07 UTC) #18
grt (UTC plus 2)
Thanks for the comments, Mattias. https://codereview.chromium.org/266553002/diff/180001/chrome/browser/prefs/mock_validation_observer.h File chrome/browser/prefs/mock_validation_observer.h (right): https://codereview.chromium.org/266553002/diff/180001/chrome/browser/prefs/mock_validation_observer.h#newcode23 chrome/browser/prefs/mock_validation_observer.h:23: class ValidationData : public ...
6 years, 7 months ago (2014-05-15 18:21:34 UTC) #19
Mattias Nissler (ping if slow)
I still find it hard to reason about this without having seen the code that ...
6 years, 7 months ago (2014-05-16 10:34:47 UTC) #20
grt (UTC plus 2)
As it happens, the safe browsing service is shut down before pref hash filters are ...
6 years, 7 months ago (2014-05-16 20:35:44 UTC) #21
Mattias Nissler (ping if slow)
On 2014/05/16 20:35:44, grt wrote: > As it happens, the safe browsing service is shut ...
6 years, 7 months ago (2014-05-21 08:36:37 UTC) #22
grt (UTC plus 2)
Hi Mattias and Erik. I've switched from Observer to Delegate, where the Delegate is owned ...
6 years, 7 months ago (2014-05-25 17:24:23 UTC) #23
Mattias Nissler (ping if slow)
LGTM w/ nits. https://codereview.chromium.org/266553002/diff/280001/chrome/browser/prefs/mock_validation_delegate.h File chrome/browser/prefs/mock_validation_delegate.h (right): https://codereview.chromium.org/266553002/diff/280001/chrome/browser/prefs/mock_validation_delegate.h#newcode70 chrome/browser/prefs/mock_validation_delegate.h:70: std::vector<ValidationEvent> validations_; nit: I think the ...
6 years, 7 months ago (2014-05-26 07:01:14 UTC) #24
grt (UTC plus 2)
Thanks. +noms for chrome/profiles OWNERS review https://codereview.chromium.org/266553002/diff/280001/chrome/browser/prefs/mock_validation_delegate.h File chrome/browser/prefs/mock_validation_delegate.h (right): https://codereview.chromium.org/266553002/diff/280001/chrome/browser/prefs/mock_validation_delegate.h#newcode70 chrome/browser/prefs/mock_validation_delegate.h:70: std::vector<ValidationEvent> validations_; On ...
6 years, 7 months ago (2014-05-26 13:28:15 UTC) #25
grt (UTC plus 2)
On 2014/05/26 13:28:15, grt wrote: > +noms for chrome/profiles OWNERS review make that chrome/browser/profiles. thanks.
6 years, 7 months ago (2014-05-26 13:28:51 UTC) #26
noms (inactive)
profiles lgtm with a small formatting nit. https://codereview.chromium.org/266553002/diff/300001/chrome/browser/profiles/profile_impl.cc File chrome/browser/profiles/profile_impl.cc (right): https://codereview.chromium.org/266553002/diff/300001/chrome/browser/profiles/profile_impl.cc#newcode476 chrome/browser/profiles/profile_impl.cc:476: sequenced_task_runner, I ...
6 years, 7 months ago (2014-05-26 13:38:20 UTC) #27
noms (inactive)
I think your CL title is cut off too :) On 2014/05/26 13:38:20, Monica Dinculescu ...
6 years, 7 months ago (2014-05-26 13:39:03 UTC) #28
grt (UTC plus 2)
Thanks. Also shortened the text for the issue's "Subject" for your reading pleasure, although this ...
6 years, 7 months ago (2014-05-26 14:30:20 UTC) #29
erikwright (departed)
LGTM. https://codereview.chromium.org/266553002/diff/180001/chrome/browser/prefs/pref_hash_filter.h File chrome/browser/prefs/pref_hash_filter.h (right): https://codereview.chromium.org/266553002/diff/180001/chrome/browser/prefs/pref_hash_filter.h#newcode67 chrome/browser/prefs/pref_hash_filter.h:67: scoped_ptr<TrackedPreferenceValidationObserver> observer, On 2014/05/15 14:55:08, Mattias Nissler wrote: ...
6 years, 7 months ago (2014-05-26 16:38:54 UTC) #30
Mattias Nissler (ping if slow)
On 2014/05/26 16:38:54, erikwright wrote: > LGTM. > > https://codereview.chromium.org/266553002/diff/180001/chrome/browser/prefs/pref_hash_filter.h > File chrome/browser/prefs/pref_hash_filter.h (right): > ...
6 years, 7 months ago (2014-05-26 16:46:50 UTC) #31
grt (UTC plus 2)
The CQ bit was checked by grt@chromium.org
6 years, 7 months ago (2014-05-26 17:03:34 UTC) #32
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/grt@chromium.org/266553002/320001
6 years, 7 months ago (2014-05-26 17:03:44 UTC) #33
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). Please consider checking whether the failures are ...
6 years, 7 months ago (2014-05-26 18:48:01 UTC) #34
commit-bot: I haz the power
Change committed as 272880
6 years, 7 months ago (2014-05-26 23:43:12 UTC) #35
gab
6 years, 6 months ago (2014-06-10 16:22:09 UTC) #36
Message was sent while issue was closed.
Took a sneak peek at this on my way back from leave.

Mostly nits, but also one question about the
TrackedPreferenceValidationDelegate's interface.

Cheers!
Gab

https://codereview.chromium.org/266553002/diff/320001/chrome/browser/prefs/pr...
File chrome/browser/prefs/pref_hash_filter_unittest.cc (right):

https://codereview.chromium.org/266553002/diff/320001/chrome/browser/prefs/pr...
chrome/browser/prefs/pref_hash_filter_unittest.cc:567: const
MockValidationDelegate::ValidationEvent* validated_atomic_pref =
In all of these tests, the "atomic" part of the test always comes before the
"split" equivalent part of the test.

Swap the last test here to keep this consistency.

https://codereview.chromium.org/266553002/diff/320001/chrome/browser/prefs/pr...
File chrome/browser/prefs/profile_pref_store_manager_unittest.cc (right):

https://codereview.chromium.org/266553002/diff/320001/chrome/browser/prefs/pr...
chrome/browser/prefs/profile_pref_store_manager_unittest.cc:240: if
(!ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking)
You could test this too here, change this method's to:

// Expect a validation event unless this platform doesn't support preference
tracking.
EXPECT_EQ(ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking,
          mock_validation_delegate_.GetEventForPath(pref_path) != NULL) <<
"...";

https://codereview.chromium.org/266553002/diff/320001/chrome/browser/prefs/pr...
chrome/browser/prefs/profile_pref_store_manager_unittest.cc:472:
ExpectValidationObserved(kProtectedAtomic);
You do this verification often after InitializePrefs() in many tests which is
redundant. This verification would also often be more relevant later in the
test.

I suggest:
1) Make the MockTrackedPreferenceValidationDelegate resetable (i.e., allow its
users to clear recorded events; allowing this test to test validation events
multiple times).
2) Move the validation in the generic methods of this test (e.g., in
InitializePrefs() and in LoadExistingPrefs() rather than duplicating this code
inline in every test).

https://codereview.chromium.org/266553002/diff/320001/chrome/browser/prefs/tr...
File chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h
(right):

https://codereview.chromium.org/266553002/diff/320001/chrome/browser/prefs/tr...
chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h:25: //
Notifies observes of the result (|value_state|) of checking the atomic
s/observes/observers ?

https://codereview.chromium.org/266553002/diff/320001/chrome/browser/prefs/tr...
chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h:34: //
Notifies observes of the result (|value_state|) of checking the split
s/observes/observers

https://codereview.chromium.org/266553002/diff/320001/chrome/browser/prefs/tr...
chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h:43:
TrackedPreferenceHelper::ResetAction reset_action) = 0;
Why would you need to track atomic/split preferences differently?

I'd think the only thing an observer would care about is the |pref_path|,
|value_state|, and |reset_action|.

Why would it need the atomic/split strategy, the |value| and the |invalid_keys|?

At least the current mock tests don't really test |value| and |invalid_keys|
(they do test strategy for the sake of coverage, but don't otherwise indicate a
reason for reporting both differently).

Powered by Google App Engine
This is Rietveld 408576698