| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/ownership/owner_settings_service.h" | 5 #include "components/ownership/owner_settings_service.h" |
| 6 | 6 |
| 7 #include <cryptohi.h> | 7 #include <cryptohi.h> |
| 8 #include <keyhi.h> | 8 #include <keyhi.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/task_runner.h" | 16 #include "base/task_runner.h" |
| 17 #include "base/task_runner_util.h" | 17 #include "base/task_runner_util.h" |
| 18 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "base/values.h" | 19 #include "base/values.h" |
| 19 #include "components/ownership/owner_key_util.h" | 20 #include "components/ownership/owner_key_util.h" |
| 20 #include "crypto/scoped_nss_types.h" | 21 #include "crypto/scoped_nss_types.h" |
| 21 | 22 |
| 22 namespace em = enterprise_management; | 23 namespace em = enterprise_management; |
| 23 | 24 |
| 24 namespace ownership { | 25 namespace ownership { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 87 } |
| 87 | 88 |
| 88 bool OwnerSettingsService::IsOwner() { | 89 bool OwnerSettingsService::IsOwner() { |
| 89 DCHECK(thread_checker_.CalledOnValidThread()); | 90 DCHECK(thread_checker_.CalledOnValidThread()); |
| 90 return private_key_.get() && private_key_->key(); | 91 return private_key_.get() && private_key_->key(); |
| 91 } | 92 } |
| 92 | 93 |
| 93 void OwnerSettingsService::IsOwnerAsync(const IsOwnerCallback& callback) { | 94 void OwnerSettingsService::IsOwnerAsync(const IsOwnerCallback& callback) { |
| 94 DCHECK(thread_checker_.CalledOnValidThread()); | 95 DCHECK(thread_checker_.CalledOnValidThread()); |
| 95 if (private_key_.get()) { | 96 if (private_key_.get()) { |
| 96 base::MessageLoop::current()->PostTask(FROM_HERE, | 97 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 97 base::Bind(callback, IsOwner())); | 98 FROM_HERE, base::Bind(callback, IsOwner())); |
| 98 } else { | 99 } else { |
| 99 pending_is_owner_callbacks_.push_back(callback); | 100 pending_is_owner_callbacks_.push_back(callback); |
| 100 } | 101 } |
| 101 } | 102 } |
| 102 | 103 |
| 103 bool OwnerSettingsService::AssembleAndSignPolicyAsync( | 104 bool OwnerSettingsService::AssembleAndSignPolicyAsync( |
| 104 base::TaskRunner* task_runner, | 105 base::TaskRunner* task_runner, |
| 105 std::unique_ptr<em::PolicyData> policy, | 106 std::unique_ptr<em::PolicyData> policy, |
| 106 const AssembleAndSignPolicyAsyncCallback& callback) { | 107 const AssembleAndSignPolicyAsyncCallback& callback) { |
| 107 DCHECK(thread_checker_.CalledOnValidThread()); | 108 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 for (std::vector<IsOwnerCallback>::iterator it(is_owner_callbacks.begin()); | 160 for (std::vector<IsOwnerCallback>::iterator it(is_owner_callbacks.begin()); |
| 160 it != is_owner_callbacks.end(); | 161 it != is_owner_callbacks.end(); |
| 161 ++it) { | 162 ++it) { |
| 162 it->Run(is_owner); | 163 it->Run(is_owner); |
| 163 } | 164 } |
| 164 | 165 |
| 165 OnPostKeypairLoadedActions(); | 166 OnPostKeypairLoadedActions(); |
| 166 } | 167 } |
| 167 | 168 |
| 168 } // namespace ownership | 169 } // namespace ownership |
| OLD | NEW |