| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/login/signed_settings.h" | 5 #include "chrome/browser/chromeos/login/signed_settings.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/threading/thread_restrictions.h" |
| 12 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/browser_thread.h" | 14 #include "chrome/browser/browser_thread.h" |
| 14 #include "chrome/browser/chromeos/cros/cros_library.h" | 15 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 15 #include "chrome/browser/chromeos/cros/login_library.h" | 16 #include "chrome/browser/chromeos/cros/login_library.h" |
| 16 #include "chrome/browser/chromeos/login/authenticator.h" | 17 #include "chrome/browser/chromeos/login/authenticator.h" |
| 17 #include "chrome/browser/chromeos/login/ownership_service.h" | 18 #include "chrome/browser/chromeos/login/ownership_service.h" |
| 18 #include "chrome/browser/chromeos/login/signed_settings_temp_storage.h" | 19 #include "chrome/browser/chromeos/login/signed_settings_temp_storage.h" |
| 19 | 20 |
| 20 namespace chromeos { | 21 namespace chromeos { |
| 21 | 22 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 const std::string& value, | 235 const std::string& value, |
| 235 SignedSettings::Delegate<bool>* d) | 236 SignedSettings::Delegate<bool>* d) |
| 236 : name_(name), | 237 : name_(name), |
| 237 value_(value), | 238 value_(value), |
| 238 d_(d) { | 239 d_(d) { |
| 239 } | 240 } |
| 240 | 241 |
| 241 StorePropertyOp::~StorePropertyOp() {} | 242 StorePropertyOp::~StorePropertyOp() {} |
| 242 | 243 |
| 243 void StorePropertyOp::Execute() { | 244 void StorePropertyOp::Execute() { |
| 244 if (!service_->IsAlreadyOwned()) { | 245 bool is_owned = false; |
| 246 { |
| 247 // This should not do blocking IO from the UI thread. |
| 248 // Temporarily allow it for now. http://crbug.com/70097 |
| 249 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 250 is_owned = service_->IsAlreadyOwned(); |
| 251 } |
| 252 if (!is_owned) { |
| 245 if (g_browser_process && | 253 if (g_browser_process && |
| 246 g_browser_process->local_state() && | 254 g_browser_process->local_state() && |
| 247 SignedSettingsTempStorage::Store(name_, value_, | 255 SignedSettingsTempStorage::Store(name_, value_, |
| 248 g_browser_process->local_state())) { | 256 g_browser_process->local_state())) { |
| 249 d_->OnSettingsOpCompleted(SUCCESS, true); | 257 d_->OnSettingsOpCompleted(SUCCESS, true); |
| 250 return; | 258 return; |
| 251 } | 259 } |
| 252 } | 260 } |
| 253 // Posts a task to the FILE thread to sign |name_|=|value_|. | 261 // Posts a task to the FILE thread to sign |name_|=|value_|. |
| 254 std::string to_sign = base::StringPrintf("%s=%s", | 262 std::string to_sign = base::StringPrintf("%s=%s", |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 306 |
| 299 RetrievePropertyOp::~RetrievePropertyOp() {} | 307 RetrievePropertyOp::~RetrievePropertyOp() {} |
| 300 | 308 |
| 301 void RetrievePropertyOp::Execute() { | 309 void RetrievePropertyOp::Execute() { |
| 302 CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded()); | 310 CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded()); |
| 303 // TODO(dilmah): Fix the race: | 311 // TODO(dilmah): Fix the race: |
| 304 // At the moment when device becomes owned there is lapse of time after | 312 // At the moment when device becomes owned there is lapse of time after |
| 305 // device has been owned and before temp_storage settings are finally | 313 // device has been owned and before temp_storage settings are finally |
| 306 // persisted into signed settings. | 314 // persisted into signed settings. |
| 307 // In this lapse of time Retrieve loses access to those settings. | 315 // In this lapse of time Retrieve loses access to those settings. |
| 308 if (!service_->IsAlreadyOwned()) { | 316 bool is_owned = false; |
| 317 { |
| 318 // This should not do blocking IO from the UI thread. |
| 319 // Temporarily allow it for now. http://crbug.com/70097 |
| 320 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 321 is_owned = service_->IsAlreadyOwned(); |
| 322 } |
| 323 if (!is_owned) { |
| 309 if (g_browser_process && | 324 if (g_browser_process && |
| 310 g_browser_process->local_state() && | 325 g_browser_process->local_state() && |
| 311 SignedSettingsTempStorage::Retrieve( | 326 SignedSettingsTempStorage::Retrieve( |
| 312 name_, &value_, g_browser_process->local_state())) { | 327 name_, &value_, g_browser_process->local_state())) { |
| 313 BrowserThread::PostTask( | 328 BrowserThread::PostTask( |
| 314 BrowserThread::UI, FROM_HERE, | 329 BrowserThread::UI, FROM_HERE, |
| 315 NewRunnableMethod(this, | 330 NewRunnableMethod(this, |
| 316 &RetrievePropertyOp::OnKeyOpComplete, | 331 &RetrievePropertyOp::OnKeyOpComplete, |
| 317 OwnerManager::SUCCESS, std::vector<uint8>())); | 332 OwnerManager::SUCCESS, std::vector<uint8>())); |
| 318 return; | 333 return; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 345 } | 360 } |
| 346 // Now, sure we're on the UI thread. | 361 // Now, sure we're on the UI thread. |
| 347 if (return_code == OwnerManager::SUCCESS) | 362 if (return_code == OwnerManager::SUCCESS) |
| 348 d_->OnSettingsOpCompleted(SUCCESS, value_); | 363 d_->OnSettingsOpCompleted(SUCCESS, value_); |
| 349 else | 364 else |
| 350 d_->OnSettingsOpCompleted(SignedSettings::MapKeyOpCode(return_code), | 365 d_->OnSettingsOpCompleted(SignedSettings::MapKeyOpCode(return_code), |
| 351 std::string()); | 366 std::string()); |
| 352 } | 367 } |
| 353 | 368 |
| 354 } // namespace chromeos | 369 } // namespace chromeos |
| OLD | NEW |