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

Side by Side Diff: chrome/browser/chromeos/settings/session_manager_operation.h

Issue 2714493002: Load DeviceLocalAccount policy and DeviceSettings immediately on restore after Chrome crash. (Closed)
Patch Set: reduce duplication and avoid double load start Created 3 years, 9 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_SETTINGS_SESSION_MANAGER_OPERATION_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_ 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 protected: 67 protected:
68 // Runs the operation. The result is reported through |callback_|. 68 // Runs the operation. The result is reported through |callback_|.
69 virtual void Run() = 0; 69 virtual void Run() = 0;
70 70
71 // Ensures the public key is loaded. 71 // Ensures the public key is loaded.
72 void EnsurePublicKey(const base::Closure& callback); 72 void EnsurePublicKey(const base::Closure& callback);
73 73
74 // Starts a load operation. 74 // Starts a load operation.
75 void StartLoading(); 75 void StartLoading();
76 76
77 // Synchronous load operation.
78 void LoadImmediately();
79
77 // Reports the result status of the operation. Once this gets called, the 80 // Reports the result status of the operation. Once this gets called, the
78 // operation should not perform further processing or trigger callbacks. 81 // operation should not perform further processing or trigger callbacks.
79 void ReportResult(DeviceSettingsService::Status status); 82 void ReportResult(DeviceSettingsService::Status status);
80 83
81 SessionManagerClient* session_manager_client() { 84 SessionManagerClient* session_manager_client() {
82 return session_manager_client_; 85 return session_manager_client_;
83 } 86 }
84 87
85 // Whether to verify the loaded policy's signature against |public_key_| and 88 // Whether to verify the loaded policy's signature against |public_key_| and
86 // perform other cloud-specific validations. (Active Directory policy has no 89 // perform other cloud-specific validations. (Active Directory policy has no
87 // signature that could be verified.) 90 // signature that could be verified.)
88 bool cloud_validations_ = true; 91 bool cloud_validations_ = true;
89 92
90 bool force_key_load_ = false; 93 bool force_key_load_ = false;
91 94
95 bool force_immediate_load_ = false;
96
92 private: 97 private:
93 // Loads the owner key from disk. Must be run on a thread that can do I/O. 98 // Loads the owner key from disk. Must be run on a thread that can do I/O.
94 static scoped_refptr<ownership::PublicKey> LoadPublicKey( 99 static scoped_refptr<ownership::PublicKey> LoadPublicKey(
95 scoped_refptr<ownership::OwnerKeyUtil> util, 100 scoped_refptr<ownership::OwnerKeyUtil> util,
96 scoped_refptr<ownership::PublicKey> current_key); 101 scoped_refptr<ownership::PublicKey> current_key);
97 102
98 // Stores the owner key loaded by LoadOwnerKey and calls |callback|. 103 // Stores the owner key loaded by LoadOwnerKey and calls |callback|.
99 void StorePublicKey(const base::Closure& callback, 104 void StorePublicKey(const base::Closure& callback,
100 scoped_refptr<ownership::PublicKey> new_key); 105 scoped_refptr<ownership::PublicKey> new_key);
101 106
102 // Triggers a device settings load. 107 // Triggers a device settings load.
103 void RetrieveDeviceSettings(); 108 void RetrieveDeviceSettings();
104 109
110 // Same as RetrieveDeviceSettings, but loads synchronously.
111 void BlockingRetrieveDeviceSettings();
112
105 // Validates device settings after retrieval from session_manager. 113 // Validates device settings after retrieval from session_manager.
106 void ValidateDeviceSettings(const std::string& policy_blob); 114 void ValidateDeviceSettings(const std::string& policy_blob);
107 115
108 // Extracts status and device settings from the validator and reports them. 116 // Extracts status and device settings from the validator and reports them.
109 void ReportValidatorStatus(policy::DeviceCloudPolicyValidator* validator); 117 void ReportValidatorStatus(policy::DeviceCloudPolicyValidator* validator);
110 118
111 SessionManagerClient* session_manager_client_ = nullptr; 119 SessionManagerClient* session_manager_client_ = nullptr;
112 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_; 120 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_;
113 121
114 Callback callback_; 122 Callback callback_;
115 123
116 scoped_refptr<ownership::PublicKey> public_key_; 124 scoped_refptr<ownership::PublicKey> public_key_;
117 125
118 bool is_loading_ = false; 126 bool is_loading_ = false;
119 std::unique_ptr<enterprise_management::PolicyData> policy_data_; 127 std::unique_ptr<enterprise_management::PolicyData> policy_data_;
120 std::unique_ptr<enterprise_management::ChromeDeviceSettingsProto> 128 std::unique_ptr<enterprise_management::ChromeDeviceSettingsProto>
121 device_settings_; 129 device_settings_;
122 130
123 base::WeakPtrFactory<SessionManagerOperation> weak_factory_; 131 base::WeakPtrFactory<SessionManagerOperation> weak_factory_;
124 132
125 DISALLOW_COPY_AND_ASSIGN(SessionManagerOperation); 133 DISALLOW_COPY_AND_ASSIGN(SessionManagerOperation);
126 }; 134 };
127 135
128 // This operation loads the public owner key from disk if appropriate, fetches 136 // This operation loads the public owner key from disk if appropriate, fetches
129 // the policy blob from session manager, and validates the loaded policy blob. 137 // the policy blob from session manager, and validates the loaded policy blob.
130 class LoadSettingsOperation : public SessionManagerOperation { 138 class LoadSettingsOperation : public SessionManagerOperation {
131 public: 139 public:
132 // Creates a new load operation. If |cloud_validations| is true, signature 140 // Creates a new load operation. If |cloud_validations| is true, signature
133 // validation and other cloud-specific checks are performed. 141 // validation and other cloud-specific checks are performed.
142 // If |force_immediate_load| is true, load happens synchronously on Run()
143 // call.
134 LoadSettingsOperation(bool force_key_load, 144 LoadSettingsOperation(bool force_key_load,
135 bool cloud_validations, 145 bool cloud_validations,
146 bool force_immediate_load,
136 const Callback& callback); 147 const Callback& callback);
137 ~LoadSettingsOperation() override; 148 ~LoadSettingsOperation() override;
138 149
139 protected: 150 protected:
140 // SessionManagerOperation: 151 // SessionManagerOperation:
141 void Run() override; 152 void Run() override;
142 153
143 private: 154 private:
144 DISALLOW_COPY_AND_ASSIGN(LoadSettingsOperation); 155 DISALLOW_COPY_AND_ASSIGN(LoadSettingsOperation);
145 }; 156 };
(...skipping 19 matching lines...) Expand all
165 std::unique_ptr<enterprise_management::PolicyFetchResponse> policy_; 176 std::unique_ptr<enterprise_management::PolicyFetchResponse> policy_;
166 177
167 base::WeakPtrFactory<StoreSettingsOperation> weak_factory_; 178 base::WeakPtrFactory<StoreSettingsOperation> weak_factory_;
168 179
169 DISALLOW_COPY_AND_ASSIGN(StoreSettingsOperation); 180 DISALLOW_COPY_AND_ASSIGN(StoreSettingsOperation);
170 }; 181 };
171 182
172 } // namespace chromeos 183 } // namespace chromeos
173 184
174 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_ 185 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698