| 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_status_checker.h" | 5 #include "chrome/browser/chromeos/login/ownership_status_checker.h" |
| 6 | 6 |
| 7 #include "content/browser/browser_thread.h" | 7 #include "content/browser/browser_thread.h" |
| 8 | 8 |
| 9 namespace chromeos { | 9 namespace chromeos { |
| 10 | 10 |
| 11 OwnershipStatusChecker::OwnershipStatusChecker(Callback* callback) | 11 OwnershipStatusChecker::OwnershipStatusChecker(Callback* callback) |
| 12 : core_(new Core(callback)) { | 12 : core_(new Core(callback)) { |
| 13 core_->Check(); | 13 core_->Check(); |
| 14 } | 14 } |
| 15 | 15 |
| 16 OwnershipStatusChecker::~OwnershipStatusChecker() { | 16 OwnershipStatusChecker::~OwnershipStatusChecker() { |
| 17 core_->Cancel(); | 17 core_->Cancel(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 OwnershipStatusChecker::Core::Core(Callback* callback) | 20 OwnershipStatusChecker::Core::Core(Callback* callback) |
| 21 : callback_(callback), | 21 : callback_(callback), |
| 22 origin_loop_(base::MessageLoopProxy::CreateForCurrentThread()) { | 22 origin_loop_(base::MessageLoopProxy::current()) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 OwnershipStatusChecker::Core::~Core() {} | 25 OwnershipStatusChecker::Core::~Core() {} |
| 26 | 26 |
| 27 void OwnershipStatusChecker::Core::Check() { | 27 void OwnershipStatusChecker::Core::Check() { |
| 28 DCHECK(origin_loop_->BelongsToCurrentThread()); | 28 DCHECK(origin_loop_->BelongsToCurrentThread()); |
| 29 OwnershipService::Status status = | 29 OwnershipService::Status status = |
| 30 OwnershipService::GetSharedInstance()->GetStatus(false); | 30 OwnershipService::GetSharedInstance()->GetStatus(false); |
| 31 if (status != OwnershipService::OWNERSHIP_UNKNOWN) { | 31 if (status != OwnershipService::OWNERSHIP_UNKNOWN) { |
| 32 // Take a spin on the message loop in order to avoid reentrancy in callers. | 32 // Take a spin on the message loop in order to avoid reentrancy in callers. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 63 void OwnershipStatusChecker::Core::ReportResult( | 63 void OwnershipStatusChecker::Core::ReportResult( |
| 64 OwnershipService::Status status) { | 64 OwnershipService::Status status) { |
| 65 DCHECK(origin_loop_->BelongsToCurrentThread()); | 65 DCHECK(origin_loop_->BelongsToCurrentThread()); |
| 66 if (callback_.get()) { | 66 if (callback_.get()) { |
| 67 callback_->Run(status); | 67 callback_->Run(status); |
| 68 callback_.reset(); | 68 callback_.reset(); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace chromeos | 72 } // namespace chromeos |
| OLD | NEW |