| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ownership_service.h" | 5 #include "chrome/browser/chromeos/login/ownership_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 // object is created before spawning threads. | 48 // object is created before spawning threads. |
| 49 if (g_ownership_service == this) { | 49 if (g_ownership_service == this) { |
| 50 // Start getting ownership status. | 50 // Start getting ownership status. |
| 51 BrowserThread::PostTask( | 51 BrowserThread::PostTask( |
| 52 BrowserThread::FILE, FROM_HERE, | 52 BrowserThread::FILE, FROM_HERE, |
| 53 base::Bind(&OwnershipService::FetchStatus, base::Unretained(this))); | 53 base::Bind(&OwnershipService::FetchStatus, base::Unretained(this))); |
| 54 } else { | 54 } else { |
| 55 // This can happen only for particular test: OwnershipServiceTest. It uses | 55 // This can happen only for particular test: OwnershipServiceTest. It uses |
| 56 // mocks and for that uses OwnershipService not as a regular singleton but | 56 // mocks and for that uses OwnershipService not as a regular singleton but |
| 57 // as a resurrecting object. This behaviour conflicts with | 57 // as a resurrecting object. This behaviour conflicts with |
| 58 // DISABLE_RUNNABLE_METHOD_REFCOUNT. So avoid posting task in those | 58 // base::Unretained(). So avoid posting task in those circumstances |
| 59 // circumstances in order to avoid accessing already deleted object. | 59 // in order to avoid accessing already deleted object. |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool OwnershipService::IsAlreadyOwned() { | 63 bool OwnershipService::IsAlreadyOwned() { |
| 64 return file_util::PathExists(utils_->GetOwnerKeyFilePath()); | 64 return file_util::PathExists(utils_->GetOwnerKeyFilePath()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 OwnershipService::Status OwnershipService::GetStatus(bool blocking) { | 67 OwnershipService::Status OwnershipService::GetStatus(bool blocking) { |
| 68 if (force_ownership_) | 68 if (force_ownership_) |
| 69 return OWNERSHIP_TAKEN; | 69 return OWNERSHIP_TAKEN; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 SetStatus(status); | 214 SetStatus(status); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void OwnershipService::SetStatus(Status new_status) { | 217 void OwnershipService::SetStatus(Status new_status) { |
| 218 DCHECK(new_status == OWNERSHIP_TAKEN || new_status == OWNERSHIP_NONE); | 218 DCHECK(new_status == OWNERSHIP_TAKEN || new_status == OWNERSHIP_NONE); |
| 219 base::AutoLock lk(ownership_status_lock_); | 219 base::AutoLock lk(ownership_status_lock_); |
| 220 ownership_status_ = new_status; | 220 ownership_status_ = new_status; |
| 221 } | 221 } |
| 222 | 222 |
| 223 } // namespace chromeos | 223 } // namespace chromeos |
| OLD | NEW |