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

Side by Side Diff: chrome/browser/prefs/tracked_atomic_preference.cc

Issue 114223002: Multi-strategy based tracking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang compile? Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/prefs/tracked_atomic_preference.h"
6
7 #include "base/values.h"
8
9 TrackedAtomicPreference::TrackedAtomicPreference(
10 const std::string& pref_path,
11 size_t reporting_id,
12 size_t reporting_ids_count,
13 EnforcementLevel enforcement_level)
14 : TrackedPreference(reporting_id, reporting_ids_count, enforcement_level),
15 pref_path_(pref_path) {
16 }
17
18 void TrackedAtomicPreference::StoreHash(const base::Value* value,
19 PrefHashStore* pref_hash_store) const {
20 pref_hash_store->StoreHash(pref_path_, value);
21 }
22
23 void TrackedAtomicPreference::EnforceAndReport(
24 PrefHashStore* pref_hash_store,
25 base::DictionaryValue* pref_store_contents) const {
26 const base::Value* value = NULL;
27 pref_store_contents->Get(pref_path_, &value);
28 PrefHashStore::ValueState value_state =
29 pref_hash_store->CheckValue(pref_path_, value);
30
31 ReportValidationResult(value_state);
32
33 ResetAction reset_action = GetAction(value_state);
34 ReportAction(reset_action);
35
36 if (reset_action == DO_RESET)
37 pref_store_contents->RemovePath(pref_path_, NULL);
38
39 if (value_state != PrefHashStore::UNCHANGED) {
40 // Store the hash for the new value (whether it was reset or not).
41 const base::Value* new_value = NULL;
42 pref_store_contents->Get(pref_path_, &new_value);
43 pref_hash_store->StoreHash(pref_path_, new_value);
44 }
45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698