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

Side by Side Diff: chrome/browser/chromeos/policy/enterprise_install_attributes.h

Issue 1189203003: Add UMA for consistency between TPM and install attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master3
Patch Set: Simplified after comments by Mattias. Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_ 6 #define CHROME_BROWSER_CHROMEOS_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 typedef base::Callback<void(LockResult lock_result)> LockResultCallback; 45 typedef base::Callback<void(LockResult lock_result)> LockResultCallback;
46 46
47 // Return serialized InstallAttributes of an enterprise-owned configuration. 47 // Return serialized InstallAttributes of an enterprise-owned configuration.
48 static std::string GetEnterpriseOwnedInstallAttributesBlobForTesting( 48 static std::string GetEnterpriseOwnedInstallAttributesBlobForTesting(
49 const std::string& user_name); 49 const std::string& user_name);
50 50
51 explicit EnterpriseInstallAttributes( 51 explicit EnterpriseInstallAttributes(
52 chromeos::CryptohomeClient* cryptohome_client); 52 chromeos::CryptohomeClient* cryptohome_client);
53 ~EnterpriseInstallAttributes(); 53 ~EnterpriseInstallAttributes();
54 54
55 // Reads data from the cache file which is created early during the boot 55 // Tries to read install attributes from the cache file which is created early
56 // process. The cache file is used to work around slow cryptohome startup, 56 // during the boot process. The cache file is used to work around slow
57 // which takes a while to register its DBus interface. See 57 // cryptohome startup, which takes a while to register its DBus interface.
58 // http://crosbug.com/37367 for background on this. 58 // (See http://crosbug.com/37367 for background on this.)
59 void ReadCacheFile(const base::FilePath& cache_file); 59 void Init(const base::FilePath& cache_file);
60 60
61 // Makes sure the local caches for enterprise-related install attributes are 61 // Makes sure the local caches for enterprise-related install attributes are
62 // up-to-date with what cryptohome has. This method checks the readiness of 62 // up-to-date with what cryptohome has. This method checks the readiness of
63 // attributes and read them if ready. Actual read will be performed in 63 // attributes and read them if ready. Actual read will be performed in
64 // ReadAttributesIfReady(). 64 // ReadAttributesIfReady().
65 void ReadImmutableAttributes(const base::Closure& callback); 65 void ReadImmutableAttributes(const base::Closure& callback);
66 66
67 // Locks the device to be an enterprise device registered by the given user. 67 // Locks the device to be an enterprise device registered by the given user.
68 // This can also be called after the lock has already been taken, in which 68 // This can also be called after the lock has already been taken, in which
69 // case it checks that the passed user agrees with the locked attribute. 69 // case it checks that the passed user agrees with the locked attribute.
(...skipping 20 matching lines...) Expand all
90 // Gets the device id that was generated when the device was registered. 90 // Gets the device id that was generated when the device was registered.
91 // Returns an empty string if the device is not an enterprise device or the 91 // Returns an empty string if the device is not an enterprise device or the
92 // device id was not stored in the lockbox (prior to R19). 92 // device id was not stored in the lockbox (prior to R19).
93 std::string GetDeviceId(); 93 std::string GetDeviceId();
94 94
95 // Gets the mode the device was enrolled to. The return value for devices that 95 // Gets the mode the device was enrolled to. The return value for devices that
96 // are not locked yet will be DEVICE_MODE_UNKNOWN. 96 // are not locked yet will be DEVICE_MODE_UNKNOWN.
97 DeviceMode GetMode(); 97 DeviceMode GetMode();
98 98
99 protected: 99 protected:
100 // True if install attributes have been read successfully. False if read
101 // failed or no read attempt was made.
100 bool device_locked_; 102 bool device_locked_;
Mattias Nissler (ping if slow) 2015/06/24 08:34:39 nit: blank line before comment.
Thiemo Nagel 2015/06/24 10:43:36 Done.
103 // Whether the TPM / install attributes consistency check is running.
104 bool consistency_check_running_;
Mattias Nissler (ping if slow) 2015/06/24 08:34:39 nit: blank line before comment.
Thiemo Nagel 2015/06/24 10:43:36 Done.
105 // To be run after the consistency check has finished.
106 base::Closure post_check_action_;
Mattias Nissler (ping if slow) 2015/06/24 08:34:39 nit: blank line here. The members below conceptual
Thiemo Nagel 2015/06/24 10:43:36 Done.
101 std::string registration_user_; 107 std::string registration_user_;
102 std::string registration_domain_; 108 std::string registration_domain_;
103 std::string registration_device_id_; 109 std::string registration_device_id_;
104 DeviceMode registration_mode_; 110 DeviceMode registration_mode_;
105 111
106 private: 112 private:
107 FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest, 113 FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest,
108 DeviceLockedFromOlderVersion); 114 DeviceLockedFromOlderVersion);
109 FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest, 115 FRIEND_TEST_ALL_PREFIXES(EnterpriseInstallAttributesTest,
110 ReadCacheFile); 116 ReadCacheFile);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 DeviceMode device_mode, 157 DeviceMode device_mode,
152 const std::string& device_id, 158 const std::string& device_id,
153 const LockResultCallback& callback, 159 const LockResultCallback& callback,
154 chromeos::DBusMethodCallStatus call_status, 160 chromeos::DBusMethodCallStatus call_status,
155 bool result); 161 bool result);
156 162
157 // Confirms the registered user and invoke the callback. 163 // Confirms the registered user and invoke the callback.
158 void OnReadImmutableAttributes(const std::string& user, 164 void OnReadImmutableAttributes(const std::string& user,
159 const LockResultCallback& callback); 165 const LockResultCallback& callback);
160 166
167 // Check state of install attributes against TPM lock state and generate UMA
168 // for the result. Asynchronously retry |dbus_tries| times in case of DBUS
169 // errors (cryptohomed startup is slow).
170 void TriggerConsistencyCheck(int dbus_tries);
171
172 // Callback for TpmIsOwned() DBUS call. Generates UMA or schedules retry in
173 // case of DBUS error.
174 void OnTpmIsOwned(int dbus_tries_remaining,
Mattias Nissler (ping if slow) 2015/06/24 08:34:39 The name of this function is misleading. Should On
Thiemo Nagel 2015/06/24 10:43:36 You're right. Done.
175 chromeos::DBusMethodCallStatus call_status,
176 bool result);
177
161 chromeos::CryptohomeClient* cryptohome_client_; 178 chromeos::CryptohomeClient* cryptohome_client_;
162 179
163 base::WeakPtrFactory<EnterpriseInstallAttributes> weak_ptr_factory_; 180 base::WeakPtrFactory<EnterpriseInstallAttributes> weak_ptr_factory_;
164 181
165 DISALLOW_COPY_AND_ASSIGN(EnterpriseInstallAttributes); 182 DISALLOW_COPY_AND_ASSIGN(EnterpriseInstallAttributes);
166 }; 183 };
167 184
168 } // namespace policy 185 } // namespace policy
169 186
170 #endif // CHROME_BROWSER_CHROMEOS_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_ 187 #endif // CHROME_BROWSER_CHROMEOS_POLICY_ENTERPRISE_INSTALL_ATTRIBUTES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698