| 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 "chromeos/cryptohome/system_salt_getter.h" | 5 #include "chromeos/cryptohome/system_salt_getter.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 FROM_HERE, base::Bind(callback, system_salt_)); | 35 FROM_HERE, base::Bind(callback, system_salt_)); |
| 36 return; | 36 return; |
| 37 } | 37 } |
| 38 | 38 |
| 39 DBusThreadManager::Get()->GetCryptohomeClient()->WaitForServiceToBeAvailable( | 39 DBusThreadManager::Get()->GetCryptohomeClient()->WaitForServiceToBeAvailable( |
| 40 base::Bind(&SystemSaltGetter::DidWaitForServiceToBeAvailable, | 40 base::Bind(&SystemSaltGetter::DidWaitForServiceToBeAvailable, |
| 41 weak_ptr_factory_.GetWeakPtr(), | 41 weak_ptr_factory_.GetWeakPtr(), |
| 42 callback)); | 42 callback)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 const SystemSaltGetter::RawSalt* SystemSaltGetter::GetRawSalt() const { | |
| 46 return raw_salt_.empty() ? nullptr : &raw_salt_; | |
| 47 } | |
| 48 | |
| 49 void SystemSaltGetter::SetRawSaltForTesting( | |
| 50 const SystemSaltGetter::RawSalt& raw_salt) { | |
| 51 raw_salt_ = raw_salt; | |
| 52 } | |
| 53 | |
| 54 void SystemSaltGetter::DidWaitForServiceToBeAvailable( | 45 void SystemSaltGetter::DidWaitForServiceToBeAvailable( |
| 55 const GetSystemSaltCallback& callback, | 46 const GetSystemSaltCallback& callback, |
| 56 bool service_is_available) { | 47 bool service_is_available) { |
| 57 if (!service_is_available) { | 48 if (!service_is_available) { |
| 58 LOG(ERROR) << "WaitForServiceToBeAvailable failed."; | 49 LOG(ERROR) << "WaitForServiceToBeAvailable failed."; |
| 59 callback.Run(std::string()); | 50 callback.Run(std::string()); |
| 60 return; | 51 return; |
| 61 } | 52 } |
| 62 DBusThreadManager::Get()->GetCryptohomeClient()->GetSystemSalt( | 53 DBusThreadManager::Get()->GetCryptohomeClient()->GetSystemSalt( |
| 63 base::Bind(&SystemSaltGetter::DidGetSystemSalt, | 54 base::Bind(&SystemSaltGetter::DidGetSystemSalt, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 } | 96 } |
| 106 | 97 |
| 107 // static | 98 // static |
| 108 std::string SystemSaltGetter::ConvertRawSaltToHexString( | 99 std::string SystemSaltGetter::ConvertRawSaltToHexString( |
| 109 const std::vector<uint8_t>& salt) { | 100 const std::vector<uint8_t>& salt) { |
| 110 return base::ToLowerASCII( | 101 return base::ToLowerASCII( |
| 111 base::HexEncode(reinterpret_cast<const void*>(salt.data()), salt.size())); | 102 base::HexEncode(reinterpret_cast<const void*>(salt.data()), salt.size())); |
| 112 } | 103 } |
| 113 | 104 |
| 114 } // namespace chromeos | 105 } // namespace chromeos |
| OLD | NEW |