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

Side by Side Diff: chrome/browser/chromeos/settings/device_settings_service.cc

Issue 2798343003: Merge "cros: Fix flaky owner detection" (Closed)
Patch Set: Created 3 years, 8 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 #include "chrome/browser/chromeos/settings/device_settings_service.h" 5 #include "chrome/browser/chromeos/settings/device_settings_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 const std::string& username, 187 const std::string& username,
188 const base::WeakPtr<ownership::OwnerSettingsService>& 188 const base::WeakPtr<ownership::OwnerSettingsService>&
189 owner_settings_service) { 189 owner_settings_service) {
190 // When InitOwner() is called twice with the same |username| it's 190 // When InitOwner() is called twice with the same |username| it's
191 // worth to reload settings since owner key may become available. 191 // worth to reload settings since owner key may become available.
192 if (!username_.empty() && username_ != username) 192 if (!username_.empty() && username_ != username)
193 return; 193 return;
194 username_ = username; 194 username_ = username;
195 owner_settings_service_ = owner_settings_service; 195 owner_settings_service_ = owner_settings_service;
196 196
197 // Reset the flag since consumer ownership should be established now.
198 will_establish_consumer_ownership_ = false;
199
197 EnsureReload(true); 200 EnsureReload(true);
198 } 201 }
199 202
200 const std::string& DeviceSettingsService::GetUsername() const { 203 const std::string& DeviceSettingsService::GetUsername() const {
201 return username_; 204 return username_;
202 } 205 }
203 206
204 ownership::OwnerSettingsService* 207 ownership::OwnerSettingsService*
205 DeviceSettingsService::GetOwnerSettingsService() const { 208 DeviceSettingsService::GetOwnerSettingsService() const {
206 return owner_settings_service_.get(); 209 return owner_settings_service_.get();
207 } 210 }
208 211
212 void DeviceSettingsService::MarkWillEstablishConsumerOwnership() {
213 will_establish_consumer_ownership_ = true;
214 }
215
209 void DeviceSettingsService::AddObserver(Observer* observer) { 216 void DeviceSettingsService::AddObserver(Observer* observer) {
210 observers_.AddObserver(observer); 217 observers_.AddObserver(observer);
211 } 218 }
212 219
213 void DeviceSettingsService::RemoveObserver(Observer* observer) { 220 void DeviceSettingsService::RemoveObserver(Observer* observer) {
214 observers_.RemoveObserver(observer); 221 observers_.RemoveObserver(observer);
215 } 222 }
216 223
217 void DeviceSettingsService::OwnerKeySet(bool success) { 224 void DeviceSettingsService::OwnerKeySet(bool success) {
218 if (!success) { 225 if (!success) {
219 LOG(ERROR) << "Owner key change failed."; 226 LOG(ERROR) << "Owner key change failed.";
220 return; 227 return;
221 } 228 }
222 229
223 public_key_ = NULL; 230 public_key_ = NULL;
224 EnsureReload(true); 231
232 if (GetOwnershipStatus() == OWNERSHIP_TAKEN ||
233 !will_establish_consumer_ownership_) {
234 EnsureReload(true);
235 }
225 } 236 }
226 237
227 void DeviceSettingsService::PropertyChangeComplete(bool success) { 238 void DeviceSettingsService::PropertyChangeComplete(bool success) {
228 if (!success) { 239 if (!success) {
229 LOG(ERROR) << "Policy update failed."; 240 LOG(ERROR) << "Policy update failed.";
230 return; 241 return;
231 } 242 }
232 243
233 EnsureReload(false); 244 if (GetOwnershipStatus() == OWNERSHIP_TAKEN ||
245 !will_establish_consumer_ownership_) {
246 EnsureReload(false);
247 }
234 } 248 }
235 249
236 void DeviceSettingsService::Enqueue( 250 void DeviceSettingsService::Enqueue(
237 const linked_ptr<SessionManagerOperation>& operation) { 251 const linked_ptr<SessionManagerOperation>& operation) {
238 pending_operations_.push_back(operation); 252 pending_operations_.push_back(operation);
239 if (pending_operations_.front().get() == operation.get()) 253 if (pending_operations_.front().get() == operation.get())
240 StartNextOperation(); 254 StartNextOperation();
241 } 255 }
242 256
243 void DeviceSettingsService::EnqueueLoad(bool request_key_load) { 257 void DeviceSettingsService::EnqueueLoad(bool request_key_load) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 DeviceSettingsService::Initialize(); 378 DeviceSettingsService::Initialize();
365 } 379 }
366 380
367 ScopedTestDeviceSettingsService::~ScopedTestDeviceSettingsService() { 381 ScopedTestDeviceSettingsService::~ScopedTestDeviceSettingsService() {
368 // Clean pending operations. 382 // Clean pending operations.
369 DeviceSettingsService::Get()->UnsetSessionManager(); 383 DeviceSettingsService::Get()->UnsetSessionManager();
370 DeviceSettingsService::Shutdown(); 384 DeviceSettingsService::Shutdown();
371 } 385 }
372 386
373 } // namespace chromeos 387 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698