Chromium Code Reviews| 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 if (!raw_salt_.empty()) | |
|
Darren Krahn
2016/04/13 16:33:43
optional: candidate for a ternary operator?
retu
Alexander Alekseev
2016/04/14 03:37:29
Done.
| |
| 47 return &raw_salt_; | |
| 48 | |
| 49 return nullptr; | |
| 50 } | |
| 51 | |
| 52 void SystemSaltGetter::SetRawSaltForTesting( | |
| 53 const SystemSaltGetter::RawSalt& raw_salt) { | |
| 54 raw_salt_ = raw_salt; | |
| 55 } | |
| 56 | |
| 45 void SystemSaltGetter::DidWaitForServiceToBeAvailable( | 57 void SystemSaltGetter::DidWaitForServiceToBeAvailable( |
| 46 const GetSystemSaltCallback& callback, | 58 const GetSystemSaltCallback& callback, |
| 47 bool service_is_available) { | 59 bool service_is_available) { |
| 48 if (!service_is_available) { | 60 if (!service_is_available) { |
| 49 LOG(ERROR) << "WaitForServiceToBeAvailable failed."; | 61 LOG(ERROR) << "WaitForServiceToBeAvailable failed."; |
| 50 callback.Run(std::string()); | 62 callback.Run(std::string()); |
| 51 return; | 63 return; |
| 52 } | 64 } |
| 53 DBusThreadManager::Get()->GetCryptohomeClient()->GetSystemSalt( | 65 DBusThreadManager::Get()->GetCryptohomeClient()->GetSystemSalt( |
| 54 base::Bind(&SystemSaltGetter::DidGetSystemSalt, | 66 base::Bind(&SystemSaltGetter::DidGetSystemSalt, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 } | 108 } |
| 97 | 109 |
| 98 // static | 110 // static |
| 99 std::string SystemSaltGetter::ConvertRawSaltToHexString( | 111 std::string SystemSaltGetter::ConvertRawSaltToHexString( |
| 100 const std::vector<uint8_t>& salt) { | 112 const std::vector<uint8_t>& salt) { |
| 101 return base::ToLowerASCII( | 113 return base::ToLowerASCII( |
| 102 base::HexEncode(reinterpret_cast<const void*>(salt.data()), salt.size())); | 114 base::HexEncode(reinterpret_cast<const void*>(salt.data()), salt.size())); |
| 103 } | 115 } |
| 104 | 116 |
| 105 } // namespace chromeos | 117 } // namespace chromeos |
| OLD | NEW |