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

Side by Side Diff: chrome/browser/chromeos/device_settings_provider.h

Issue 8727037: Signed settings refactoring: Proper caching and more tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 9 years 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 (c) 2011 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 #ifndef CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_
6 #define CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "base/basictypes.h"
13 #include "base/callback.h"
14 #include "base/hash_tables.h"
15 #include "chrome/browser/chromeos/cros_settings_provider.h"
16 #include "chrome/browser/chromeos/login/signed_settings_helper.h"
17 #include "chrome/browser/chromeos/signed_settings_migration_helper.h"
18 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
19 #include "content/public/browser/notification_registrar.h"
20
21 namespace em = enterprise_management;
22
23 class PrefService;
24
25 namespace base {
26 class ListValue;
27 }
28
29 namespace chromeos {
30
31 class OwnershipService;
32
33 // CrosSettingsProvider implementation that works with SignedSettings.
34 class DeviceSettingsProvider : public CrosSettingsProvider,
35 public content::NotificationObserver {
36 public:
37 DeviceSettingsProvider();
38 virtual ~DeviceSettingsProvider();
39
40 // CrosSettingsProvider implementation.
41 virtual const base::Value* Get(const std::string& path) const OVERRIDE;
42 virtual bool GetTrusted(const std::string& path,
43 const base::Closure& callback) OVERRIDE;
44 virtual bool HandlesSetting(const std::string& path) const OVERRIDE;
45 virtual void Reload() OVERRIDE;
46
47 private:
48 // CrosSettingsProvider implementation:
49 virtual void DoSet(const std::string& path,
50 const base::Value& value) OVERRIDE;
51
52 // content::NotificationObserver implementation:
53 virtual void Observe(int type,
54 const content::NotificationSource& source,
55 const content::NotificationDetails& details) OVERRIDE;
56
57 const em::PolicyData get_policy() const;
58
59 void RetrieveCachedData();
60
61 void SetInPolicy(const std::string& prop, const base::Value& value);
62
63 // Finalizes stores to the policy file if the cache is dirt
64 void FinishSetInPolicy(const std::string& prop,
65 const base::Value* value,
66 SignedSettings::ReturnCode code,
67 const em::PolicyFetchResponse& policy);
68
69 // Parses the policy cache and fills the cache of base::Value objects.
70 void UpdateValuesCache();
71
72 // Applies the metrics policy and if not set migrates the legacy file.
73 void ApplyMetricsSetting(bool use_file, bool new_value) const;
74
75 // Applies the data roaming policy.
76 void ApplyRoamingSetting(bool new_value) const;
77
78 // Applies any changes of the policies that are not handled by the respective
79 // subsystms.
80 void ApplySideEffects() const;
81
82 // Called right before boolean property is changed.
83 void OnBooleanPropertyChange(const std::string& path, bool new_value);
84
85 // Checks if the current cache value can be trusted for being representative
86 // for the disk cache.
87 bool RequestTrustedEntity();
88
89 // Serializes the temp store to the policy if ownership is taken.
90 void FinalizeTempStorage(SignedSettings::ReturnCode code,
91 const em::PolicyFetchResponse& policy);
92
93 // Called right after signed value was checked.
94 void OnPropertyRetrieve(const std::string& path,
95 const base::Value* value,
96 bool use_default_value);
97
98 // Callback of StorePolicyOp for ordinary policy stores.
99 void OnStorePolicyCompleted(SignedSettings::ReturnCode code);
100
101 // Callback of RetrievePolicyOp for ordinary policy [re]loads.
102 void OnRetrievePolicyCompleted(SignedSettings::ReturnCode code,
103 const em::PolicyFetchResponse& policy);
104
105 // Pending callbacks that need to be invoked after settings verification.
106 std::vector<base::Closure> callbacks_;
107
108 OwnershipService* ownership_service_;
109 mutable scoped_ptr<SignedSettingsMigrationHelper> migration_helper_;
110
111 content::NotificationRegistrar registrar_;
112
113 // In order to guard against occasional failure to fetch a property
114 // we allow for some number of retries.
115 int retries_left_;
116
117 em::PolicyData policy_;
118 bool trusted_;
119
120 PrefValueMap values_cache_;
121
122 friend class SignedSettingsHelper;
123
124 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProvider);
125 };
126
127 } // namespace chromeos
128
129 #endif // CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698