OLD | NEW |
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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 Enqueue( | 140 Enqueue( |
141 new StoreSettingsOperation( | 141 new StoreSettingsOperation( |
142 base::Bind(&DeviceSettingsService::HandleCompletedOperation, | 142 base::Bind(&DeviceSettingsService::HandleCompletedOperation, |
143 weak_factory_.GetWeakPtr(), | 143 weak_factory_.GetWeakPtr(), |
144 callback), | 144 callback), |
145 policy.Pass())); | 145 policy.Pass())); |
146 } | 146 } |
147 | 147 |
148 DeviceSettingsService::OwnershipStatus | 148 DeviceSettingsService::OwnershipStatus |
149 DeviceSettingsService::GetOwnershipStatus() { | 149 DeviceSettingsService::GetOwnershipStatus() { |
150 if (public_key_) | 150 if (public_key_.get()) |
151 return public_key_->is_loaded() ? OWNERSHIP_TAKEN : OWNERSHIP_NONE; | 151 return public_key_->is_loaded() ? OWNERSHIP_TAKEN : OWNERSHIP_NONE; |
152 return OWNERSHIP_UNKNOWN; | 152 return OWNERSHIP_UNKNOWN; |
153 } | 153 } |
154 | 154 |
155 void DeviceSettingsService::GetOwnershipStatusAsync( | 155 void DeviceSettingsService::GetOwnershipStatusAsync( |
156 const OwnershipStatusCallback& callback) { | 156 const OwnershipStatusCallback& callback) { |
157 if (public_key_) { | 157 if (public_key_.get()) { |
158 // If there is a key, report status immediately. | 158 // If there is a key, report status immediately. |
159 base::MessageLoop::current()->PostTask( | 159 base::MessageLoop::current()->PostTask( |
160 FROM_HERE, base::Bind(callback, GetOwnershipStatus())); | 160 FROM_HERE, base::Bind(callback, GetOwnershipStatus())); |
161 } else { | 161 } else { |
162 // If the key hasn't been loaded yet, enqueue the callback to be fired when | 162 // If the key hasn't been loaded yet, enqueue the callback to be fired when |
163 // the next SessionManagerOperation completes. If no operation is pending, | 163 // the next SessionManagerOperation completes. If no operation is pending, |
164 // start a load operation to fetch the key and report the result. | 164 // start a load operation to fetch the key and report the result. |
165 pending_ownership_status_callbacks_.push_back(callback); | 165 pending_ownership_status_callbacks_.push_back(callback); |
166 if (pending_operations_.empty()) | 166 if (pending_operations_.empty()) |
167 EnqueueLoad(false); | 167 EnqueueLoad(false); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 DeviceSettingsService::Initialize(); | 352 DeviceSettingsService::Initialize(); |
353 } | 353 } |
354 | 354 |
355 ScopedTestDeviceSettingsService::~ScopedTestDeviceSettingsService() { | 355 ScopedTestDeviceSettingsService::~ScopedTestDeviceSettingsService() { |
356 // Clean pending operations. | 356 // Clean pending operations. |
357 DeviceSettingsService::Get()->UnsetSessionManager(); | 357 DeviceSettingsService::Get()->UnsetSessionManager(); |
358 DeviceSettingsService::Shutdown(); | 358 DeviceSettingsService::Shutdown(); |
359 } | 359 } |
360 | 360 |
361 } // namespace chromeos | 361 } // namespace chromeos |
OLD | NEW |